[edk2] [PATCH] MdeModulePkg MemoryProfile.h:two bytes of Reserved[4] as ActionStringOffset

2016-07-07 Thread Star Zeng
At 94092aa60341a3e4b1e1ea7c362781b8404ac538, we extended
MEMORY_PROFILE_ALLOC_INFO to add ActionStringOffset and
Reserved2[6] fields, that was not aware the Reserved[4]
field can be reused to have better memory profile database
size efficiency.

With the patch, PcdMemoryProfilePropertyMask|0x3 and
PcdMemoryProfileMemoryType|0x, the memory profile
database size can be reduced as below on my sample platform.

UefiMemoryProfileSize - 0x1597A8 -> UefiMemoryProfileSize - 0x12AB28
SmramProfileSize - 0xCF68 -> SmramProfileSize - 0xB8E8

Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Include/Guid/MemoryProfile.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Include/Guid/MemoryProfile.h 
b/MdeModulePkg/Include/Guid/MemoryProfile.h
index 38a64945e368..777f950db79a 100644
--- a/MdeModulePkg/Include/Guid/MemoryProfile.h
+++ b/MdeModulePkg/Include/Guid/MemoryProfile.h
@@ -146,13 +146,12 @@ typedef struct {
   MEMORY_PROFILE_COMMON_HEADER  Header;
   PHYSICAL_ADDRESS  CallerAddress;
   UINT32SequenceId;
-  UINT8 Reserved[4];
+  UINT8 Reserved[2];
+  UINT16ActionStringOffset;
   MEMORY_PROFILE_ACTION Action;
   EFI_MEMORY_TYPE   MemoryType;
   PHYSICAL_ADDRESS  Buffer;
   UINT64Size;
-  UINT16ActionStringOffset;
-  UINT8 Reserved2[6];
 //CHAR8 ActionString[];
 } MEMORY_PROFILE_ALLOC_INFO;
 
-- 
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/3] IntelFrameworkModulePkg BdsDxe: Use definition in IndustryStandard/Smbios.h

2016-07-27 Thread Star Zeng
Cc: Ruiyu Ni 
Cc: Eric Dong 
Cc: Jeff Fan 
Cc: Amy Chan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c 
b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
index fc8e50f1450e..c771974ca0d2 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
@@ -747,7 +747,7 @@ UpdateFrontPageStrings (
 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
 Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
 while (!EFI_ERROR(Status)) {
-  if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {
+  if (Record->Type == SMBIOS_TYPE_BIOS_INFORMATION) {
 Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;
 StrIndex = Type0Record->BiosVersion;
 GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + 
Type0Record->Hdr.Length), StrIndex, &NewString);
@@ -756,7 +756,7 @@ UpdateFrontPageStrings (
 FreePool (NewString);
   }
 
-  if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) {
+  if (Record->Type == SMBIOS_TYPE_SYSTEM_INFORMATION) {
 Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;
 StrIndex = Type1Record->ProductName;
 GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + 
Type1Record->Hdr.Length), StrIndex, &NewString);
@@ -765,7 +765,7 @@ UpdateFrontPageStrings (
 FreePool (NewString);
   }
 
-  if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {
+  if (Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) {
 Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;
 StrIndex = Type4Record->ProcessorVersion;
 GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + 
Type4Record->Hdr.Length), StrIndex, &NewString);
@@ -774,7 +774,7 @@ UpdateFrontPageStrings (
 FreePool (NewString);
   }
 
-  if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {
+  if (Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) {
 Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;
 ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString);
 TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED);
@@ -782,7 +782,7 @@ UpdateFrontPageStrings (
 FreePool (NewString);
   }
 
-  if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
+  if ( Record->Type == SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
 Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;
 if (Type19Record->StartingAddress != 0x ) {
   InstalledMemory += RShiftU64(Type19Record->EndingAddress -
-- 
2.7.0.windows.1

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


[edk2] [PATCH 2/3] MdeModulePkg UiApp: Use definition in IndustryStandard/Smbios.h

2016-07-27 Thread Star Zeng
Cc: Ruiyu Ni 
Cc: Eric Dong 
Cc: Feng Tian 
Cc: Amy Chan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Application/UiApp/FrontPage.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Application/UiApp/FrontPage.c 
b/MdeModulePkg/Application/UiApp/FrontPage.c
index aef0e79124de..bda5ff9231b9 100644
--- a/MdeModulePkg/Application/UiApp/FrontPage.c
+++ b/MdeModulePkg/Application/UiApp/FrontPage.c
@@ -579,7 +579,7 @@ UpdateFrontPageBannerStrings (
   SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
   Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
   while (!EFI_ERROR(Status)) {
-if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {
+if (Record->Type == SMBIOS_TYPE_BIOS_INFORMATION) {
   Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;
   StrIndex = Type0Record->BiosVersion;
   GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + 
Type0Record->Hdr.Length), StrIndex, &NewString);
@@ -597,7 +597,7 @@ UpdateFrontPageBannerStrings (
   }
 }
 
-if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) {
+if (Record->Type == SMBIOS_TYPE_SYSTEM_INFORMATION) {
   Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;
   StrIndex = Type1Record->ProductName;
   GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + 
Type1Record->Hdr.Length), StrIndex, &NewString);
@@ -606,7 +606,7 @@ UpdateFrontPageBannerStrings (
   FreePool (NewString);
 }
 
-if ((Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) && !FoundCpu) {
+if ((Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) && !FoundCpu) {
   Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;
   //
   // The information in the record should be only valid when the CPU 
Socket is populated.
@@ -627,7 +627,7 @@ UpdateFrontPageBannerStrings (
   }
 }
 
-if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
+if ( Record->Type == SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
   Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;
   if (Type19Record->StartingAddress != 0x ) {
 InstalledMemory += RShiftU64(Type19Record->EndingAddress -
-- 
2.7.0.windows.1

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


[edk2] [PATCH 0/3] Use definition in IndustryStandard/Smbios.h

2016-07-27 Thread Star Zeng
Star Zeng (3):
  IntelFrameworkModulePkg BdsDxe: Use definition in
IndustryStandard/Smbios.h
  MdeModulePkg UiApp: Use definition in IndustryStandard/Smbios.h
  MdeModulePkg SmbiosDxe: Use definition in IndustryStandard/Smbios.h

 IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c | 10 +-
 MdeModulePkg/Application/UiApp/FrontPage.c   |  8 
 MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c |  6 +++---
 3 files changed, 12 insertions(+), 12 deletions(-)

-- 
2.7.0.windows.1

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


[edk2] [PATCH 3/3] MdeModulePkg SmbiosDxe: Use definition in IndustryStandard/Smbios.h

2016-07-27 Thread Star Zeng
Cc: Feng Tian 
Cc: Amy Chan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c 
b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
index 809dff84ac9b..ea762d59b9bd 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
@@ -2,7 +2,7 @@
   This code produces the Smbios protocol. It also responsible for constructing 
   SMBIOS table into system table.
   
-Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -1127,7 +1127,7 @@ SmbiosCreateTable (
   // Create End-Of-Table structure
   //
   GetMaxSmbiosHandle(SmbiosProtocol, &SmbiosHandle);
-  EndStructure.Header.Type = EFI_SMBIOS_TYPE_END_OF_TABLE;
+  EndStructure.Header.Type = SMBIOS_TYPE_END_OF_TABLE;
   EndStructure.Header.Length = (UINT8) sizeof (EFI_SMBIOS_TABLE_HEADER);
   EndStructure.Header.Handle = SmbiosHandle;
   EndStructure.Tailing[0] = 0;
@@ -1300,7 +1300,7 @@ SmbiosCreate64BitTable (
   // Create End-Of-Table structure
   //
   GetMaxSmbiosHandle(SmbiosProtocol, &SmbiosHandle);
-  EndStructure.Header.Type = EFI_SMBIOS_TYPE_END_OF_TABLE;
+  EndStructure.Header.Type = SMBIOS_TYPE_END_OF_TABLE;
   EndStructure.Header.Length = (UINT8) sizeof (EFI_SMBIOS_TABLE_HEADER);
   EndStructure.Header.Handle = SmbiosHandle;
   EndStructure.Tailing[0] = 0;
-- 
2.7.0.windows.1

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


[edk2] [PATCH] ShellPkg SmbiosView: Show "SocketDesignation" instead of "Socket" for Type 4

2016-08-05 Thread Star Zeng
It is to make the info shown more aligned with SMBIOS spec.

Cc: Amy Chan 
Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index 3f99dc4825dc..7e17b69d5afa 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -1,7 +1,7 @@
 /** @file
   Module for clarifying the content of the smbios structure element 
information.
 
-  Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
+  Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.  
   (C) Copyright 2015 Hewlett Packard Enterprise Development LP
   This program and the accompanying materials
@@ -399,7 +399,7 @@ SmbiosPrintStructure (
   // Processor Information (Type 4)
   //
   case 4:
-PRINT_PENDING_STRING (Struct, Type4, Socket);
+PRINT_SMBIOS_STRING (Struct, Struct->Type4->Socket, SocketDesignation)
 DisplayProcessorType (Struct->Type4->ProcessorType, Option);
 if (AE_SMBIOS_VERSION (0x2, 0x6) && (Struct->Hdr->Length > 0x28) &&
 (Struct->Type4->ProcessorFamily == 0xFE)) {
-- 
2.8.1.windows.1

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


[edk2] [PATCH] PcAtChipsetPkg AcpiTimerLib: Get more accurate TSC Frequency

2016-08-10 Thread Star Zeng
Minimize the code overhead between the two TSC reads by adding
new internal API to calculate TSC Frequency instead of reusing
MicroSecondDelay ().

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Paul A Lohr 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c | 56 +-
 .../Library/AcpiTimerLib/BaseAcpiTimerLib.c| 33 -
 .../Library/AcpiTimerLib/DxeAcpiTimerLib.c | 31 
 3 files changed, 99 insertions(+), 21 deletions(-)

diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c 
b/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
index 806a4f7ce24c..e6fea231123d 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
@@ -1,7 +1,7 @@
 /** @file
   ACPI Timer implements one instance of Timer Library.
 
-  Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -335,3 +335,57 @@ GetTimeInNanoSecond (
 
   return NanoSeconds;
 }
+
+/**
+  Calculate TSC frequency.
+
+  The TSC counting frequency is determined by comparing how far it counts
+  during a 100us period as determined by the ACPI timer. The ACPI timer is
+  used because it counts at a known frequency.
+  The TSC is sampled, followed by waiting for ACPI_TIMER_FREQUENCY / 1
+  clocks of the ACPI timer, or 100us. The TSC is then sampled again. The
+  difference multiplied by 1 is the TSC frequency. There will be a small
+  error because of the overhead of reading the ACPI timer. An attempt is
+  made to determine and compensate for this error.
+
+  @return The number of TSC counts per second.
+
+**/
+UINT64
+InternalCalculateTscFrequency (
+  VOID
+  )
+{
+  UINT64  StartTSC;
+  UINT64  EndTSC;
+  UINT16  TimerAddr;
+  UINT32  Ticks;
+  UINT64  TscFrequency;
+  BOOLEAN InterruptState;
+
+  InterruptState = SaveAndDisableInterrupts ();
+
+  TimerAddr = InternalAcpiGetAcpiTimerIoPort ();
+  Ticks = IoRead32 (TimerAddr) + (ACPI_TIMER_FREQUENCY / 1);// Set 
Ticks to 100us in the future
+
+  StartTSC = AsmReadTsc (); // Get 
base value for the TSC
+  //
+  // Wait until the ACPI timer has counted 100us.
+  // Timer wrap-arounds are handled correctly by this function.
+  // When the current ACPI timer value is greater than 'Ticks', the while loop 
will exit.
+  //
+  while (((Ticks - IoRead32 (TimerAddr)) & BIT23) == 0) {
+CpuPause();
+  }
+  EndTSC = AsmReadTsc ();   // TSC 
value 100us later
+
+  TscFrequency = MultU64x32 (
+   (EndTSC - StartTSC), // Number 
of TSC counts in 100us
+   1// Number 
of 100us in a second
+   );
+
+  SetInterruptState (InterruptState);
+
+  return TscFrequency;
+}
+
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c 
b/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
index 21fdb79908b8..8819ebcfccef 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
@@ -1,7 +1,7 @@
 /** @file
   ACPI Timer implements one instance of Timer Library.
 
-  Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -17,6 +17,26 @@
 #include 
 
 /**
+  Calculate TSC frequency.
+
+  The TSC counting frequency is determined by comparing how far it counts
+  during a 100us period as determined by the ACPI timer. The ACPI timer is
+  used because it counts at a known frequency.
+  The TSC is sampled, followed by waiting for ACPI_TIMER_FREQUENCY / 1
+  clocks of the ACPI timer, or 100us. The TSC is then sampled again. The
+  difference multiplied by 1 is the TSC frequency. There will be a small
+  error because of the overhead of reading the ACPI timer. An attempt is
+  made to determine and compensate for this error.
+
+  @return The number of TSC counts per second.
+
+**/
+UINT64
+InternalCalculateTscFrequency (
+  VOID
+  );
+
+/**
   Internal function to retrieves the 64-bit frequency in Hz.
 
   Internal function to retrieves the 64-bit frequency in Hz.
@@ -29,14 +49,5 @@ InternalGetPerformanceCounterFrequency (
   VOID
   ) 
 {
-  BOOLEAN  InterruptState;
-  UINT64   Count;
-  UINT

[edk2] [PATCH] PcAtChipsetPkg AcpiTimerLib: Wait 363 ACPI timer counts to get TSC Freq

2016-08-16 Thread Star Zeng
Compute the number of ticks to wait to measure TSC frequency.
Instead of (ACPI_TIMER_FREQUENCY / 1) = 357 and 357 * 1 = 357,
use 363 * 9861 = 3579543 Hz which is within 2 Hz of ACPI_TIMER_FREQUENCY.
363 counts is a calibration time of 101.4 uS.

The idea comes from Michael and Paolo.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Paolo Bonzini 
Cc: Paul A Lohr 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c | 32 +-
 .../Library/AcpiTimerLib/BaseAcpiTimerLib.c| 14 +-
 .../Library/AcpiTimerLib/DxeAcpiTimerLib.c | 14 +-
 3 files changed, 33 insertions(+), 27 deletions(-)

diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c 
b/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
index e6fea231123d..020031e3f4a5 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c
@@ -340,13 +340,13 @@ GetTimeInNanoSecond (
   Calculate TSC frequency.
 
   The TSC counting frequency is determined by comparing how far it counts
-  during a 100us period as determined by the ACPI timer. The ACPI timer is
-  used because it counts at a known frequency.
-  The TSC is sampled, followed by waiting for ACPI_TIMER_FREQUENCY / 1
-  clocks of the ACPI timer, or 100us. The TSC is then sampled again. The
-  difference multiplied by 1 is the TSC frequency. There will be a small
-  error because of the overhead of reading the ACPI timer. An attempt is
-  made to determine and compensate for this error.
+  during a 101.4 us period as determined by the ACPI timer.
+  The ACPI timer is used because it counts at a known frequency.
+  The TSC is sampled, followed by waiting 363 counts of the ACPI timer,
+  or 101.4 us. The TSC is then sampled again. The difference multiplied by
+  9861 is the TSC frequency. There will be a small error because of the
+  overhead of reading the ACPI timer. An attempt is made to determine and
+  compensate for this error.
 
   @return The number of TSC counts per second.
 
@@ -366,22 +366,28 @@ InternalCalculateTscFrequency (
   InterruptState = SaveAndDisableInterrupts ();
 
   TimerAddr = InternalAcpiGetAcpiTimerIoPort ();
-  Ticks = IoRead32 (TimerAddr) + (ACPI_TIMER_FREQUENCY / 1);// Set 
Ticks to 100us in the future
+  //
+  // Compute the number of ticks to wait to measure TSC frequency.
+  // Use 363 * 9861 = 3579543 Hz which is within 2 Hz of ACPI_TIMER_FREQUENCY.
+  // 363 counts is a calibration time of 101.4 uS.
+  //
+  Ticks = IoRead32 (TimerAddr) + 363;
 
   StartTSC = AsmReadTsc (); // Get 
base value for the TSC
   //
-  // Wait until the ACPI timer has counted 100us.
+  // Wait until the ACPI timer has counted 101.4 us.
   // Timer wrap-arounds are handled correctly by this function.
-  // When the current ACPI timer value is greater than 'Ticks', the while loop 
will exit.
+  // When the current ACPI timer value is greater than 'Ticks',
+  // the while loop will exit.
   //
   while (((Ticks - IoRead32 (TimerAddr)) & BIT23) == 0) {
 CpuPause();
   }
-  EndTSC = AsmReadTsc ();   // TSC 
value 100us later
+  EndTSC = AsmReadTsc ();   // TSC 
value 101.4 us later
 
   TscFrequency = MultU64x32 (
-   (EndTSC - StartTSC), // Number 
of TSC counts in 100us
-   1// Number 
of 100us in a second
+   (EndTSC - StartTSC), // Number 
of TSC counts in 101.4 us
+   9861 // Number 
of 101.4 us in a second
);
 
   SetInterruptState (InterruptState);
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c 
b/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
index 8819ebcfccef..29521f8b220b 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
@@ -20,13 +20,13 @@
   Calculate TSC frequency.
 
   The TSC counting frequency is determined by comparing how far it counts
-  during a 100us period as determined by the ACPI timer. The ACPI timer is
-  used because it counts at a known frequency.
-  The TSC is sampled, followed by waiting for ACPI_TIMER_FREQUENCY / 1
-  clocks of the ACPI timer, or 100us. The TSC is then sampled again. The
-  difference multiplied by 1 is the TSC frequency. There will be a small
-  error because of the overhead of reading the ACPI timer. An attempt is
-  made to determine and compensate for this error.
+  during a 101.4 us period as determined by the ACPI timer.
+  The ACPI timer is used because it counts at a known frequency.
+  The TSC is sampled, followed by waiting 363 counts 

[edk2] [PATCH 4/6] QuarkPlatformPkg: Declare PciSegmentLib in platform dsc

2016-08-19 Thread Star Zeng
PiDxeS3BootScriptLib has been updated to consume PciSegmentLib
instead of PciLib to support multiple PCI segment.
That means platforms need to add PciSegmentLib
declaration in platform dsc if the PciSegmentLib was
not declared in platform dsc before.

For platforms only have one segment,
MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf is recommended
to be used and declared in platform dsc for PiDxeS3BootScriptLib to have
equivalent functionality with before.

Cc: Jiewen Yao 
Cc: Michael D Kinney 
Cc: Chan Amy 
Cc: Kelly Steele 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 QuarkPlatformPkg/Quark.dsc| 1 +
 QuarkPlatformPkg/QuarkMin.dsc | 1 +
 2 files changed, 2 insertions(+)

diff --git a/QuarkPlatformPkg/Quark.dsc b/QuarkPlatformPkg/Quark.dsc
index 0b845bacf984..51a7b632074c 100644
--- a/QuarkPlatformPkg/Quark.dsc
+++ b/QuarkPlatformPkg/Quark.dsc
@@ -93,6 +93,7 @@ [LibraryClasses]
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
+  PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
   PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
   PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
   
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
diff --git a/QuarkPlatformPkg/QuarkMin.dsc b/QuarkPlatformPkg/QuarkMin.dsc
index 437b0a60694f..99ae0677eb8b 100644
--- a/QuarkPlatformPkg/QuarkMin.dsc
+++ b/QuarkPlatformPkg/QuarkMin.dsc
@@ -83,6 +83,7 @@ [LibraryClasses]
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
+  PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
   PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
   PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
   
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
-- 
2.7.0.windows.1

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


[edk2] [PATCH 3/6] Vlv2TbltDevicePkg: Declare PciSegmentLib in platform dsc

2016-08-19 Thread Star Zeng
PiDxeS3BootScriptLib has been updated to consume PciSegmentLib
instead of PciLib to support multiple PCI segment.
That means platforms need to add PciSegmentLib
declaration in platform dsc if the PciSegmentLib was
not declared in platform dsc before.

For platforms only have one segment,
MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf is recommended
to be used and declared in platform dsc for PiDxeS3BootScriptLib to have
equivalent functionality with before.

Cc: Jiewen Yao 
Cc: Michael D Kinney 
Cc: Chan Amy 
Cc: David Wei 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 1 +
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 1 +
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc| 1 +
 3 files changed, 3 insertions(+)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index 05eb3c698fcc..7125366681cd 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -119,6 +119,7 @@ [LibraryClasses.common]
   CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
+  PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
   PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
   PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
   
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index 32dda41625ac..6efaf32df256 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -119,6 +119,7 @@ [LibraryClasses.common]
   CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
+  PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
   PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
   PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
   
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index a176041e2951..6bb503d3cdd2 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -119,6 +119,7 @@ [LibraryClasses.common]
   CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
+  PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
   PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
   PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
   
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
-- 
2.7.0.windows.1

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


[edk2] [PATCH 2/6] MdeModulePkg PiDxeS3BootScriptLib: Support multiple PCI segment

2016-08-19 Thread Star Zeng
Support multiple PCI segment for PCI_CONFIG2 opcodes.

PiDxeS3BootScriptLib needs to be updated to consume PciSegmentLib
instead of PciLib. That means platforms need to add PciSegmentLib
declaration like below in platform dsc if the PciSegmentLib was
not declared in platform dsc before.

PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf

For platforms only have one segment,
MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf is recommended
to be used and declared in platform dsc for PiDxeS3BootScriptLib to have
equivalent functionality with before.

Cc: Jiewen Yao 
Cc: Michael D Kinney 
Cc: Chan Amy 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../PiDxeS3BootScriptLib/BootScriptExecute.c   | 135 ++---
 .../Library/PiDxeS3BootScriptLib/BootScriptSave.c  |  15 +--
 .../PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf|   2 +-
 .../PiDxeS3BootScriptLib/InternalBootScriptLib.h   |  18 +--
 4 files changed, 80 insertions(+), 90 deletions(-)

diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c 
b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
index 9e63273bc19c..b865d4452fc8 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
@@ -1,7 +1,7 @@
 /** @file
   Interpret and execute the S3 data in S3 boot script.
 
-  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions
@@ -639,9 +639,10 @@ BootScriptExecuteMemoryWrite (
 
 }
 /**
-  Performance PCI configuration read operation
+  Performance PCI configuration 2 read operation
 
   @param  Width   Width of the operation.
+  @param  Segment Pci segment number
   @param  Address Address of the operation.
   @param  Count   Count of the number of accesses to perform.
   @param  Buffer  Pointer to the buffer read from PCI config space
@@ -652,8 +653,9 @@ BootScriptExecuteMemoryWrite (
 
 **/
 EFI_STATUS
-ScriptPciCfgRead (
+ScriptPciCfg2Read (
   IN  S3_BOOT_SCRIPT_LIB_WIDTHWidth,
+  IN  UINT16   Segment,
   IN  UINT64   Address,
   IN  UINTNCount,
   OUT VOID*Buffer
@@ -663,11 +665,11 @@ ScriptPciCfgRead (
   UINTN   AddressStride;
   UINTN   BufferStride;
   PTR Out;
-  UINTN   PciAddress;
+  UINT64  PciAddress;
 
   Out.Buf = (UINT8 *) Buffer;
 
-  PciAddress = PCI_ADDRESS_ENCODE (Address);
+  PciAddress = PCI_ADDRESS_ENCODE (Segment, Address);
 
   Status = BuildLoopData (Width, PciAddress, &AddressStride, &BufferStride);
   if (EFI_ERROR (Status)) {
@@ -679,42 +681,42 @@ ScriptPciCfgRead (
   for (; Count > 0; Count--, PciAddress += AddressStride, Out.Buf += 
BufferStride) {
 switch (Width) {
 case S3BootScriptWidthUint8:
-  DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", PciAddress));
-  *Out.Uint8 = PciRead8 (PciAddress);
+  DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%016lx\n", PciAddress));
+  *Out.Uint8 = PciSegmentRead8 (PciAddress);
   break;
 case S3BootScriptWidthFifoUint8:
-  DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", 
PciAddress));
-  *Out.Uint8 = PciRead8 (PciAddress);
+  DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx\n", 
PciAddress));
+  *Out.Uint8 = PciSegmentRead8 (PciAddress);
   break;
 case S3BootScriptWidthFillUint8:
-  DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", 
PciAddress));
-  *Out.Uint8 = PciRead8 (PciAddress);
+  DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx\n", 
PciAddress));
+  *Out.Uint8 = PciSegmentRead8 (PciAddress);
   break;
 
 case S3BootScriptWidthUint16:
-  DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", PciAddress));
-  *Out.Uint16 = PciRead16 (PciAddress);
+  DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%016lx\n", PciAddress));
+  *Out.Uint16 = PciSegmentRead16 (PciAddress);
   break;
 case S3BootScriptWidthFifoUint16:
-  DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", 
PciAddress));
-  *Out.Uint16 = PciRead16 (PciAddress);
+  DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx\n", 
PciAddress));
+  *Out.Uint16 = PciSegmentRead16 (PciAddress);
   break;
 case S3BootScriptWidthFillUint16:
-  DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", 
PciAddress));
-  *Out.Uint16 = PciRead16 (PciAddress);
+  DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx\n", 
PciAddress));
+  *Out.Uint16 = Pc

[edk2] [PATCH 0/6] PiDxeS3BootScriptLib: Support multiple PCI segment

2016-08-19 Thread Star Zeng
Support multiple PCI segment for PCI_CONFIG2 opcodes.

PiDxeS3BootScriptLib needs to be updated to consume PciSegmentLib
instead of PciLib. That means platforms need to add PciSegmentLib
declaration like below in platform dsc if the PciSegmentLib was
not declared in platform dsc before.

PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf

For platforms only have one segment,
MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf is recommended
to be used and declared in platform dsc for PiDxeS3BootScriptLib to have
equivalent functionality with before.

Cc: Jiewen Yao 
Cc: Michael D Kinney 
Cc: Chan Amy 
Cc: Laszlo Ersek 
Cc: Kelly Steele 
Cc: David Wei 
Cc: Chao Zhang 

Star Zeng (6):
  MdeModulePkg PiDxeS3BootScriptLib: Remove the trailing white spaces
  MdeModulePkg PiDxeS3BootScriptLib: Support multiple PCI segment
  Vlv2TbltDevicePkg: Declare PciSegmentLib in platform dsc
  QuarkPlatformPkg: Declare PciSegmentLib in platform dsc
  QuarkSocPkg/QuarkSocPkg.dsc: Declare PciSegmentLib
  SecurityPkg/SecurityPkg.dsc: Declare PciSegmentLib

 .../PiDxeS3BootScriptLib/BootScriptExecute.c   | 411 +--
 .../BootScriptInternalFormat.h |   2 +-
 .../Library/PiDxeS3BootScriptLib/BootScriptSave.c  | 451 ++---
 .../PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf|   4 +-
 .../PiDxeS3BootScriptLib/DxeS3BootScriptLib.uni|   2 +-
 .../PiDxeS3BootScriptLib/InternalBootScriptLib.h   |  26 +-
 QuarkPlatformPkg/Quark.dsc |   1 +
 QuarkPlatformPkg/QuarkMin.dsc  |   1 +
 QuarkSocPkg/QuarkSocPkg.dsc|   1 +
 SecurityPkg/SecurityPkg.dsc|   1 +
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc|   1 +
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc  |   1 +
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc   |   1 +
 13 files changed, 450 insertions(+), 453 deletions(-)

-- 
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/6] MdeModulePkg PiDxeS3BootScriptLib: Remove the trailing white spaces

2016-08-19 Thread Star Zeng
Cc: Jiewen Yao 
Cc: Michael D Kinney 
Cc: Chan Amy 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../PiDxeS3BootScriptLib/BootScriptExecute.c   | 288 +++---
 .../BootScriptInternalFormat.h |   2 +-
 .../Library/PiDxeS3BootScriptLib/BootScriptSave.c  | 436 ++---
 .../PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf|   2 +-
 .../PiDxeS3BootScriptLib/DxeS3BootScriptLib.uni|   2 +-
 .../PiDxeS3BootScriptLib/InternalBootScriptLib.h   |  10 +-
 6 files changed, 370 insertions(+), 370 deletions(-)

diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c 
b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
index 45dd581b085d..9e63273bc19c 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
@@ -1,5 +1,5 @@
 /** @file
-  Interpret and execute the S3 data in S3 boot script. 
+  Interpret and execute the S3 data in S3 boot script.
 
   Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
 
@@ -23,7 +23,7 @@
   Management Bus (SMBus) Specification. The resulting transaction will be 
either that the SMBus
   slave devices accept this transaction or that this function returns with 
error.
 
-  @param  SmbusAddressAddress that encodes the SMBUS Slave 
Address, SMBUS Command, SMBUS Data Length, 
+  @param  SmbusAddressAddress that encodes the SMBUS Slave 
Address, SMBUS Command, SMBUS Data Length,
   and PEC.
   @param  Operation   Signifies which particular SMBus hardware 
protocol instance that
   it will use to execute the SMBus 
transactions. This SMBus
@@ -120,7 +120,7 @@ SmbusExecute (
   return EFI_INVALID_PARAMETER;
   }
 
-  return Status;  
+  return Status;
 }
 
 /**
@@ -130,7 +130,7 @@ SmbusExecute (
   @param Width  Width of the operation.
   @param AddressAddress of the operation.
   @param AddressStride  Instride for stepping input buffer.
-  @param BufferStride   Outstride for stepping output buffer.  
+  @param BufferStride   Outstride for stepping output buffer.
 
   @retval EFI_SUCCESS  Successful translation.
   @retval EFI_INVALID_PARAMETER Width or Address is invalid.
@@ -170,18 +170,18 @@ BuildLoopData (
 
 /**
   Perform IO read operation
-  
+
   @param[in]  Width   Width of the operation.
   @param[in]  Address Address of the operation.
   @param[in]  Count   Count of the number of accesses to perform.
-  @param[out] Buffer  Pointer to the buffer to read from I/O space.  
+  @param[out] Buffer  Pointer to the buffer to read from I/O space.
 
   @retval EFI_SUCCESS The data was written to the EFI System.
   @retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.
 Buffer is NULL.
 The Buffer is not aligned for the given Width.
-Address is outside the legal range of I/O 
ports.  
-
+Address is outside the legal range of I/O 
ports.
+
 **/
 EFI_STATUS
 ScriptIoRead (
@@ -274,18 +274,18 @@ ScriptIoRead (
 
 /**
   Perform IO write operation
-  
+
   @param[in]  Width Width of the operation.
   @param[in]  Address Address of the operation.
   @param[in]  Count Count of the number of accesses to perform.
-  @param[in]  Buffer Pointer to the buffer to write to I/O space.  
+  @param[in]  Buffer Pointer to the buffer to write to I/O space.
 
   @retval EFI_SUCCESS The data was written to the EFI System.
   @retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.
 Buffer is NULL.
 The Buffer is not aligned for the given Width.
-Address is outside the legal range of I/O 
ports.  
-
+Address is outside the legal range of I/O 
ports.
+
 **/
 EFI_STATUS
 ScriptIoWrite (
@@ -322,11 +322,11 @@ ScriptIoWrite (
   case S3BootScriptWidthUint8:
 DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", 
(UINTN)Address, (UINTN)*In.Uint8));
 IoWrite8 ((UINTN) Address, *In.Uint8);
-break;  
+break;
   case S3BootScriptWidthFifoUint8:
 DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", 
(UINTN)OriginalAddress, (UINTN)*In.Uint8));
 IoWrite8 ((UINTN) OriginalAddress, *In.Uint8);
-break;   
+break;
   case S3BootScriptWidthFillUint8:
 DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", 
(UINTN)Address, (UINTN)*OriginalIn.Uint8));
 IoWrite8 ((UINTN) Address, *OriginalIn.Uint8);
@@ -334,11 +334,11 @@ ScriptIoWrite (
   case S3BootScriptWidthUint1

[edk2] [PATCH 6/6] SecurityPkg/SecurityPkg.dsc: Declare PciSegmentLib

2016-08-19 Thread Star Zeng
PiDxeS3BootScriptLib has been updated to consume PciSegmentLib
instead of PciLib to support multiple PCI segment.

Cc: Jiewen Yao 
Cc: Michael D Kinney 
Cc: Chan Amy 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/SecurityPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 0ac4dfb5c83a..3b36d0f5a77a 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -66,6 +66,7 @@ [LibraryClasses]
   
TrEEPpVendorLib|SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.inf
   RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
   PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
+  PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
   
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
   LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
-- 
2.7.0.windows.1

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


[edk2] [PATCH 5/6] QuarkSocPkg/QuarkSocPkg.dsc: Declare PciSegmentLib

2016-08-19 Thread Star Zeng
PiDxeS3BootScriptLib has been updated to consume PciSegmentLib
instead of PciLib to support multiple PCI segment.

Cc: Jiewen Yao 
Cc: Michael D Kinney 
Cc: Chan Amy 
Cc: Kelly Steele 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 QuarkSocPkg/QuarkSocPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/QuarkSocPkg/QuarkSocPkg.dsc b/QuarkSocPkg/QuarkSocPkg.dsc
index 20301b36469b..42bb5bb9ab8a 100644
--- a/QuarkSocPkg/QuarkSocPkg.dsc
+++ b/QuarkSocPkg/QuarkSocPkg.dsc
@@ -60,6 +60,7 @@ [LibraryClasses]
   CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
+  PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
   PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
   PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
   
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
-- 
2.7.0.windows.1

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


[edk2] [PATCH 0/2] Return correct AuthenticationStatus for FvReadFile()

2016-08-26 Thread Star Zeng
Inherit the authentication status from FV.

Cc: Jiewen Yao 
Cc: Liming Gao 
Cc: Chao Zhang 

Star Zeng (2):
  MdeModulePkg DxeCore: Return correct AuthStatus for FvReadFile
  IntelFrameworkModulePkg FwVolDxe: Return correct AuthStatus for
FvReadFile

 .../Universal/FirmwareVolume/FwVolDxe/FwVolRead.c  | 7 +--
 MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c| 7 +--
 2 files changed, 10 insertions(+), 4 deletions(-)

-- 
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] MdeModulePkg DxeCore: Return correct AuthStatus for FvReadFile

2016-08-26 Thread Star Zeng
Inherit the authentication status from FV.

Cc: Jiewen Yao 
Cc: Liming Gao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c 
b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
index 1acac5d8fd79..00e0d7d289ec 100644
--- a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
+++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
@@ -1,7 +1,7 @@
 /** @file
   Implements functions to read firmware file
 
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -347,7 +347,10 @@ FvReadFile (
if ((FvDevice->FwVolHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == 
EFI_FVB2_MEMORY_MAPPED) {
  *FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;
}
-  *AuthenticationStatus = 0;
+  //
+  // Inherit the authentication status.
+  //
+  *AuthenticationStatus = FvDevice->AuthenticationStatus;
   *BufferSize = FileSize;
 
   if (Buffer == NULL) {
-- 
2.7.0.windows.1

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


[edk2] [PATCH 2/2] IntelFrameworkModulePkg FwVolDxe: Return correct AuthStatus for FvReadFile

2016-08-26 Thread Star Zeng
Inherit the authentication status from FV.

Cc: Jiewen Yao 
Cc: Liming Gao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../Universal/FirmwareVolume/FwVolDxe/FwVolRead.c  | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolRead.c 
b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolRead.c
index 8e2706bb8a72..0d9021914f33 100644
--- a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolRead.c
+++ b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolRead.c
@@ -1,7 +1,7 @@
 /** @file
   Implements functions to read firmware file.
 
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions
@@ -405,7 +405,10 @@ FvReadFile (
if ((FvDevice->FwVolHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == 
EFI_FVB2_MEMORY_MAPPED) {
  *FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;
}
-  *AuthenticationStatus = 0;
+  //
+  // Inherit the authentication status.
+  //
+  *AuthenticationStatus = FvDevice->AuthenticationStatus;
 
   //
   // If Buffer is NULL, we only want to get some information
-- 
2.7.0.windows.1

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


[edk2] [PATCH] MdeModulePkg VarCheck: #### in L"Boot####" are upper case hex

2016-08-26 Thread Star Zeng
UEFI spec:
Each load option entry resides in a Boot, Driver, SysPrep,
OsRecovery or PlatformRecovery variable where  is replaced
by a unique option number in printable hexadecimal representation using
the digits 0-9, and the upper case versions of the characters A-F
(-).

The patch also makes L"HwErrRec" follow this rule.

Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Library/VarCheckLib/VarCheckLib.c   | 16 
 .../Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c   | 14 +++---
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c 
b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c
index 41b209da169f..5ca0d3edca44 100644
--- a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c
+++ b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation functions and structures for var check services.
 
-Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -96,17 +96,17 @@ VARIABLE_ENTRY_PROPERTY mVarCheckVariableWithWildcardName[] 
= {
 };
 
 /**
-  Check if a Unicode character is a hexadecimal character.
+  Check if a Unicode character is an upper case hexadecimal character.
 
-  This function checks if a Unicode character is a
-  hexadecimal character.  The valid hexadecimal character is
-  L'0' to L'9', L'a' to L'f', or L'A' to L'F'.
+  This function checks if a Unicode character is an upper case
+  hexadecimal character.  The valid upper case hexadecimal character is
+  L'0' to L'9', or L'A' to L'F'.
 
 
   @param[in] Char   The character to check against.
 
-  @retval TRUE  If the Char is a hexadecmial character.
-  @retval FALSE If the Char is not a hexadecmial character.
+  @retval TRUE  If the Char is an upper case hexadecmial character.
+  @retval FALSE If the Char is not an upper case hexadecmial character.
 
 **/
 BOOLEAN
@@ -115,7 +115,7 @@ VarCheckInternalIsHexaDecimalDigitCharacter (
   IN CHAR16 Char
   )
 {
-  return (BOOLEAN) ((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= 
L'F') || (Char >= L'a' && Char <= L'f'));
+  return (BOOLEAN) ((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= 
L'F'));
 }
 
 /**
diff --git a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c 
b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
index 8f7126e6aea6..80dc6341adcf 100644
--- a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
+++ b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
@@ -678,17 +678,17 @@ EFI_GUID *mUefiDefinedGuid[] = {
 };
 
 /**
-  Check if a Unicode character is a hexadecimal character.
+  Check if a Unicode character is an upper case hexadecimal character.
 
-  This function checks if a Unicode character is a
-  hexadecimal character.  The valid hexadecimal character is
-  L'0' to L'9', L'a' to L'f', or L'A' to L'F'.
+  This function checks if a Unicode character is an upper case
+  hexadecimal character.  The valid upper case hexadecimal character is
+  L'0' to L'9', or L'A' to L'F'.
 
 
   @param[in] Char   The character to check against.
 
-  @retval TRUE  If the Char is a hexadecmial character.
-  @retval FALSE If the Char is not a hexadecmial character.
+  @retval TRUE  If the Char is an upper case hexadecmial character.
+  @retval FALSE If the Char is not an upper case hexadecmial character.
 
 **/
 BOOLEAN
@@ -697,7 +697,7 @@ VarCheckUefiIsHexaDecimalDigitCharacter (
   IN CHAR16 Char
   )
 {
-  return (BOOLEAN) ((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= 
L'F') || (Char >= L'a' && Char <= L'f'));
+  return (BOOLEAN) ((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= 
L'F'));
 }
 
 /**
-- 
2.7.0.windows.1

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


[edk2] [PATCH] MdeModulePkg SmbiosMeasurementDxe: Add NominalSpeed in Type 27 to black list

2016-08-31 Thread Star Zeng
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../SmbiosMeasurementDxe/SmbiosMeasurementDxe.c| 31 ++
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c 
b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
index f9e0196677a9..bc5e7464e133 100644
--- a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
+++ b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
@@ -1,7 +1,7 @@
 /** @file
   This driver measures SMBIOS table to TPM.
 
-Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -84,6 +84,9 @@ SMBIOS_FILTER_TABLE  mSmbiosFilterType22BlackList[] = {
 SMBIOS_FILTER_TABLE  mSmbiosFilterType23BlackList[] = {
   {0x17, OFFSET_OF(SMBIOS_TABLE_TYPE23, ResetCount),  
FIELD_SIZE_OF(SMBIOS_TABLE_TYPE23, ResetCount),  0},
 };
+SMBIOS_FILTER_TABLE  mSmbiosFilterType27BlackList[] = {
+  {0x1B, OFFSET_OF(SMBIOS_TABLE_TYPE27, NominalSpeed),
FIELD_SIZE_OF(SMBIOS_TABLE_TYPE27, NominalSpeed),0},
+};
 SMBIOS_FILTER_TABLE  mSmbiosFilterType39BlackList[] = {
   {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39, SerialNumber),
FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39, SerialNumber),
SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
   {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39, AssetTagNumber),  
FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39, AssetTagNumber),  
SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
@@ -101,6 +104,7 @@ SMBIOS_FILTER_STRUCT  mSmbiosFilterStandardTableBlackList[] 
= {
   {0x12, NULL, 0},
   {0x16, mSmbiosFilterType22BlackList, 
sizeof(mSmbiosFilterType22BlackList)/sizeof(mSmbiosFilterType22BlackList[0])},
   {0x17, mSmbiosFilterType23BlackList, 
sizeof(mSmbiosFilterType23BlackList)/sizeof(mSmbiosFilterType23BlackList[0])},
+  {0x1B, mSmbiosFilterType27BlackList, 
sizeof(mSmbiosFilterType27BlackList)/sizeof(mSmbiosFilterType27BlackList[0])},
   {0x1F, NULL, 0},
   {0x21, NULL, 0},
   {0x27, mSmbiosFilterType39BlackList, 
sizeof(mSmbiosFilterType39BlackList)/sizeof(mSmbiosFilterType39BlackList[0])},
@@ -281,18 +285,23 @@ FilterSmbiosEntry (
 } else {
   Filter = FilterStruct->Filter;
   for (Index = 0; Index < FilterStruct->FilterCount; Index++) {
-if ((Filter[Index].Flags & SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) {
-  CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset, 
sizeof(StringId));
-  if (StringId != 0) {
-// set ' ' for string field
-String = GetSmbiosStringById (TableEntry, StringId, &StringLen);
-ASSERT (String != NULL);
-//DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, 
StringLen));
-SetMem (String, StringLen, ' ');
+if (((SMBIOS_STRUCTURE *) TableEntry)->Length >= (Filter[Index].Offset 
+ Filter[Index].Size)) {
+  //
+  // The field is present in the SMBIOS entry.
+  //
+  if ((Filter[Index].Flags & SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) 
{
+CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset, 
sizeof(StringId));
+if (StringId != 0) {
+  // set ' ' for string field
+  String = GetSmbiosStringById (TableEntry, StringId, &StringLen);
+  ASSERT (String != NULL);
+  //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, 
StringLen));
+  SetMem (String, StringLen, ' ');
+}
   }
+  // zero non-string field
+  ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset, 
Filter[Index].Size);
 }
-// zero non-string field
-ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset, 
Filter[Index].Size);
   }
 }
   }
-- 
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] BaseTools: Follow PI1.4a to fix artificial limitation of PCD SkuId range

2016-09-02 Thread Star Zeng
From: Yonghong Zhu 

Current BaseTools follow previous PI spec to use UINT8 for SkuId, to
follow PI1.4a, BaseTools need to be updated to fix artificial limitation
of PCD SkuId range.

This patch is to update BaseTools to use UINT64 for SkuId, since the
PCD database structure needs to be naturally aligned, the PCD database
structure layout is adjusted to keep the natural alignment and version
is updated to 6.

Note: As the PCD database structure layout is adjusted, the structure
definition in MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h and
PCD drivers also need to be updated. That means the source code and
BaseTools need to be upgraded at the same time, and if they are not
upgraded at the same time, build error like below will be triggered
to help user identify the problem.

"Please make sure the version of PCD PEIM Service and the generated
PCD PEI Database match."

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu 
---
 BaseTools/Source/Python/AutoGen/GenPcdDb.py | 91 ++---
 1 file changed, 57 insertions(+), 34 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py 
b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index d5997f0e66aa..fc9ac7178f61 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -19,7 +19,7 @@ from ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB
 from ValidCheckingInfoObject import VAR_VALID_OBJECT_FACTORY
 from Common.VariableAttributes import VariableAttributes
 
-DATABASE_VERSION = 5
+DATABASE_VERSION = 6
 
 gPcdDatabaseAutoGenC = TemplateString("""
 //
@@ -27,6 +27,8 @@ gPcdDatabaseAutoGenC = TemplateString("""
 //
 #if 0
 ${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit = {
+  /* SkuIdTable */
+  { ${BEGIN}${SKUID_VALUE}, ${END} },
 ${BEGIN}  { ${INIT_VALUE_UINT64} }, /*  
${INIT_CNAME_DECL_UINT64}_${INIT_GUID_DECL_UINT64}[${INIT_NUMSKUS_DECL_UINT64}] 
*/
 ${END}
 ${BEGIN}  ${VARDEF_VALUE_UINT64}, /* 
${VARDEF_CNAME_UINT64}_${VARDEF_GUID_UINT64}_VariableDefault_${VARDEF_SKUID_UINT64}
 */
@@ -86,8 +88,6 @@ ${BEGIN}  { ${INIT_VALUE_BOOLEAN} }, /*  
${INIT_CNAME_DECL_BOOLEAN}_${INIT_GUID_
 ${END}
 ${BEGIN}  ${VARDEF_VALUE_BOOLEAN}, /* 
${VARDEF_CNAME_BOOLEAN}_${VARDEF_GUID_BOOLEAN}_VariableDefault_${VARDEF_SKUID_BOOLEAN}
 */
 ${END}
-  /* SkuIdTable */
-  { ${BEGIN}${SKUID_VALUE}, ${END} },
   ${SYSTEM_SKU_ID_VALUE}
 };
 #endif
@@ -122,6 +122,7 @@ gPcdDatabaseAutoGenH = TemplateString("""
 #define ${PHASE}_EXMAP_TABLE_EMPTY  ${EXMAP_TABLE_EMPTY}
 
 typedef struct {
+  UINT64 SkuIdTable[${PHASE}_SKUID_TABLE_SIZE];
 ${BEGIN}  UINT64 
${INIT_CNAME_DECL_UINT64}_${INIT_GUID_DECL_UINT64}[${INIT_NUMSKUS_DECL_UINT64}];
 ${END}
 ${BEGIN}  UINT64 
${VARDEF_CNAME_UINT64}_${VARDEF_GUID_UINT64}_VariableDefault_${VARDEF_SKUID_UINT64};
@@ -156,7 +157,6 @@ ${BEGIN}  BOOLEAN
${INIT_CNAME_DECL_BOOLEAN}_${INIT_GUID_DECL_BOOLEAN
 ${END}
 ${BEGIN}  BOOLEAN
${VARDEF_CNAME_BOOLEAN}_${VARDEF_GUID_BOOLEAN}_VariableDefault_${VARDEF_SKUID_BOOLEAN};
 ${END}
-  UINT8  SkuIdTable[${PHASE}_SKUID_TABLE_SIZE];
 ${SYSTEM_SKU_ID}
 } ${PHASE}_PCD_DATABASE_INIT;
 
@@ -176,7 +176,9 @@ ${END}
 
 typedef struct {
   //GUID  Signature;  // PcdDataBaseGuid
+  //UINT32BuildVersion;
   //UINT32Length;
+  //SKU_IDSystemSkuId;  // Current SkuId value.
   //UINT32UninitDataBaseSize;// Total size for PCD those 
default value with 0.
   //TABLE_OFFSET  LocalTokenNumberTableOffset;
   //TABLE_OFFSET  ExMapTableOffset;
@@ -184,11 +186,11 @@ typedef struct {
   //TABLE_OFFSET  StringTableOffset;
   //TABLE_OFFSET  SizeTableOffset;
   //TABLE_OFFSET  SkuIdTableOffset; 
+  //TABLE_OFFSET  PcdNameTableOffset;
   //UINT16LocalTokenCount;  // LOCAL_TOKEN_NUMBER for all
   //UINT16ExTokenCount; // EX_TOKEN_NUMBER for DynamicEx
   //UINT16GuidTableCount;   // The Number of Guid in GuidTable
-  //SKU_IDSystemSkuId;  // Current SkuId value.
-  //UINT8 Pad;
+  //UINT8 Pad[2];
   ${PHASE}_PCD_DATABASE_INITInit;
   ${PHASE}_PCD_DATABASE_UNINIT  Uninit;
 } ${PHASE}_PCD_DATABASE;
@@ -204,6 +206,8 @@ gEmptyPcdDatabaseAutoGenC = TemplateString("""
 //
 #if 0
 ${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit = {
+  /* SkuIdTable */
+  { 0 },
   /* ExMapTable */
   {
 {0, 0, 0}
@@ -226,8 +230,6 @@ ${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit = {
   {
 0, 0
   },
-  /* SkuIdTable */
-  { 0 },
   ${SYSTEM_SKU_ID_VALUE}
 };
 #endif
@@ -760,9 +762,9 @@ def BuildExDataBase(Dict):
 VardefValueBoolean = Dict['VARDEF_DB_VALUE_BOOLEAN']
 DbVardefValueBoolean = DbItemList(1, RawDataList = VardefValueBoolean)
 SkuidValue = Dict['SKUID_VALUE']
-DbSkuidValue = DbItemLi

[edk2] [PATCH 0/2] Follow PI1.4a to fix artificial limitation of PCD SkuId range

2016-09-02 Thread Star Zeng
Current BaseTools follow previous PI spec to use UINT8 for SkuId, to
follow PI1.4a, BaseTools need to be updated to fix artificial limitation
of PCD SkuId range.

BaseTools is updated to use UINT64 for SkuId, since the PCD database
structure needs to be naturally aligned, the PCD database structure
layout is adjusted to keep the natural alignment and version
is updated to 6.

The structure definition in MdeModulePkg/Include/Guid/
PcdDataBaseSignatureGuid.h and PCD drivers are also updated to match BaseTools.

Note: The source code and BaseTools need to be upgraded at the same time,
and if they are not upgraded at the same time, build error like below will
be triggered to help user identify the problem.

"Please make sure the version of PCD PEIM Service and the generated
PCD PEI Database match."

Star Zeng (1):
  MdeModulePkg PCD: Update PCD database structure definition to match
BaseTools

Yonghong Zhu (1):
  BaseTools: Follow PI1.4a to fix artificial limitation of PCD SkuId
range

 BaseTools/Source/Python/AutoGen/GenPcdDb.py| 91 ++
 .../Include/Guid/PcdDataBaseSignatureGuid.h| 14 ++--
 MdeModulePkg/Universal/PCD/Dxe/Pcd.c   |  2 +-
 MdeModulePkg/Universal/PCD/Dxe/Service.c   |  2 +-
 MdeModulePkg/Universal/PCD/Dxe/Service.h   |  4 +-
 MdeModulePkg/Universal/PCD/Pei/Pcd.c   |  2 +-
 MdeModulePkg/Universal/PCD/Pei/Service.c   |  4 +-
 MdeModulePkg/Universal/PCD/Pei/Service.h   |  4 +-
 8 files changed, 73 insertions(+), 50 deletions(-)

-- 
2.7.0.windows.1

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


[edk2] [PATCH 2/2] MdeModulePkg PCD: Update PCD database structure definition to match BaseTools

2016-09-02 Thread Star Zeng
To follow PI1.4a, BaseTools has be updated to fix artificial limitation of
SkuId range.

This patch is to update PCD database structure definition to match BaseTools.

Note: The source code and BaseTools need to be upgraded at the same time,
and if they are not upgraded at the same time, build error like below will
be triggered to help user identify the problem.

"Please make sure the version of PCD PEIM Service and the generated
PCD PEI Database match."

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h | 14 +++---
 MdeModulePkg/Universal/PCD/Dxe/Pcd.c |  2 +-
 MdeModulePkg/Universal/PCD/Dxe/Service.c |  2 +-
 MdeModulePkg/Universal/PCD/Dxe/Service.h |  4 ++--
 MdeModulePkg/Universal/PCD/Pei/Pcd.c |  2 +-
 MdeModulePkg/Universal/PCD/Pei/Service.c |  4 ++--
 MdeModulePkg/Universal/PCD/Pei/Service.h |  4 ++--
 7 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h 
b/MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h
index ac95f7e21ae8..d2e848800b75 100644
--- a/MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h
+++ b/MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h
@@ -1,7 +1,7 @@
 /** @file
   Guid for Pcd DataBase Signature.
 
-Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials are licensed and made available 
under
 the terms and conditions of the BSD License that accompanies this distribution.
 The full text of the license may be found at
@@ -23,7 +23,7 @@ extern EFI_GUID gPcdDataBaseSignatureGuid;
 //
 // Common definitions
 //
-typedef UINT8 SKU_ID;
+typedef UINT64 SKU_ID;
 
 #define PCD_TYPE_SHIFT28
 
@@ -62,7 +62,7 @@ typedef struct  {
 } DYNAMICEX_MAPPING;
 
 typedef struct {
-  UINT32  SkuDataStartOffset;   // Offset(with TYPE info) from the PCD_DB.
+  UINT32  SkuDataStartOffset;   // Offset(with DATUM TYPE info) from the 
PCD_DB.
   UINT32  SkuIdTableOffset; // Offset from the PCD_DB.
 } SKU_HEAD;
 
@@ -95,6 +95,7 @@ typedef struct {
 GUID  Signature;// PcdDataBaseGuid.
 UINT32BuildVersion;
 UINT32Length;
+SKU_IDSystemSkuId;  // Current SkuId value.
 UINT32UninitDataBaseSize;   // Total size for PCD those 
default value with 0.
 TABLE_OFFSET  LocalTokenNumberTableOffset;
 TABLE_OFFSET  ExMapTableOffset;
@@ -106,14 +107,15 @@ typedef struct {
 UINT16LocalTokenCount;  // LOCAL_TOKEN_NUMBER for all.
 UINT16ExTokenCount; // EX_TOKEN_NUMBER for 
DynamicEx.
 UINT16GuidTableCount;   // The Number of Guid in 
GuidTable.
-SKU_IDSystemSkuId;  // Current SkuId value.
-UINT8 Pad;  // Pad bytes to satisfy the 
alignment.
+UINT8 Pad[2];   // Pad bytes to satisfy the 
alignment.
 
 //
 // Default initialized external PCD database binary structure
 //
 // Padding is needed to keep necessary alignment
 //
+//SKU_ID SkuIdTable[];// SkuIds system 
supports.
+//SKU_ID SkuIndexTable[]; // SkuIds for 
each PCD with SKU enable.
 //UINT64 ValueUint64[];
 //UINT32 ValueUint32[];
 //VPD_HEAD   VpdHead[];   // VPD Offset
@@ -129,8 +131,6 @@ typedef struct {
 //UINT16 ValueUint16[];
 //UINT8  ValueUint8[];
 //BOOLEANValueBoolean[];
-//UINT8  SkuIdTable[];// SkuIds system 
supports.
-//UINT8  SkuIndexTable[]; // SkuIds for 
each PCD with SKU enable.
 
 } PCD_DATABASE_INIT;
 
diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c 
b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
index b9cf9e4e7646..1bb9098c04cf 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
@@ -239,7 +239,7 @@ DxeGetPcdInfoGetSku (
   VOID
   )
 {
-  return mPcdDatabase.DxeDb->SystemSkuId;
+  return (UINTN) mPcdDatabase.DxeDb->SystemSkuId;
 }
 
 /**
diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c 
b/MdeModulePkg/Universal/PCD/Dxe/Service.c
index 9ab456624fc7..6d0b0f8adec6 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Service.c
+++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c
@@ -958,7 +958,7 @@ GetSkuEnabledTokenNumber (
 {
   SKU_HEAD  *SkuHead;
   SKU_ID*SkuIdTable;
-  INTN  Index;
+  UINTN  

[edk2] [PATCH] MdeModulePkg DxeCorePerformanceLib: Only support linking with DxeCore

2017-01-12 Thread Star Zeng
DxeCorePerformanceLib is the performance log manager of PEI and DXE
phase, and it will also produce Performance(Ex) protocol, it should
only support linking with DxeCore.

Cc: Liming Gao 
Cc: Feng Tian 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf 
b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
index f73d0a4386ad..e091c6271426 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
@@ -9,7 +9,7 @@
 #  This library is mainly used by DxeCore to start performance logging to 
ensure that
 #  Performance and PerformanceEx Protocol are installed at the very beginning 
of DXE phase.
 #  
-#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -28,7 +28,7 @@ [Defines]
   FILE_GUID  = D0F78BBF-0A30-4c63-8A48-0F618A4AFACD
   MODULE_TYPE= DXE_CORE
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = PerformanceLib|DXE_CORE DXE_DRIVER 
DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
+  LIBRARY_CLASS  = PerformanceLib|DXE_CORE
 
   CONSTRUCTOR= DxeCorePerformanceLibConstructor
 
-- 
2.7.0.windows.1

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


[edk2] [PATCH] MdePkg DxeHobLib: Make GetHobList working before Constructor is called

2017-01-16 Thread Star Zeng
The latest PiSmmCore driver added several debug messages in the
function SmmAddMemoryRegion in Page.c. The function SmmAddMemoryRegion
is called by the library constructor
PiSmmCoreMemoryAllocationLibConstructor.

When PiSmmCoreMemoryAllocationLibConstructor is executed, the
constructor of DxeHobLib (HobLibConstructor in HobLib.c) is not
executed yet. But platform instance of DebugLib may need get hob
before printing any message. As a result, an ASSERT happens in the
function GetHobList.

The patch is to update GetHobList to get HOB list from system
configuration table when the HOB list is not retrieved and not cached
yet, and HobLibConstructor is also to be updated to just call
GetHobList.

Cc: Jiewen Yao 
Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Amy Chan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdePkg/Library/DxeHobLib/HobLib.c | 67 ---
 1 file changed, 34 insertions(+), 33 deletions(-)

diff --git a/MdePkg/Library/DxeHobLib/HobLib.c 
b/MdePkg/Library/DxeHobLib/HobLib.c
index c6c04e6a5924..bb65206b044a 100644
--- a/MdePkg/Library/DxeHobLib/HobLib.c
+++ b/MdePkg/Library/DxeHobLib/HobLib.c
@@ -1,7 +1,7 @@
 /** @file
   HOB Library implemenation for Dxe Phase.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -24,35 +24,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 VOID  *mHobList = NULL;
 
 /**
-  The constructor function caches the pointer to HOB list.
-  
-  The constructor function gets the start address of HOB list from system 
configuration table.
-  It will ASSERT() if that operation fails and it will always return 
EFI_SUCCESS. 
-
-  @param  ImageHandle   The firmware allocated handle for the EFI image.
-  @param  SystemTable   A pointer to the EFI System Table.
-  
-  @retval EFI_SUCCESS   The constructor successfully gets HobList.
-  @retval Other value   The constructor can't get HobList.
-
-**/
-EFI_STATUS
-EFIAPI
-HobLibConstructor (
-  IN EFI_HANDLEImageHandle,
-  IN EFI_SYSTEM_TABLE  *SystemTable
-  )
-{
-  EFI_STATUS  Status;
-
-  Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList);
-  ASSERT_EFI_ERROR (Status);
-  ASSERT (mHobList != NULL);
-
-  return Status;
-}
-
-/**
   Returns the pointer to the HOB list.
 
   This function returns the pointer to first HOB in the list.
@@ -62,9 +33,11 @@ HobLibConstructor (
   Since the System Configuration Table does not exist that the time the DXE 
Core is 
   launched, the DXE Core uses a global variable from the DXE Core Entry Point 
Library 
   to manage the pointer to the HOB list.
-  
+
   If the pointer to the HOB list is NULL, then ASSERT().
-  
+
+  This function also caches the pointer to the HOB list retrieved.
+
   @return The pointer to the HOB list.
 
 **/
@@ -74,11 +47,39 @@ GetHobList (
   VOID
   )
 {
-  ASSERT (mHobList != NULL);
+  EFI_STATUS  Status;
+
+  if (mHobList == NULL) {
+Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList);
+ASSERT_EFI_ERROR (Status);
+ASSERT (mHobList != NULL);
+  }
   return mHobList;
 }
 
 /**
+  The constructor function caches the pointer to HOB list by calling 
GetHobList()
+  and will always return EFI_SUCCESS. 
+
+  @param  ImageHandle   The firmware allocated handle for the EFI image.
+  @param  SystemTable   A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS   The constructor successfully gets HobList.
+
+**/
+EFI_STATUS
+EFIAPI
+HobLibConstructor (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  GetHobList ();
+
+  return EFI_SUCCESS;
+}
+
+/**
   Returns the next instance of a HOB type from the starting HOB.
 
   This function searches the first instance of a HOB type from the starting 
HOB pointer. 
-- 
2.7.0.windows.1

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


[edk2] [PATCH] ShellPkg SmbiosView: Add missing decoding of SlotType AGP8X

2017-01-16 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=344

SlotType AGP8X was added in SMBIOS spec 2.3.4, but the decoding
of it is missing. I found it when I am adding SMBIOS spec 3.1.0
support.

Cc: Jaben Carsey 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
index b802c5450907..bb7a19b04170 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
@@ -2,7 +2,7 @@
   Build a table, each item is (Key, Info) pair.
   And give a interface of query a string out of a table.
 
-  Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
+  Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
   (C) Copyright 2016-2017 Hewlett Packard Enterprise Development LP
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -1263,6 +1263,10 @@ TABLE_ITEM  SystemSlotTypeTable[] = {
 L"PCI-X"
   },
   {
+0x13,
+L"AGP 8X"
+  },
+  {
 0xA0,
 L"PC-98/C20 "
   },
-- 
2.7.0.windows.1

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


[edk2] [PATCH] ShellPkg SmbiosView: Add missing decoding of SMBIOS spec 3.0.0

2017-01-16 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=345

When I am adding SMBIOS spec 3.1.0, I found the decoding of
SMBIOS spec 3.0.0 for some definitions is missing.

Cc: Jaben Carsey 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../SmbiosView/PrintInfo.c | 18 -
 .../SmbiosView/QueryTable.c| 80 ++
 2 files changed, 97 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index d9adb1a7abb9..abbc9835b5d0 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -1,7 +1,7 @@
 /** @file
   Module for clarifying the content of the smbios structure element 
information.
 
-  Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.  
   (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
   This program and the accompanying materials
@@ -1580,6 +1580,10 @@ DisplayProcessorFamily (
 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_INTEL_ATOM), gShellDebug1HiiHandle);
 break;
 
+  case 0x2C:
+Print (L"Intel(R) Core(TM) M processor\n");
+break;
+
   case 0x30:
 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_ALPHA_FAMILY_2), gShellDebug1HiiHandle);
 break;
@@ -1768,6 +1772,18 @@ DisplayProcessorFamily (
 Print (L"68030\n");
 break;
 
+  case 0x66:
+Print (L"AMD Athlon(TM) X4 Quad-Core Processor Family\n");
+break;
+
+  case 0x67:
+Print (L"AMD Opteron(TM) X1000 Series Processor\n");
+break;
+
+  case 0x68:
+Print (L"AMD Opteron(TM) X2000 Series APU\n");
+break;
+
   case 0x70:
 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_HOBBIT_FAMILY), gShellDebug1HiiHandle);
 break;
diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
index bb7a19b04170..acca00d5c37d 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
@@ -248,6 +248,18 @@ TABLE_ITEM  SystemEnclosureTypeTable[] = {
 0x1D,
 L"  Blade Enclosure"
   },
+  {
+0x1E,
+L"  Tablet"
+  },
+  {
+0x1F,
+L"  Convertible"
+  },
+  {
+0x20,
+L"  Detachable"
+  },
 };
 
 TABLE_ITEM  SystemEnclosureStatusTable[] = {
@@ -503,6 +515,22 @@ TABLE_ITEM  ProcessorUpgradeTable[] = {
   {
 0x2C,
 L"Socket LGA1356-3"
+  },
+  {
+0x2D,
+L"Socket LGA1150"
+  },
+  {
+0x2E,
+L"Socket BGA1168"
+  },
+  {
+0x2F,
+L"Socket BGA1234"
+  },
+  {
+0x30,
+L"Socket BGA1364"
   }
 };
 
@@ -1267,6 +1295,58 @@ TABLE_ITEM  SystemSlotTypeTable[] = {
 L"AGP 8X"
   },
   {
+0x14,
+L"M.2 Socket 1-DP (Mechanical Key A)"
+  },
+  {
+0x15,
+L"M.2 Socket 1-SD (Mechanical Key E)"
+  },
+  {
+0x16,
+L"M.2 Socket 2 (Mechanical Key B)"
+  },
+  {
+0x17,
+L"M.2 Socket 3 (Mechanical Key M)"
+  },
+  {
+0x18,
+L"MXM Type I"
+  },
+  {
+0x19,
+L"MXM Type II"
+  },
+  {
+0x1A,
+L"MXM Type III (standard connector)"
+  },
+  {
+0x1B,
+L"MXM Type III (HE connector)"
+  },
+  {
+0x1C,
+L"MXM Type IV"
+  },
+  {
+0x1D,
+L"MXM 3.0 Type A"
+  },
+  {
+0x1E,
+L"MXM 3.0 Type B"
+  },
+  {
+0x1F,
+L"PCI Express Gen 2 SFF-8639"
+  },
+  {
+0x20,
+L"PCI Express Gen 3 SFF-8639"
+  },
+  {
 0xA0,
 L"PC-98/C20 "
   },
-- 
2.7.0.windows.1

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


[edk2] [PATCH 0/3] Add SMBIOS spec 3.1.0 support

2017-01-16 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=340

TPM Device (Type 43) support has been added at
713e4b007cb791829397522ad8f366dd1e08bee6 and
e9f0be021b7649c15d823e193110c0088cda9a89.

These patch are to add support for below items.
• BIOS Information (Type 0):
– Add new entry for extended BIOS ROM size
• System Enclosure or Chassis (Type 3):
– Add new chassis types: IoT Gateway and Embedded PC
– Add new chassis types: Mini PC and Stick PC
• Processor Information (Type 4):
– Add Intel Core m3 m5 m7 processors
– Add processor socket AM4
– Add processor socket LGA1151
– Add processor socket BGA1356, BGA1440, BGA1515
– Add AMD Opteron A-Series processor
– Add processor socket LGA3647-1
– Add processor socket SP3 Processors
– Add families for ARMv7 and ARMv8
– Add family for AMD Opteron(TM) X3000 Series APU
• Cache Information (Type 7):
– Extend to support Cache sizes >2047 MB
• System Slots (Type 9):
– Add Mini PCIe support

Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Feng Tian 
Cc: Ruiyu Ni 
Cc: Jaben Carsey 

Star Zeng (3):
  MdePkg: Add definitions for SMBIOS spec 3.1.0
  MdeModulePkg: Update PcdSmbiosVersion to 0x0301 for SMBIOS spec 3.1.0
  ShellPkg SmbiosView: Add decoding of SMBIOS spec 3.1.0

 MdeModulePkg/MdeModulePkg.dec  |  2 +-
 MdePkg/Include/IndustryStandard/SmBios.h   | 46 --
 .../SmbiosView/PrintInfo.c | 44 -
 .../SmbiosView/QueryTable.c| 56 ++
 .../SmbiosView/SmbiosViewStrings.uni   |  1 +
 .../UefiShellDebug1CommandsLib.uni |  3 +-
 6 files changed, 145 insertions(+), 7 deletions(-)

-- 
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/3] MdePkg: Add definitions for SMBIOS spec 3.1.0

2017-01-16 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=340

TPM Device (Type 43) definition has been added at
713e4b007cb791829397522ad8f366dd1e08bee6.

This patch is to add definitions for below items.
• BIOS Information (Type 0):
– Add new entry for extended BIOS ROM size
• System Enclosure or Chassis (Type 3):
– Add new chassis types: IoT Gateway and Embedded PC
– Add new chassis types: Mini PC and Stick PC
• Processor Information (Type 4):
– Add Intel Core m3 m5 m7 processors
– Add processor socket AM4
– Add processor socket LGA1151
– Add processor socket BGA1356, BGA1440, BGA1515
– Add AMD Opteron A-Series processor
– Add processor socket LGA3647-1
– Add processor socket SP3 Processors
– Add families for ARMv7 and ARMv8
– Add family for AMD Opteron(TM) X3000 Series APU
• Cache Information (Type 7):
– Extend to support Cache sizes >2047 MB
• System Slots (Type 9):
– Add Mini PCIe support

Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdePkg/Include/IndustryStandard/SmBios.h | 46 +---
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/SmBios.h 
b/MdePkg/Include/IndustryStandard/SmBios.h
index f72a56d6a0d3..f5c29bcbd0c8 100644
--- a/MdePkg/Include/IndustryStandard/SmBios.h
+++ b/MdePkg/Include/IndustryStandard/SmBios.h
@@ -1,7 +1,7 @@
 /** @file
-  Industry Standard Definitions of SMBIOS Table Specification v3.0.0.
+  Industry Standard Definitions of SMBIOS Table Specification v3.1.0.
 
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials are licensed and made available 
under 
 the terms and conditions of the BSD License that accompanies this 
distribution.  
@@ -268,6 +268,14 @@ typedef struct {
 } MISC_BIOS_CHARACTERISTICS_EXTENSION;
 
 ///
+/// Extended BIOS ROM size.
+///
+typedef struct {
+  UINT16 Size   :14;
+  UINT16 Unit   :2;
+} EXTENDED_BIOS_ROM_SIZE;
+
+///
 /// BIOS Information (Type 0).
 ///
 typedef struct {
@@ -283,6 +291,10 @@ typedef struct {
   UINT8 SystemBiosMinorRelease;
   UINT8 EmbeddedControllerFirmwareMajorRelease;
   UINT8 EmbeddedControllerFirmwareMinorRelease;
+  //
+  // Add for smbios 3.1.0
+  //
+  EXTENDED_BIOS_ROM_SIZEExtendedBiosSize;
 } SMBIOS_TABLE_TYPE0;
 
 ///
@@ -407,7 +419,11 @@ typedef enum {
   MiscChassisBladeEnclosure   = 0x1D,
   MiscChassisTablet   = 0x1E,
   MiscChassisConvertible  = 0x1F,
-  MiscChassisDetachable   = 0x20
+  MiscChassisDetachable   = 0x20,
+  MiscChassisIoTGateway   = 0x21,
+  MiscChassisEmbeddedPc   = 0x22,
+  MiscChassisMiniPc   = 0x23,
+  MiscChassisStickPc  = 0x24
 } MISC_CHASSIS_TYPE;
 
 ///
@@ -540,6 +556,9 @@ typedef enum {
   ProcessorFamilyIntelCoreSoloMobile= 0x2A,
   ProcessorFamilyIntelAtom  = 0x2B,
   ProcessorFamilyIntelCoreM = 0x2C,
+  ProcessorFamilyIntelCorem3= 0x2D,
+  ProcessorFamilyIntelCorem5= 0x2E,
+  ProcessorFamilyIntelCorem7= 0x2F,
   ProcessorFamilyAlpha  = 0x30,
   ProcessorFamilyAlpha21064 = 0x31,
   ProcessorFamilyAlpha21066 = 0x32,
@@ -590,6 +609,8 @@ typedef enum {
   ProcessorFamilyAmdAthlonX4QuadCore= 0x66,
   ProcessorFamilyAmdOpteronX1000Series  = 0x67,
   ProcessorFamilyAmdOpteronX2000Series  = 0x68,
+  ProcessorFamilyAmdOpteronASeries  = 0x69,
+  ProcessorFamilyAmdOpteronX3000Series  = 0x6A,
   ProcessorFamilyHobbit = 0x70,
   ProcessorFamilyCrusoeTM5000   = 0x78,
   ProcessorFamilyCrusoeTM3000   = 0x79,
@@ -699,6 +720,8 @@ typedef enum {
 /// Processor Information2 - Processor Family2.
 ///
 typedef enum {
+  ProcessorFamilyARMv7 = 0x0100,
+  ProcessorFamilyARMv8 = 0x0101,
   ProcessorFamilySH3   = 0x0104,
   ProcessorFamilySH4   = 0x0105,
   ProcessorFamilyARM   = 0x0118,
@@ -774,7 +797,14 @@ typedef enum {
   ProcessorUpgradeSocketLGA1150   = 0x2D,
   ProcessorUpgradeSocketBGA1168   = 0x2E,
   ProcessorUpgradeSocketBGA1234   = 0x2F,
-  ProcessorUpgradeSocketBGA1364   = 0x30
+  ProcessorUpgradeSocketBGA1364   = 0x30,
+  ProcessorUpgradeSocketAM4   = 0x31,
+  ProcessorUpgradeSocketLGA1151   = 0x32,
+  ProcessorUpgradeSocketBGA1356   = 0x33,
+  ProcessorUpgradeSocketBGA1440   = 0x34,
+  ProcessorUpgradeSocketBGA1515   = 0x35,
+  ProcessorUpgradeSocketLGA3647_1 = 0x36,
+  ProcessorUpgradeSocketSP3   = 0x37
 } PROCESSOR_UPGRADE;
 
 ///
@@ -1081,6 +,11 @@ typedef struct {
   UINT8 ErrorCorrectionType;///&l

[edk2] [PATCH 2/3] MdeModulePkg: Update PcdSmbiosVersion to 0x0301 for SMBIOS spec 3.1.0

2017-01-16 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=340

Cc: Feng Tian 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/MdeModulePkg.dec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 73071919646c..bde93a4aeccb 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1515,7 +1515,7 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, 
PcdsDynamicEx]
 
   ## SMBIOS version.
   # @Prompt SMBIOS version.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0300|UINT16|0x00010055
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0301|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.
-- 
2.7.0.windows.1

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


[edk2] [PATCH 3/3] ShellPkg SmbiosView: Add decoding of SMBIOS spec 3.1.0

2017-01-16 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=340

The decoding of TPM Device (Type 43) has been added at
e9f0be021b7649c15d823e193110c0088cda9a89.

Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../SmbiosView/PrintInfo.c | 44 -
 .../SmbiosView/QueryTable.c| 56 ++
 .../SmbiosView/SmbiosViewStrings.uni   |  1 +
 .../UefiShellDebug1CommandsLib.uni |  3 +-
 4 files changed, 102 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index abbc9835b5d0..ecb8e2492453 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -335,7 +335,17 @@ SmbiosPrintStructure (
   PRINT_STRUCT_VALUE (Struct, Type0, 
EmbeddedControllerFirmwareMajorRelease);
   PRINT_STRUCT_VALUE (Struct, Type0, 
EmbeddedControllerFirmwareMinorRelease);
 }
-
+if (AE_SMBIOS_VERSION (0x3, 0x1) && (Struct->Hdr->Length > 0x18)) {
+  ShellPrintHiiEx (
+-1,
+-1,
+NULL,
+STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_EXTENDED_BIOS_SIZE),
+gShellDebug1HiiHandle,
+Struct->Type0->ExtendedBiosSize.Size,
+(Struct->Type0->ExtendedBiosSize.Unit == 0x0) ? L"MB": L"GB"
+);
+}
 break;
 
   //
@@ -510,6 +520,10 @@ SmbiosPrintStructure (
 DisplayCacheErrCorrectingType (Struct->Type7->ErrorCorrectionType, Option);
 DisplayCacheSystemCacheType (Struct->Type7->SystemCacheType, Option);
 DisplayCacheAssociativity (Struct->Type7->Associativity, Option);
+if (AE_SMBIOS_VERSION (0x3, 0x1) && (Struct->Hdr->Length > 0x13)) {
+  PRINT_STRUCT_VALUE_H (Struct, Type7, MaximumCacheSize2);
+  PRINT_STRUCT_VALUE_H (Struct, Type7, InstalledSize2);
+}
 break;
 
   //
@@ -1584,6 +1598,18 @@ DisplayProcessorFamily (
 Print (L"Intel(R) Core(TM) M processor\n");
 break;
 
+  case 0x2D:
+Print (L"Intel(R) Core(TM) m3 processor\n");
+break;
+
+  case 0x2E:
+Print (L"Intel(R) Core(TM) m5 processor\n");
+break;
+
+  case 0x2F:
+Print (L"Intel(R) Core(TM) m7 processor\n");
+break;
+
   case 0x30:
 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_ALPHA_FAMILY_2), gShellDebug1HiiHandle);
 break;
@@ -1784,6 +1810,14 @@ DisplayProcessorFamily (
 Print (L"AMD Opteron(TM) X2000 Series APU\n");
 break;
 
+  case 0x69:
+Print (L"AMD Opteron(TM) A-Series Processor\n");
+break;
+
+  case 0x6A:
+Print (L"AMD Opteron(TM) X3000 Series APU\n");
+break;
+
   case 0x70:
 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_HOBBIT_FAMILY), gShellDebug1HiiHandle);
 break;
@@ -2215,6 +2249,14 @@ DisplayProcessorFamily2 (
   // Use switch to check
   //
   switch (Family2) {
+case 0x100:
+  Print (L"ARMv7\n");
+  break;
+
+case 0x101:
+  Print (L"ARMv8\n");
+  break;
+
 case 0x104:
   Print (L"SH-3\n");
   break;
diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
index acca00d5c37d..4a06c12e3b2b 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
@@ -260,6 +260,22 @@ TABLE_ITEM  SystemEnclosureTypeTable[] = {
 0x20,
 L"  Detachable"
   },
+  {
+0x21,
+L"  IoT Gateway"
+  },
+  {
+0x22,
+L"  Embedded PC"
+  },
+  {
+0x23,
+L"  Mini PC"
+  },
+  {
+0x24,
+L"  Stick PC"
+  },
 };
 
 TABLE_ITEM  SystemEnclosureStatusTable[] = {
@@ -531,6 +547,34 @@ TABLE_ITEM  ProcessorUpgradeTable[] = {
   {
 0x30,
 L"Socket BGA1364"
+  },
+  {
+0x31,
+L"Socket AM4"
+  },
+  {
+0x32,
+L"Socket LGA1151"
+  },
+  {
+0x33,
+L"Socket BGA1356"
+  },
+  {
+0x34,
+L"Socket BGA1440"
+  },
+  {
+0x35,
+L"Socket BGA1515"
+  },
+  {
+0x36,
+L"Socket LGA3647-1"
+  },
+  {
+0x37,
+L"Socket SP3"
   }
 };
 
@@ -1347,6 +1391,18 @@ TABLE_ITEM  SystemSlotTypeTable[] = {
 L"PCI Express Gen 3 SFF-8639"
   },
   {
+0x21,
+L"PCI Express Mini 52-pin (CEM spec. 2.0) with bottom-side keep-outs"
+  },
+  {
+0x22,
+L"PCI Express Mini 52-pin (CEM spec. 2.0) without bottom-side keep-outs"
+  },
+  {
+0x23,
+L"PCI Ex

[edk2] [PATCH] MdePkg: Correct comments of macros FixedPcdGetX/PatchPcdXXX in PcdLib.h

2017-01-16 Thread Star Zeng
The patch is also to refine comments of macros PcdToken and PcdTokenEx.

Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdePkg/Include/Library/PcdLib.h | 44 -
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/MdePkg/Include/Library/PcdLib.h b/MdePkg/Include/Library/PcdLib.h
index 4def32886294..9e7e09f52cdc 100644
--- a/MdePkg/Include/Library/PcdLib.h
+++ b/MdePkg/Include/Library/PcdLib.h
@@ -14,7 +14,7 @@
   There are no restrictions on the use of FeaturePcd(), FixedPcdGetXX(),
   PatchPcdGetXX(), and PatchPcdSetXX().
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -32,9 +32,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 /**
   Retrieves a token number based on a token name.
 
- Returns the token number associated with the PCD token specified by TokenName.
+  Returns the token number associated with the PCD token specified by 
TokenName.
   If TokenName is not a valid token in the token space, then the module will 
not build.
-  If TokenName is not a feature flag, then the module will not build.
 
   @param   TokenName  The name of the PCD token to retrieve the token number 
for.
 
@@ -49,7 +48,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
   Returns the Boolean value for the PCD feature flag specified by TokenName.
   If TokenName is not a valid token in the token space, then the module will 
not build.
-  If TokenName is not a feature flag, then the module will not build.
+  If TokenName is not a feature flag PCD, then the module will not build.
 
   @param   TokenName  The name of the PCD token to retrieve a current value 
for.
 
@@ -64,7 +63,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
   Returns the 8-bit value for the token specified by TokenName.
   If TokenName is not a valid token in the token space, then the module will 
not build.
-  If TokenName is not a feature flag, then the module will not build.
+  If TokenName is not a fixed at build PCD, then the module will not build.
 
   @param   TokenName  The name of the PCD token to retrieve a current value 
for.
 
@@ -79,7 +78,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
   Returns the 16-bit value for the token specified by TokenName.
   If TokenName is not a valid token in the token space, then the module will 
not build.
-  If TokenName is not a feature flag, then the module will not build.
+  If TokenName is not a fixed at build PCD, then the module will not build.
 
   @param   TokenName  The name of the PCD token to retrieve a current value 
for.
 
@@ -94,7 +93,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
   Returns the 32-bit value for the token specified by TokenName.
   If TokenName is not a valid token in the token space, then the module will 
not build.
-  If TokenName is not a feature flag, then the module will not build.
+  If TokenName is not a fixed at build PCD, then the module will not build.
 
   @param   TokenName  The name of the PCD token to retrieve a current value 
for.
 
@@ -109,7 +108,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
   Returns the 64-bit value for the token specified by TokenName.
   If TokenName is not a valid token in the token space, then the module will 
not build.
-  If TokenName is not a feature flag, then the module will not build.
+  If TokenName is not a fixed at build PCD, then the module will not build.
 
   @param   TokenName  The name of the PCD token to retrieve a current value 
for.
 
@@ -124,7 +123,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
   Returns the Boolean value for the token specified by TokenName.
   If TokenName is not a valid token in the token space, then the module will 
not build.
-  If TokenName is not a feature flag, then the module will not build.
+  If TokenName is not a fixed at build PCD, then the module will not build.
 
   @param   TokenName  The name of the PCD token to retrieve a current value 
for.
 
@@ -139,7 +138,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
   Returns a pointer to the buffer for the token specified by TokenName.
   If TokenName is not a valid token in the token space, then the module will 
not build.
-  If TokenName is not a feature flag, then the module will not build.
+  If TokenName is not a fixed at build PCD, then the module will not build.
 
   @param   TokenName  The name of the PCD token to

[edk2] [PATCH 2/7] IntelFrameworkPkg UefiLib: Make the event empty function public

2017-01-16 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=298

Then this event empty function can be used to remove
the duplication in drivers and other libraries.

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../Library/FrameworkUefiLib/UefiLib.c | 42 +++---
 .../Library/FrameworkUefiLib/UefiLibInternal.h | 20 +--
 .../Library/FrameworkUefiLib/UefiNotTiano.c|  4 +--
 3 files changed, 23 insertions(+), 43 deletions(-)

diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c 
b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c
index e198b729a329..30b6dc921828 100644
--- a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c
+++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c
@@ -5,7 +5,7 @@
   EFI Driver Model related protocols, manage Unicode string tables for UEFI 
Drivers, 
   and print messages on the console output and standard error devices.
 
-  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -310,7 +310,7 @@ EfiEventGroupSignal (
   Status = gBS->CreateEventEx (
   EVT_NOTIFY_SIGNAL,
   TPL_CALLBACK,
-  InternalEmptyFunction,
+  EfiEventEmptyFunction,
   NULL,
   EventGroup,
   &Event
@@ -325,6 +325,24 @@ EfiEventGroupSignal (
   return Status;
 }
 
+/**
+  An empty function that can be used as NotifyFunction parameter of
+  CreateEvent() or CreateEventEx().
+
+  @param Event  Event whose notification function is being invoked.
+  @param ContextThe pointer to the notification function's context,
+which is implementation-dependent.
+
+**/
+VOID
+EFIAPI
+EfiEventEmptyFunction (
+  IN EFI_EVENT  Event,
+  IN VOID   *Context
+  )
+{
+}
+
 /** 
   Returns the current TPL.
 
@@ -1457,23 +1475,3 @@ GetBestLanguage (
   //
   return NULL;
 }
-
-/**
-  An empty function to pass error checking of CreateEventEx ().
-
-  This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error
-  checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
-
-  @param  Event Event whose notification function is being 
invoked.
-  @param  Context   Pointer to the notification function's context,
-which is implementation-dependent.
-
-**/
-VOID
-EFIAPI
-InternalEmptyFunction (
-  IN EFI_EVENTEvent,
-  IN VOID *Context
-  )
-{
-}
diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h 
b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h
index 16c663626db2..51f58176defa 100644
--- a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h
+++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h
@@ -1,7 +1,7 @@
 /** @file
   Internal include file for UefiLib.
 
-  Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD 
License
which accompanies this distribution. The full text of the license may be 
found at
@@ -41,22 +41,4 @@
 #include 
 #include 
 
-/**
-  An empty function to pass error checking of CreateEventEx ().
-
-  This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error
-  checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
-
-  @param  Event Event whose notification function is being 
invoked.
-  @param  Context   Pointer to the notification function's context,
-which is implementation-dependent.
-
-**/
-VOID
-EFIAPI
-InternalEmptyFunction (
-  IN EFI_EVENTEvent,
-  IN VOID *Context
-  );
-
 #endif
diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c 
b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c
index 1221403672f9..e641aba647bb 100644
--- a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c
+++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c
@@ -45,7 +45,7 @@ EfiCreateEventLegacyBoot (
 {
   return EfiCreateEventLegacyBootEx (
TPL_CALLBACK,
-   InternalEmptyFunction,
+   EfiEventEmptyFunction,
NULL,
LegacyBootEvent
);
@@ -135,7 +135,7 @@ EfiCreateEventReadyToBoot (
 {
   return EfiCreateEventReadyToBootEx (
TPL_CALLBACK,
-  

[edk2] [PATCH 1/7] MdePkg UefiLib: Make the event empty function public

2017-01-16 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=298

Then this event empty function can be used to remove
the duplication in drivers and other libraries.

Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdePkg/Include/Library/UefiLib.h | 18 +-
 MdePkg/Library/UefiLib/UefiLib.c | 42 +++-
 MdePkg/Library/UefiLib/UefiLibInternal.h | 20 +--
 MdePkg/Library/UefiLib/UefiNotTiano.c| 10 
 4 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/UefiLib.h
index e8a6b8498e65..0b14792a0a7f 100644
--- a/MdePkg/Include/Library/UefiLib.h
+++ b/MdePkg/Include/Library/UefiLib.h
@@ -12,7 +12,7 @@
   of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is
   defined, then debug and assert related macros wrapped by it are the NULL 
implementations.
 
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials are licensed and made available 
under 
 the terms and conditions of the BSD License that accompanies this 
distribution.  
 The full text of the license may be found at
@@ -241,6 +241,22 @@ EfiEventGroupSignal (
   IN CONST EFI_GUID *EventGroup
   );
 
+/**
+  An empty function that can be used as NotifyFunction parameter of
+  CreateEvent() or CreateEventEx().
+
+  @param Event  Event whose notification function is being invoked.
+  @param ContextThe pointer to the notification function's context,
+which is implementation-dependent.
+
+**/
+VOID
+EFIAPI
+EfiEventEmptyFunction (
+  IN EFI_EVENT  Event,
+  IN VOID   *Context
+  );
+
 /** 
   Returns the current TPL.
 
diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/UefiLib.c
index 96d375fb6f2e..a7eee01240c1 100644
--- a/MdePkg/Library/UefiLib/UefiLib.c
+++ b/MdePkg/Library/UefiLib/UefiLib.c
@@ -5,7 +5,7 @@
   EFI Driver Model related protocols, manage Unicode string tables for UEFI 
Drivers, 
   and print messages on the console output and standard error devices.
 
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -332,7 +332,7 @@ EfiEventGroupSignal (
   Status = gBS->CreateEventEx (
   EVT_NOTIFY_SIGNAL,
   TPL_CALLBACK,
-  InternalEmptyFunction,
+  EfiEventEmptyFunction,
   NULL,
   EventGroup,
   &Event
@@ -347,6 +347,24 @@ EfiEventGroupSignal (
   return Status;
 }
 
+/**
+  An empty function that can be used as NotifyFunction parameter of
+  CreateEvent() or CreateEventEx().
+
+  @param Event  Event whose notification function is being invoked.
+  @param ContextThe pointer to the notification function's context,
+which is implementation-dependent.
+
+**/
+VOID
+EFIAPI
+EfiEventEmptyFunction (
+  IN EFI_EVENT  Event,
+  IN VOID   *Context
+  )
+{
+}
+
 /** 
   Returns the current TPL.
 
@@ -1587,23 +1605,3 @@ GetBestLanguage (
   //
   return NULL;
 }
-
-/**
-  An empty function to pass error checking of CreateEventEx ().
-
-  This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error
-  checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
-
-  @param  Event Event whose notification function is being 
invoked.
-  @param  Context   The pointer to the notification function's 
context,
-which is implementation-dependent.
-
-**/
-VOID
-EFIAPI
-InternalEmptyFunction (
-  IN EFI_EVENTEvent,
-  IN VOID *Context
-  )
-{
-}
diff --git a/MdePkg/Library/UefiLib/UefiLibInternal.h 
b/MdePkg/Library/UefiLib/UefiLibInternal.h
index 2311f27f1e6d..412ad1b89c9d 100644
--- a/MdePkg/Library/UefiLib/UefiLibInternal.h
+++ b/MdePkg/Library/UefiLib/UefiLibInternal.h
@@ -1,7 +1,7 @@
 /** @file
   Internal include file for UefiLib.
 
-  Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD 
License
which accompanies this distribution. The full text of the license may be 
found at
@@ -41,22 +41,4 @@
 #include 
 #include 
 
-/**
-  An empty function to pass error checking of Creat

[edk2] [PATCH 0/7] Make the event empty function in UefiLib public

2017-01-16 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=298

We found there are many event empty functions in EDK2 code base,
these patches are to make the event empty function in UefiLib public,
then this event empty function can be used to remove
the duplication in drivers and other libraries.

In CorebootPayloadPkg/QuarkPlatformPkg/ArmPlatformPkg, EfiEventGroupSignal
from UefiLib can be used to remove the duplication of event empty function.

Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Jeff Fan 
Cc: Feng Tian 
Cc: Ruiyu Ni 
Cc: Maurice Ma 
Cc: Prince Agyeman 
Cc: Kelly Steele 
Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Cc: Laszlo Ersek 

Star Zeng (7):
  MdePkg UefiLib: Make the event empty function public
  IntelFrameworkPkg UefiLib: Make the event empty function public
  MdeModulePkg: Use EfiEventEmptyFunction from UefiLib
  IntelFrameworkModulePkg: Use EfiEventEmptyFunction from UefiLib
  CorebootPayloadPkg: Use EfiEventGroupSignal from UefiLib
  QuarkPlatformPkg: Use EfiEventGroupSignal from UefiLib
  ArmPlatformPkg: Use EfiEventGroupSignal from UefiLib

 .../Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 36 ++-
 .../Library/PlatformIntelBdsLib/IntelBdsPlatform.h |  3 +-
 .../PlatformIntelBdsLib/PlatformIntelBdsLib.inf|  3 +-
 .../PlatformBootManagerLib/PlatformBootManager.c   | 25 ++---
 .../Universal/BdsDxe/BdsEntry.c| 20 +--
 .../Library/FrameworkUefiLib/UefiLib.c | 42 +++---
 .../Library/FrameworkUefiLib/UefiLibInternal.h | 20 +--
 .../Library/FrameworkUefiLib/UefiNotTiano.c|  4 +--
 MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c  | 23 ++--
 MdeModulePkg/Core/Dxe/DxeMain.h| 18 +-
 MdeModulePkg/Core/Dxe/Event/Event.c|  4 +--
 MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c | 19 ++
 .../Universal/Console/ConSplitterDxe/ConSplitter.c | 22 ++--
 .../Universal/Console/ConSplitterDxe/ConSplitter.h | 18 +-
 .../Universal/DriverSampleDxe/DriverSample.c   | 20 ++-
 .../Universal/SetupBrowserDxe/Presentation.c   | 20 ++-
 MdePkg/Include/Library/UefiLib.h   | 18 +-
 MdePkg/Library/UefiLib/UefiLib.c   | 42 +++---
 MdePkg/Library/UefiLib/UefiLibInternal.h   | 20 +--
 MdePkg/Library/UefiLib/UefiNotTiano.c  | 10 +++---
 .../PlatformBootManagerLib/PlatformBootManager.c   | 25 ++---
 21 files changed, 91 insertions(+), 321 deletions(-)

-- 
2.7.0.windows.1

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


[edk2] [PATCH 3/7] MdeModulePkg: Use EfiEventEmptyFunction from UefiLib

2017-01-16 Thread Star Zeng
Use EfiEventEmptyFunction from UefiLib and remove the duplication
of event empty function.

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

Cc: Feng Tian 
Cc: Ruiyu Ni 
Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c  | 23 ++
 MdeModulePkg/Core/Dxe/DxeMain.h| 18 +
 MdeModulePkg/Core/Dxe/Event/Event.c|  4 ++--
 MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c | 19 ++
 .../Universal/Console/ConSplitterDxe/ConSplitter.c | 22 ++---
 .../Universal/Console/ConSplitterDxe/ConSplitter.h | 18 +
 .../Universal/DriverSampleDxe/DriverSample.c   | 20 ++-
 .../Universal/SetupBrowserDxe/Presentation.c   | 20 ++-
 8 files changed, 14 insertions(+), 130 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c 
b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
index 69c3b11c6afc..5686d94e6a72 100644
--- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
@@ -26,7 +26,7 @@
   Depex - Dependency Expresion.
   SOR   - Schedule On Request - Don't schedule if this bit is set.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -392,25 +392,6 @@ CoreTrust (
   return EFI_NOT_FOUND;
 }
 
-
-/**
-  An empty function to pass error checking of CreateEventEx ().
-
-  @param  Event Event whose notification function is being 
invoked.
-  @param  Context   Pointer to the notification function's context,
-which is implementation-dependent.
-
-**/
-VOID
-EFIAPI
-CoreEmptyCallbackFunction (
-  IN EFI_EVENTEvent,
-  IN VOID *Context
-  )
-{
-  return;
-}
-
 /**
   This is the main Dispatcher for DXE and it exits when there are no more
   drivers to run. Drain the mScheduledQueue and load and start a PE
@@ -451,7 +432,7 @@ CoreDispatcher (
   Status = CoreCreateEventEx (
  EVT_NOTIFY_SIGNAL,
  TPL_NOTIFY,
- CoreEmptyCallbackFunction,
+ EfiEventEmptyFunction,
  NULL,
  &gEfiEventDxeDispatchGuid,
  &DxeDispatchEvent
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h
index 327d23a95234..ae35fbb5664e 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.h
+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
@@ -2,7 +2,7 @@
   The internal header file includes the common header files, defines
   internal structure and functions used by DxeCore module.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -2675,22 +2675,6 @@ CoreReleaseLock (
   IN EFI_LOCK  *Lock
   );
 
-
-/**
-  An empty function to pass error checking of CreateEventEx ().
-
-  @param  Event Event whose notification function is being 
invoked.
-  @param  Context   Pointer to the notification function's context,
-which is implementation-dependent.
-
-**/
-VOID
-EFIAPI
-CoreEmptyCallbackFunction (
-  IN EFI_EVENTEvent,
-  IN VOID *Context
-  );
-
 /**
   Read data from Firmware Block by FVB protocol Read. 
   The data may cross the multi block ranges.
diff --git a/MdeModulePkg/Core/Dxe/Event/Event.c 
b/MdeModulePkg/Core/Dxe/Event/Event.c
index 01715ec3ca7d..86ca369d56ff 100644
--- a/MdeModulePkg/Core/Dxe/Event/Event.c
+++ b/MdeModulePkg/Core/Dxe/Event/Event.c
@@ -1,7 +1,7 @@
 /** @file
   UEFI Event support functions implemented in this file.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 (C) Copyright 2015 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
@@ -143,7 +143,7 @@ CoreInitializeEventServices (
   CoreCreateEventEx (
 EVT_NOTIFY_SIGNAL,
 TPL_NOTIFY,
-CoreEmptyCallbackFunction,
+EfiEventEmptyFunction,
 NULL,
 &gIdleLoopEventGuid,
 &gIdleLoopEvent
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c
index 35131a94

[edk2] [PATCH 4/7] IntelFrameworkModulePkg: Use EfiEventEmptyFunction from UefiLib

2017-01-16 Thread Star Zeng
Use EfiEventEmptyFunction from UefiLib and remove the duplication
of event empty function.

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

Cc: Jeff Fan 
Cc: Ruiyu Ni 
Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c 
b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
index bf81de40a31d..8a64f041426a 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -83,24 +83,6 @@ BdsInitialize (
   return Status;
 }
 
-
-/**
-  An empty function to pass error checking of CreateEventEx ().
-
-  @param  Event Event whose notification function is being 
invoked.
-  @param  Context   Pointer to the notification function's context,
-which is implementation-dependent.
-
-**/
-VOID
-EFIAPI
-BdsEmptyCallbackFunction (
-  IN EFI_EVENTEvent,
-  IN VOID *Context
-  )
-{
-}
-
 /**
 
   This function attempts to boot for the boot order specified
@@ -144,7 +126,7 @@ BdsBootDeviceSelect (
 Status = gBS->CreateEventEx (
 EVT_NOTIFY_SIGNAL,
 TPL_CALLBACK,
-BdsEmptyCallbackFunction,
+EfiEventEmptyFunction,
 NULL,
 &gConnectConInEventGuid,
 &ConnectConInEvent
-- 
2.7.0.windows.1

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


[edk2] [PATCH 5/7] CorebootPayloadPkg: Use EfiEventGroupSignal from UefiLib

2017-01-16 Thread Star Zeng
Use EfiEventGroupSignal from UefiLib and remove
InternalBdsEmptyCallbackFuntion.

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

Cc: Maurice Ma 
Cc: Prince Agyeman 
Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../PlatformBootManagerLib/PlatformBootManager.c   | 25 ++
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git 
a/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c 
b/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index 56be30f7a041..7e92441da11f 100644
--- a/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -2,7 +2,7 @@
   This file include all platform action which can be customized
   by IBV/OEM.
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -17,16 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include "PlatformConsole.h"
 
 VOID
-EFIAPI
-InternalBdsEmptyCallbackFuntion (
-  IN EFI_EVENTEvent,
-  IN VOID *Context
-  )
-{
-  return;
-}
-
-VOID
 InstallReadyToLock (
   VOID
   )
@@ -34,24 +24,13 @@ InstallReadyToLock (
   EFI_STATUSStatus;
   EFI_HANDLEHandle;
   EFI_SMM_ACCESS2_PROTOCOL  *SmmAccess;
-  EFI_EVENT EndOfDxeEvent;
 
   DEBUG((DEBUG_INFO,"InstallReadyToLock  entering..\n"));
   //
   // Inform the SMM infrastructure that we're entering BDS and may run 3rd 
party code hereafter
   // Since PI1.2.1, we need signal EndOfDxe as ExitPmAuth
   //
-  Status = gBS->CreateEventEx (
-  EVT_NOTIFY_SIGNAL,
-  TPL_CALLBACK,
-  InternalBdsEmptyCallbackFuntion,
-  NULL,
-  &gEfiEndOfDxeEventGroupGuid,
-  &EndOfDxeEvent
-  );
-  ASSERT_EFI_ERROR (Status);
-  gBS->SignalEvent (EndOfDxeEvent);
-  gBS->CloseEvent (EndOfDxeEvent);
+  EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
   DEBUG((DEBUG_INFO,"All EndOfDxe callbacks have returned successfully\n"));
 
   //
-- 
2.7.0.windows.1

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


[edk2] [PATCH 6/7] QuarkPlatformPkg: Use EfiEventGroupSignal from UefiLib

2017-01-16 Thread Star Zeng
Use EfiEventGroupSignal from UefiLib and remove
InternalBdsEmptyCallbackFuntion.

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

Cc: Kelly Steele 
Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../PlatformBootManagerLib/PlatformBootManager.c   | 25 ++
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git 
a/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c 
b/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index b61eb03360a2..49aa15c11f15 100644
--- a/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -2,7 +2,7 @@
 This file include all platform action which can be customized
 by IBV/OEM.
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -176,16 +176,6 @@ PlatformRegisterFvBootOption (
   }
 }
 
-VOID
-EFIAPI
-InternalBdsEmptyCallbackFuntion (
-  IN EFI_EVENT  Event,
-  IN VOID   *Context
-  )
-{
-  return;
-}
-
 /**
   Do the platform specific action before the console is connected.
 
@@ -209,7 +199,6 @@ PlatformBootManagerBeforeConsole (
   EFI_BOOT_MODE BootMode;
   EFI_ACPI_S3_SAVE_PROTOCOL *AcpiS3Save;
   EFI_HANDLEHandle;
-  EFI_EVENT EndOfDxeEvent;
 
   //
   // Update the console variables.
@@ -294,17 +283,7 @@ PlatformBootManagerBeforeConsole (
   // Inform PI SMM drivers that BDS may run 3rd party code
   // Create and signal End of DXE event group
   //
-  Status = gBS->CreateEventEx (
-  EVT_NOTIFY_SIGNAL,
-  TPL_CALLBACK,
-  InternalBdsEmptyCallbackFuntion,
-  NULL,
-  &gEfiEndOfDxeEventGroupGuid,
-  &EndOfDxeEvent
-  );
-  ASSERT_EFI_ERROR (Status);
-  gBS->SignalEvent (EndOfDxeEvent);
-  gBS->CloseEvent (EndOfDxeEvent);
+  EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
 
   DEBUG((EFI_D_INFO,"All EndOfDxe callbacks have returned successfully\n"));
 
-- 
2.7.0.windows.1

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


[edk2] [PATCH 7/7] ArmPlatformPkg: Use EfiEventGroupSignal from UefiLib

2017-01-16 Thread Star Zeng
Use EfiEventGroupSignal from UefiLib and remove
EmptyCallbackFunction.

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

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 36 ++
 .../Library/PlatformIntelBdsLib/IntelBdsPlatform.h |  3 +-
 .../PlatformIntelBdsLib/PlatformIntelBdsLib.inf|  3 +-
 3 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c 
b/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
index ceb4f076e2a6..885866854329 100644
--- a/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
+++ b/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
 Copyright (c) 2014, ARM Ltd. All rights reserved.
 
 This program and the accompanying materials
@@ -31,24 +31,6 @@ PlatformIntelBdsConstructor (
   return EFI_SUCCESS;
 }
 
-/**
-  An empty function to pass error checking of CreateEventEx ().
-
-  @param  Event Event whose notification function is being 
invoked.
-  @param  Context   Pointer to the notification function's context,
-which is implementation-dependent.
-
-**/
-STATIC
-VOID
-EFIAPI
-EmptyCallbackFunction (
-  IN EFI_EVENTEvent,
-  IN VOID *Context
-  )
-{
-}
-
 //
 // BDS Platform Functions
 //
@@ -63,24 +45,10 @@ PlatformBdsInit (
   VOID
   )
 {
-  EFI_EVENT   EndOfDxeEvent;
-  EFI_STATUS  Status;
-
   //
   // Signal EndOfDxe PI Event
   //
-  Status = gBS->CreateEventEx (
-  EVT_NOTIFY_SIGNAL,
-  TPL_CALLBACK,
-  EmptyCallbackFunction,
-  NULL,
-  &gEfiEndOfDxeEventGroupGuid,
-  &EndOfDxeEvent
-  );
-  if (!EFI_ERROR (Status)) {
-gBS->SignalEvent (EndOfDxeEvent);
-gBS->CloseEvent (EndOfDxeEvent);
-  }
+  EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
 }
 
 STATIC
diff --git a/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h 
b/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h
index da428288fb9f..1329c54a1c3a 100644
--- a/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h
+++ b/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h
@@ -1,7 +1,7 @@
 /** @file
   Head file for BDS Platform specific code
 
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -28,6 +28,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/ArmPlatformPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf 
b/ArmPlatformPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
index daa0d91a2f76..a27adacbc1c2 100644
--- a/ArmPlatformPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+++ b/ArmPlatformPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
@@ -2,7 +2,7 @@
 #  Implementation for PlatformBdsLib library class interfaces.
 #  using ARM Platform framework.
 #
-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
 #  Copyright (c) 2014, ARM Ltd. All rights reserved.
 #
 #  This program and the accompanying materials
@@ -50,6 +50,7 @@ [LibraryClasses]
   UefiBootServicesTableLib
   PcdLib
   GenericBdsLib
+  UefiLib
 
 [Guids]
   gEfiEndOfDxeEventGroupGuid
-- 
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/3] MdePkg: Add definitions for SMBIOS spec 3.1.1

2017-01-22 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=349

This patch is to add definitions for below items.
Processor Information (Type 4):
- add socket SP3r2
- add AMD Zen Processor Family
Management Controller Host Interface (Type 42):
- include Host Interface Type and Protocol Identifier enumerations

Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdePkg/Include/IndustryStandard/SmBios.h | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/SmBios.h 
b/MdePkg/Include/IndustryStandard/SmBios.h
index f5c29bcbd0c8..6a8fa1b39d17 100644
--- a/MdePkg/Include/IndustryStandard/SmBios.h
+++ b/MdePkg/Include/IndustryStandard/SmBios.h
@@ -611,6 +611,7 @@ typedef enum {
   ProcessorFamilyAmdOpteronX2000Series  = 0x68,
   ProcessorFamilyAmdOpteronASeries  = 0x69,
   ProcessorFamilyAmdOpteronX3000Series  = 0x6A,
+  ProcessorFamilyAmdZen = 0x6B,
   ProcessorFamilyHobbit = 0x70,
   ProcessorFamilyCrusoeTM5000   = 0x78,
   ProcessorFamilyCrusoeTM3000   = 0x79,
@@ -804,7 +805,8 @@ typedef enum {
   ProcessorUpgradeSocketBGA1440   = 0x34,
   ProcessorUpgradeSocketBGA1515   = 0x35,
   ProcessorUpgradeSocketLGA3647_1 = 0x36,
-  ProcessorUpgradeSocketSP3   = 0x37
+  ProcessorUpgradeSocketSP3   = 0x37,
+  ProcessorUpgradeSocketSP3r2 = 0x38
 } PROCESSOR_UPGRADE;
 
 ///
@@ -2386,6 +2388,25 @@ typedef struct {
 } SMBIOS_TABLE_TYPE41;
 
 ///
+/// Management Controller Host Interface - Interface Types.
+/// 00h �C 3Fh: MCTP Host Interfaces
+///
+typedef enum{
+  MCHostInterfaceTypeNetworkHostInterface   = 0x40,
+  MCHostInterfaceTypeOemDefined = 0xF0
+} MC_HOST_INTERFACE_TYPE;
+
+///
+/// Management Controller Host Interface - Protocol Types.
+///
+typedef enum{
+  MCHostInterfaceProtocolTypeIPMI   = 0x02,
+  MCHostInterfaceProtocolTypeMCTP   = 0x03,
+  MCHostInterfaceProtocolTypeRedfishOverIP  = 0x04,
+  MCHostInterfaceProtocolTypeOemDefined = 0xF0
+} MC_HOST_INTERFACE_PROTOCOL_TYPE;
+
+///
 /// Management Controller Host Interface (Type 42).
 ///
 /// The information in this structure defines the attributes of a Management
@@ -2404,7 +2425,7 @@ typedef struct {
 ///
 typedef struct {
   SMBIOS_STRUCTURE  Hdr;
-  UINT8 InterfaceType;
+  UINT8 InterfaceType;  ///< The 
enumeration value from MC_HOST_INTERFACE_TYPE
   UINT8 MCHostInterfaceData[1]; ///< This field 
has a minimum of four bytes
 } SMBIOS_TABLE_TYPE42;
 
-- 
2.7.0.windows.1

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


[edk2] [PATCH 0/3] Add SMBIOS spec 3.1.1 support

2017-01-22 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=349

These patches are to add support for below items.
Processor Information (Type 4):
- add socket SP3r2
- add AMD Zen Processor Family
Management Controller Host Interface (Type 42):
- include Host Interface Type and Protocol Identifier enumerations

Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Feng Tian 
Cc: Ruiyu Ni 
Cc: Jaben Carsey 

Star Zeng (3):
  MdePkg: Add definitions for SMBIOS spec 3.1.1
  MdeModulePkg: Update PcdSmbiosDocRev to 0x1 for SMBIOS spec 3.1.1
  ShellPkg SmbiosView: Add decoding of SMBIOS spec 3.1.1

 MdeModulePkg/MdeModulePkg.dec  |  2 +-
 MdePkg/Include/IndustryStandard/SmBios.h   | 25 +--
 .../SmbiosView/PrintInfo.c |  6 +++-
 .../SmbiosView/QueryTable.c| 37 ++
 .../SmbiosView/QueryTable.h| 14 +++-
 .../SmbiosView/SmbiosViewStrings.uni   |  3 +-
 6 files changed, 81 insertions(+), 6 deletions(-)

-- 
2.7.0.windows.1

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


[edk2] [PATCH 2/3] MdeModulePkg: Update PcdSmbiosDocRev to 0x1 for SMBIOS spec 3.1.1

2017-01-22 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=349

Cc: Feng Tian 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/MdeModulePkg.dec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 7e67ddccbb85..273cd7e1716f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1519,7 +1519,7 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, 
PcdsDynamicEx]
 
   ## 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|0x0|UINT8|0x0001006A
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x1|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 3/3] ShellPkg SmbiosView: Add decoding of SMBIOS spec 3.1.1

2017-01-22 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=349

Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../SmbiosView/PrintInfo.c |  6 +++-
 .../SmbiosView/QueryTable.c| 37 ++
 .../SmbiosView/QueryTable.h| 14 +++-
 .../SmbiosView/SmbiosViewStrings.uni   |  3 +-
 4 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index ecb8e2492453..1d6002b92593 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -1106,7 +1106,7 @@ SmbiosPrintStructure (
   // Management Controller Host Interface (Type 42)
   //
   case 42:
-PRINT_STRUCT_VALUE_H (Struct, Type42, InterfaceType);
+DisplayMCHostInterfaceType (Struct->Type42->InterfaceType, Option);
 break;
 
   //
@@ -1818,6 +1818,10 @@ DisplayProcessorFamily (
 Print (L"AMD Opteron(TM) X3000 Series APU\n");
 break;
 
+  case 0x6B:
+Print (L"AMD Zen Processor Family\n");
+break;
+
   case 0x70:
 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_HOBBIT_FAMILY), gShellDebug1HiiHandle);
 break;
diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
index 4a06c12e3b2b..282ba584c8c9 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
@@ -575,6 +575,10 @@ TABLE_ITEM  ProcessorUpgradeTable[] = {
   {
 0x37,
 L"Socket SP3"
+  },
+  {
+0x38,
+L"Socket SP3r2"
   }
 };
 
@@ -3156,6 +3160,22 @@ TABLE_ITEM  IPMIDIBMCInterfaceTypeTable[] = {
   },
 };
 
+TABLE_ITEM  MCHostInterfaceTypeTable[] = {
+  {
+0x3F00,
+L" MCTP Host Interface "
+  },
+  {
+0x40,
+L" Network Host Interface "
+  },
+  {
+0xF0,
+L" OEM defined "
+  },
+};
+
+
 TABLE_ITEM  StructureTypeInfoTable[] = {
   {
 0,
@@ -4525,6 +4545,23 @@ DisplayIPMIDIBMCInterfaceType (
 }
 
 /**
+  Display Management Controller Host Interface (Type 42) information.
+
+  @param[in] Key  The key of the structure.
+  @param[in] Option   The optional information.
+**/
+VOID
+DisplayMCHostInterfaceType (
+  IN UINT8 Key,
+  IN UINT8 Option
+  )
+{
+  ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_QUERYTABLE_MC_HOST_INTERFACE_TYPE), gShellDebug1HiiHandle);
+  PRINT_INFO_OPTION (Key, Option);
+  PRINT_TABLE_ITEM (MCHostInterfaceTypeTable, Key);
+}
+
+/**
   Display the structure type information.
 
   @param[in] Key  The key of the structure.
diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h
index 9cae7094fb19..bd9e6898d40a 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h
@@ -2,7 +2,7 @@
   Build a table, each item is (key, info) pair.
   and give a interface of query a string out of a table.
 
-  Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.
+  Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -779,4 +779,16 @@ DisplayIPMIDIBMCInterfaceType (
   IN UINT8 Option
   );
 
+/**
+  Display Management Controller Host Interface (Type 42) information.
+
+  @param[in] Key  The key of the structure.
+  @param[in] Option   The optional information.
+**/
+VOID
+DisplayMCHostInterfaceType (
+  IN UINT8 Key,
+  IN UINT8 Option
+  );
+
 #endif
diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni
index b9032df076d2..7d694536dbcd 100644
--- 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni
+++ 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni
@@ -1,6 +1,6 @@
 // /**
 //
-// Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
+// Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
 // (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.
 // (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
 // This program and the accompanying materials
@@ -444,6 +444,7 @@
 #string STR_SMBIOSVIEW_QUERYTABLE_MANAGEMENT_DEV_ADDR_TYPE  #language 
en-US "Manag

[edk2] [PATCH] SecurityPkg HashLibRouter: Avoid incorrect PcdTcg2HashAlgorithmBitmap

2017-01-24 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=244

Currently, when software HashLib (HashLibBaseCryptoRouter) and related
HashInstanceLib instances are used, PcdTcg2HashAlgorithmBitmap is
expected to be configured to 0 in platform dsc.
But PcdTcg2HashAlgorithmBitmap has default value 0x in
SecurityPkg.dec, and some platforms forget to configure it to 0 or
still configure it to 0x in platform dsc, that will make final
PcdTcg2HashAlgorithmBitmap value incorrect.

This patch is to add CONSTRUCTOR in HashLib (HashLibBaseCryptoRouter)
and PcdTcg2HashAlgorithmBitmap will be set to 0 in the CONSTRUCTOR.

Current HASH_LIB_PEI_ROUTER_GUID HOB created in
HashLibBaseCryptoRouterPei is shared between modules that links
HashLibBaseCryptoRouterPei.
To avoid mutual interference, separated HASH_LIB_PEI_ROUTER_GUID HOBs
with gEfiCallerIdGuid Identifier will be created for those modules.

This patch is also to add check in HashLib (HashLibBaseCryptoRouter)
for the mismatch of supported HashMask between modules that may link
different HashInstanceLib instances, warning will be reported if
mismatch is found.

Cc: Yao Jiewen 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../HashLibBaseCryptoRouterDxe.c   |  80 -
 .../HashLibBaseCryptoRouterDxe.inf |   3 +-
 .../HashLibBaseCryptoRouterPei.c   | 190 +
 .../HashLibBaseCryptoRouterPei.inf |   8 +-
 SecurityPkg/SecurityPkg.dec|   4 +
 SecurityPkg/SecurityPkg.uni|   8 +-
 6 files changed, 254 insertions(+), 39 deletions(-)

diff --git 
a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.c 
b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.c
index 3250c3a01a0c..4775cfee2d7a 100644
--- a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.c
+++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.c
@@ -3,7 +3,7 @@
   hash handler registerd, such as SHA1, SHA256.
   Platform can use PcdTpm2HashMask to mask some hash engines.
 
-Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved. 
+Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved. 
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -28,6 +28,30 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 HASH_INTERFACE   mHashInterface[HASH_COUNT] = {{{0}, NULL, NULL, NULL}};
 UINTNmHashInterfaceCount = 0;
 
+UINT32   mSupportedHashMaskLast = 0;
+UINT32   mSupportedHashMaskCurrent = 0;
+
+/**
+  Check mismatch of supported HashMask between modules
+  that may link different HashInstanceLib instances.
+
+**/
+VOID
+CheckSupportedHashMaskMismatch (
+  VOID
+  )
+{
+  if (mSupportedHashMaskCurrent != mSupportedHashMaskLast) {
+DEBUG ((
+  DEBUG_WARN,
+  "WARNING: There is mismatch of supported HashMask (0x%x - 0x%x) between 
modules\n",
+  mSupportedHashMaskCurrent,
+  mSupportedHashMaskLast
+  ));
+DEBUG ((DEBUG_WARN, "that are linking different HashInstanceLib 
instances!\n"));
+  }
+}
+
 /**
   Start hash sequence.
 
@@ -50,6 +74,8 @@ HashStart (
 return EFI_UNSUPPORTED;
   }
 
+  CheckSupportedHashMaskMismatch ();
+
   HashCtx = AllocatePool (sizeof(*HashCtx) * mHashInterfaceCount);
   ASSERT (HashCtx != NULL);
 
@@ -90,6 +116,8 @@ HashUpdate (
 return EFI_UNSUPPORTED;
   }
 
+  CheckSupportedHashMaskMismatch ();
+
   HashCtx = (HASH_HANDLE *)HashHandle;
 
   for (Index = 0; Index < mHashInterfaceCount; Index++) {
@@ -133,6 +161,8 @@ HashCompleteAndExtend (
 return EFI_UNSUPPORTED;
   }
 
+  CheckSupportedHashMaskMismatch ();
+
   HashCtx = (HASH_HANDLE *)HashHandle;
   ZeroMem (DigestList, sizeof(*DigestList));
 
@@ -180,6 +210,8 @@ HashAndExtend (
 return EFI_UNSUPPORTED;
   }
 
+  CheckSupportedHashMaskMismatch ();
+
   HashStart (&HashHandle);
   HashUpdate (HashHandle, DataToHash, DataToHashLen);
   Status = HashCompleteAndExtend (HashHandle, PcrIndex, NULL, 0, DigestList);
@@ -204,7 +236,6 @@ RegisterHashInterfaceLib (
 {
   UINTN  Index;
   UINT32 HashMask;
-  UINT32 BiosSupportedHashMask;
   EFI_STATUS Status;
 
   //
@@ -218,21 +249,58 @@ RegisterHashInterfaceLib (
   if (mHashInterfaceCount >= sizeof(mHashInterface)/sizeof(mHashInterface[0])) 
{
 return EFI_OUT_OF_RESOURCES;
   }
-  BiosSupportedHashMask = PcdGet32 (PcdTcg2HashAlgorithmBitmap);
-  Status = PcdSet32S (PcdTcg2HashAlgorithmBitmap, BiosSupportedHashMask | 
HashMask);
-  ASSERT_EFI_ERROR (Status);
 
   //
   // Check duplication
   //
   for (Index = 0; Index < mHashInterfaceCount; Index++) {

[edk2] [PATCH] ShellPkg SmbiosView: Eliminate trailing " | " in PrintBitsInfo()

2017-02-09 Thread Star Zeng
Current PrintBitsInfo() will always print an additional trailing
" | " for the bit flags, for example,

Base Board Feature Flags: Hosting board |  Replaceable |

Th patch is to eliminate trailing " | " in PrintBitsInfo(), then
the output will be like below

Base Board Feature Flags: Hosting board |  Replaceable

Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
index 282ba584c8c9..02d9ab1f57b3 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
@@ -3449,19 +3449,24 @@ PrintBitsInfo (
 
   UINTN   Index;
   UINT32  Value;
-  BOOLEAN NoInfo;
+  BOOLEAN FirstInfo;
 
-  NoInfo  = TRUE;
+  FirstInfo = TRUE;
   Value   = Bits;
   //
   // query the table and print information
   //
   for (Index = 0; Index < Number; Index++) {
 if (BIT (Value, Table[Index].Key) != 0) {
+  if (!FirstInfo) {
+//
+// If it is not first info, print the separator first.
+//
+Print (L" | ");
+  }
   Print (Table[Index].Info);
-  Print (L" | ");
 
-  NoInfo = FALSE;
+  FirstInfo = FALSE;
   //
   // clear the bit, for reserved bits test
   //
@@ -3469,7 +3474,10 @@ PrintBitsInfo (
 }
   }
 
-  if (NoInfo) {
+  //
+  // There is no any info if FirstInfo is still TRUE.
+  //
+  if (FirstInfo) {
 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_QUERYTABLE_NO_INFO), gShellDebug1HiiHandle);
   }
 
-- 
2.7.0.windows.1

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


[edk2] [PATCH] ShellPkg SmbiosView: Correct some outputs for Type 0/3/10

2017-02-09 Thread Star Zeng
Type 0: Update "EDD Enhanced Disk Driver)..." to
"EDD (Enhanced Disk Driver)..." for
STR_SMBIOSVIEW_PRINTINFO_EDD_ENHANCED_DRIVER

Type 3: Use L"  Laptop" instead of L"  LapTop" in
SystemEnclosureTypeTable to match SMBIOS spec.

Type 10: The BIT7 of Device Type is representing the
status of device whether it is enabled or disabled.
But current code is not considering the BIT7 and will
print "Undefined Value" for enabled device. Type 41
has same definition of Device Type, the code is
correct and will be applied to Type 10 by this patch.

Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c | 3 ++-
 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c| 2 +-
 .../UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni| 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index 1d6002b92593..50d15ef1758e 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -570,7 +570,8 @@ SmbiosPrintStructure (
   UINTN NumOfDevice;
   NumOfDevice = (Struct->Type10->Hdr.Length - sizeof (SMBIOS_STRUCTURE)) / 
(2 * sizeof (UINT8));
   for (Index = 0; Index < NumOfDevice; Index++) {
-DisplayOnboardDeviceTypes (Struct->Type10->Device[Index].DeviceType, 
Option);
+ShellPrintEx(-1,-1,(((Struct->Type10->Device[Index].DeviceType) & 
0x80) != 0) ? L"Device Enabled\n": L"Device Disabled\n");
+DisplayOnboardDeviceTypes ((Struct->Type10->Device[Index].DeviceType) 
& 0x7F, Option);
 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_DESC_STRING), gShellDebug1HiiHandle);
 ShellPrintEx(-1,-1,L"%a\n",LibGetSmbiosString (Struct, 
Struct->Type10->Device[Index].DescriptionString));
   }
diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
index 02d9ab1f57b3..afea429b7aa3 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
@@ -166,7 +166,7 @@ TABLE_ITEM  SystemEnclosureTypeTable[] = {
   },
   {
 0x09,
-L"  LapTop"
+L"  Laptop"
   },
   {
 0x0A,
diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni
index 7d694536dbcd..2cd682630557 100644
--- 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni
+++ 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni
@@ -133,7 +133,7 @@
 #string STR_SMBIOSVIEW_PRINTINFO_SELECTED_BOOT_SUPPORTED#language 
en-US "Selectable Boot is supported\r\n"
 #string STR_SMBIOSVIEW_PRINTINFO_BIOS_ROM_SOCKETED  #language 
en-US "BIOS ROM is socketed\r\n"
 #string STR_SMBIOSVIEW_PRINTINFO_BOOT_FROM_PC_CARD  #language 
en-US "Boot From PC Card(PCMCIA)is supported\r\n"
-#string STR_SMBIOSVIEW_PRINTINFO_EDD_ENHANCED_DRIVER#language 
en-US "EDD Enhanced Disk Driver) Specification is supported\r\n"
+#string STR_SMBIOSVIEW_PRINTINFO_EDD_ENHANCED_DRIVER#language 
en-US "EDD (Enhanced Disk Driver) Specification is supported\r\n"
 #string STR_SMBIOSVIEW_PRINTINFO_JAPANESE_FLOPPY_NEC#language 
en-US "Int 13h - Japanese Floppy for NEC 9800 1.2mb (3.5\",1k Bytes/Sector, 360 
RPM) is supported\r\n"
 #string STR_SMBIOSVIEW_PRINTINFO_JAPANESE_FLOPPY_TOSHIBA#language 
en-US "Int 13h - Japanese Floppy for Toshiba 1.2mn (3.5\", 360 RPM) is 
supported\r\n"
 #string STR_SMBIOSVIEW_PRINTINFO_FLOPPY_SERVICES_SUPPORTED  #language 
en-US "Int 13h - 5.25\"/360KB Floppy Services are supported\r\n"
-- 
2.7.0.windows.1

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


[edk2] [PATCH] MdePkg ACPI: Incorrect definition name for ACPI IORT Table signature

2017-02-09 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=363

The definition name for ACPI IO Remapping Table signature is incorrect
in Acpi60.h and Acpi61.h as below:

The name should be changed to
EFI_ACPI_6_0_IO_REMAPPING_TABLE_SIGNATURE
EFI_ACPI_6_1_IO_REMAPPING_TABLE_SIGNATURE

The comments
///
/// "IORT" Interrupt Source Override
///
will be also changed to
///
/// "IORT" I/O Remapping Table
///

Cc: Alexei Fedorov 
Cc: Jiewen Yao 
Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdePkg/Include/IndustryStandard/Acpi60.h | 6 +++---
 MdePkg/Include/IndustryStandard/Acpi61.h | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/Acpi60.h 
b/MdePkg/Include/IndustryStandard/Acpi60.h
index ab798e9cf4c1..6183d8a9bd6c 100644
--- a/MdePkg/Include/IndustryStandard/Acpi60.h
+++ b/MdePkg/Include/IndustryStandard/Acpi60.h
@@ -1,7 +1,7 @@
 /** @file   
   ACPI 6.0 definitions from the ACPI Specification Revision 6.0 Errata A 
January, 2016.
 
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
   This program and the accompanying materials  
   are licensed and made available under the terms and conditions of the BSD 
License 
@@ -2252,9 +2252,9 @@ typedef struct {
 #define EFI_ACPI_6_0_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE  SIGNATURE_32('i', 
'B', 'F', 'T')
 
 ///
-/// "IORT" Interrupt Source Override
+/// "IORT" I/O Remapping Table
 ///
-#define EFI_ACPI_6_0_INTERRUPT_SOURCE_OVERRIDE_SIGNATURE  SIGNATURE_32('I', 
'O', 'R', 'T')
+#define EFI_ACPI_6_0_IO_REMAPPING_TABLE_SIGNATURE  SIGNATURE_32('I', 'O', 'R', 
'T')
 
 ///
 /// "IVRS" I/O Virtualization Reporting Structure
diff --git a/MdePkg/Include/IndustryStandard/Acpi61.h 
b/MdePkg/Include/IndustryStandard/Acpi61.h
index dc3153b7e7c8..0fac9a80694d 100644
--- a/MdePkg/Include/IndustryStandard/Acpi61.h
+++ b/MdePkg/Include/IndustryStandard/Acpi61.h
@@ -1,7 +1,7 @@
 /** @file   
   ACPI 6.1 definitions from the ACPI Specification Revision 6.1 January, 2016.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
   This program and the accompanying materials  
   are licensed and made available under the terms and conditions of the BSD 
License 
@@ -2284,9 +2284,9 @@ typedef struct {
 #define EFI_ACPI_6_1_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE  SIGNATURE_32('i', 
'B', 'F', 'T')
 
 ///
-/// "IORT" Interrupt Source Override
+/// "IORT" I/O Remapping Table
 ///
-#define EFI_ACPI_6_1_INTERRUPT_SOURCE_OVERRIDE_SIGNATURE  SIGNATURE_32('I', 
'O', 'R', 'T')
+#define EFI_ACPI_6_1_IO_REMAPPING_TABLE_SIGNATURE  SIGNATURE_32('I', 'O', 'R', 
'T')
 
 ///
 /// "IVRS" I/O Virtualization Reporting Structure
-- 
2.7.0.windows.1

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


[edk2] [PATCH V2] MdePkg ACPI: Incorrect definition name for ACPI IORT Table signature

2017-02-09 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=363

The definition name for ACPI IO Remapping Table signature is incorrect
in Acpi60.h and Acpi61.h as below:
EFI_ACPI_6_0_INTERRUPT_SOURCE_OVERRIDE_SIGNATURE
EFI_ACPI_6_1_INTERRUPT_SOURCE_OVERRIDE_SIGNATURE

The name should be changed to
EFI_ACPI_6_0_IO_REMAPPING_TABLE_SIGNATURE
EFI_ACPI_6_1_IO_REMAPPING_TABLE_SIGNATURE

The comments
///
/// "IORT" Interrupt Source Override
///
will be also changed to
///
/// "IORT" I/O Remapping Table
///

V2: Minor commit log update.

Cc: Alexei Fedorov 
Cc: Jiewen Yao 
Cc: Liming Gao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdePkg/Include/IndustryStandard/Acpi60.h | 6 +++---
 MdePkg/Include/IndustryStandard/Acpi61.h | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/Acpi60.h 
b/MdePkg/Include/IndustryStandard/Acpi60.h
index ab798e9cf4c1..6183d8a9bd6c 100644
--- a/MdePkg/Include/IndustryStandard/Acpi60.h
+++ b/MdePkg/Include/IndustryStandard/Acpi60.h
@@ -1,7 +1,7 @@
 /** @file   
   ACPI 6.0 definitions from the ACPI Specification Revision 6.0 Errata A 
January, 2016.
 
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
   This program and the accompanying materials  
   are licensed and made available under the terms and conditions of the BSD 
License 
@@ -2252,9 +2252,9 @@ typedef struct {
 #define EFI_ACPI_6_0_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE  SIGNATURE_32('i', 
'B', 'F', 'T')
 
 ///
-/// "IORT" Interrupt Source Override
+/// "IORT" I/O Remapping Table
 ///
-#define EFI_ACPI_6_0_INTERRUPT_SOURCE_OVERRIDE_SIGNATURE  SIGNATURE_32('I', 
'O', 'R', 'T')
+#define EFI_ACPI_6_0_IO_REMAPPING_TABLE_SIGNATURE  SIGNATURE_32('I', 'O', 'R', 
'T')
 
 ///
 /// "IVRS" I/O Virtualization Reporting Structure
diff --git a/MdePkg/Include/IndustryStandard/Acpi61.h 
b/MdePkg/Include/IndustryStandard/Acpi61.h
index dc3153b7e7c8..0fac9a80694d 100644
--- a/MdePkg/Include/IndustryStandard/Acpi61.h
+++ b/MdePkg/Include/IndustryStandard/Acpi61.h
@@ -1,7 +1,7 @@
 /** @file   
   ACPI 6.1 definitions from the ACPI Specification Revision 6.1 January, 2016.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
   This program and the accompanying materials  
   are licensed and made available under the terms and conditions of the BSD 
License 
@@ -2284,9 +2284,9 @@ typedef struct {
 #define EFI_ACPI_6_1_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE  SIGNATURE_32('i', 
'B', 'F', 'T')
 
 ///
-/// "IORT" Interrupt Source Override
+/// "IORT" I/O Remapping Table
 ///
-#define EFI_ACPI_6_1_INTERRUPT_SOURCE_OVERRIDE_SIGNATURE  SIGNATURE_32('I', 
'O', 'R', 'T')
+#define EFI_ACPI_6_1_IO_REMAPPING_TABLE_SIGNATURE  SIGNATURE_32('I', 'O', 'R', 
'T')
 
 ///
 /// "IVRS" I/O Virtualization Reporting Structure
-- 
2.7.0.windows.1

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


[edk2] [PATCH] Security Tcg2Smm: Add missing gEfiTcg2ProtocolGuid dependency

2017-02-19 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=380

gEfiTcgProtocolGuid dependency was added in TcgSmm.
But gEfiTcg2ProtocolGuid dependency is missing in Tcg2Smm.

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf 
b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf
index 70184740c49d..c4efa2a188ef 100644
--- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf
+++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf
@@ -79,7 +79,8 @@ [Pcd]
 [Depex]
   gEfiAcpiTableProtocolGuid AND
   gEfiSmmSwDispatch2ProtocolGuid AND
-  gEfiSmmVariableProtocolGuid
+  gEfiSmmVariableProtocolGuid AND
+  gEfiTcg2ProtocolGuid
 
 [UserExtensions.TianoCore."ExtraFiles"]
   Tcg2SmmExtra.uni
-- 
2.7.0.windows.1

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


[edk2] [PATCH] MdeModulePkg SmmSmiHandlerProfileLib: Fix GCC build failure

2017-02-23 Thread Star Zeng
Cc: Feng Tian 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c 
b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c
index 0191cdebbf12..2edc71be3efb 100644
--- a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c
+++ b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c
@@ -99,7 +99,7 @@ SmmSmiHandlerProfileLibConstructor (
   gSmst->SmmLocateProtocol (
&gSmiHandlerProfileGuid,
NULL,
-   &mSmiHandlerProfile
+   (VOID **) &mSmiHandlerProfile
);
   return EFI_SUCCESS;
 }
-- 
2.7.0.windows.1

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


[edk2] [PATCH 0/3] DP: Fix GCC build failure

2017-02-23 Thread Star Zeng
Fix GCC build failure caused by "Remove TimerLib dependency from DP" patch 
series.

Star Zeng (3):
  MdeModulePkg PerformanceLib: Fix GCC build failure caused by cfb0aba
  PerformancePkg Dp_App: Fixed GCC build failure caused by 1393510
  ShellPkg UefiDpLib: Fixed GCC build failure caused by ef22403

 MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 2 +-
 MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c | 4 ++--
 PerformancePkg/Dp_App/Dp.c | 2 +-
 ShellPkg/Library/UefiDpLib/Dp.c| 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

-- 
2.7.0.windows.1

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


[edk2] [PATCH 2/3] PerformancePkg Dp_App: Fixed GCC build failure caused by 1393510

2017-02-23 Thread Star Zeng
Cc: Michael Kinney 
Cc: Liming Gao 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 PerformancePkg/Dp_App/Dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PerformancePkg/Dp_App/Dp.c b/PerformancePkg/Dp_App/Dp.c
index 389f3681e9f9..e2cb862364ab 100644
--- a/PerformancePkg/Dp_App/Dp.c
+++ b/PerformancePkg/Dp_App/Dp.c
@@ -399,7 +399,7 @@ InitializeDp (
   //StartCount = Value loaded into the counter when it starts counting
   //  EndCount = Value counter counts to before it needs to be reset
   //
-  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, 
&PerformanceProperty);
+  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, 
(VOID **) &PerformanceProperty);
   if (EFI_ERROR (Status)) {
 PrintToken (STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND));
 goto Done;
-- 
2.7.0.windows.1

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


[edk2] [PATCH 3/3] ShellPkg UefiDpLib: Fixed GCC build failure caused by ef22403

2017-02-23 Thread Star Zeng
Cc: Michael Kinney 
Cc: Liming Gao 
Cc: Jaben Carsey 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 ShellPkg/Library/UefiDpLib/Dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiDpLib/Dp.c b/ShellPkg/Library/UefiDpLib/Dp.c
index 444c136ab188..33f69a0c145a 100644
--- a/ShellPkg/Library/UefiDpLib/Dp.c
+++ b/ShellPkg/Library/UefiDpLib/Dp.c
@@ -271,7 +271,7 @@ ShellCommandRunDp (
   //StartCount = Value loaded into the counter when it starts counting
   //  EndCount = Value counter counts to before it needs to be reset
   //
-  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, 
&PerformanceProperty);
+  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID 
**) &PerformanceProperty);
   if (EFI_ERROR (Status)) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), 
gDpHiiHandle);
 goto Done;
-- 
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/3] MdeModulePkg PerformanceLib: Fix GCC build failure caused by cfb0aba

2017-02-23 Thread Star Zeng
Cc: Ard Biesheuvel 
Cc: Liming Gao 
Cc: Feng Tian 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 2 +-
 MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c 
b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index 1564514518d3..51f488af6c14 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -535,7 +535,7 @@ DxeCorePerformanceLibConstructor (
 
   InternalGetPeiPerformance ();
 
-  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, 
&PerformanceProperty);
+  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID 
**) &PerformanceProperty);
   if (EFI_ERROR (Status)) {
 //
 // Install configuration table for performance property.
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c 
b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
index a03a8c8dcc46..cd1f1a5d5f66 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
@@ -16,7 +16,7 @@
 
  SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted 
input and do basic validation.
 
-Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -729,7 +729,7 @@ InitializeSmmCorePerformanceLib (
   Status = gSmst->SmiHandlerRegister (SmmPerformanceHandlerEx, 
&gSmmPerformanceExProtocolGuid, &Handle);
   ASSERT_EFI_ERROR (Status);
 
-  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, 
&PerformanceProperty);
+  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID 
**) &PerformanceProperty);
   if (EFI_ERROR (Status)) {
 //
 // Install configuration table for performance property.
-- 
2.7.0.windows.1

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


[edk2] [PATCH 0/2] DP: Link DxeSmmPerformanceLib to make DP command generic

2017-02-28 Thread Star Zeng
Current PerformancePkg is linking DxePerformanceLib
that could only dump PEI and DXE performance log.
Current ShellPkg is linking BasePerformanceLibNull.

We could link DxeSmmPerformanceLib to make DP command
built from PerformancePkg and ShellPkg generic.

Star Zeng (2):
  PerformancePkg: Link DxeSmmPerformanceLib to make DP command generic
  ShellPkg: Link DxeSmmPerformanceLib to make DP command generic

 PerformancePkg/PerformancePkg.dsc | 21 ++---
 ShellPkg/ShellPkg.dsc |  2 +-
 2 files changed, 3 insertions(+), 20 deletions(-)

-- 
2.8.1.windows.1

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


[edk2] [PATCH 1/2] PerformancePkg: Link DxeSmmPerformanceLib to make DP command generic

2017-02-28 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=412

Also remove the unreferenced TimerLib mapping.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 PerformancePkg/PerformancePkg.dsc | 21 ++---
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/PerformancePkg/PerformancePkg.dsc 
b/PerformancePkg/PerformancePkg.dsc
index 4278cbd09271..95cc905cbb66 100644
--- a/PerformancePkg/PerformancePkg.dsc
+++ b/PerformancePkg/PerformancePkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 # Build description file to generate Shell DP application.
 #
-# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
 # which accompanies this distribution.  The full text of the license may be 
found at
@@ -45,7 +45,7 @@ [LibraryClasses]
   
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
   HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
   
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
-  PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
+  
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
   SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
@@ -56,23 +56,6 @@ [LibraryClasses]
   PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
   DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
 
-[LibraryClasses.IA32, LibraryClasses.X64]
-  # This library instance mapping needs adjusting based on platform.
-  # The TimerLib instance must match the TimerLib the platform was built with.
-  # If the platform was built with more than one TimerLib type, then this 
utility
-  # will produce invalid results for any measurements done with a TimerLib 
instance
-  # that is different than the one below.
-  #
-  # TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
-  TimerLib|PerformancePkg/Library/TscTimerLib/DxeTscTimerLib.inf
-
-[LibraryClasses.IPF]
-  PalLib|MdePkg/Library/UefiPalLib/UefiPalLib.inf
-  TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
-
-[LibraryClasses.EBC]
-  TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
-
 [Components.IA32, Components.X64]
   PerformancePkg/Library/TscTimerLib/DxeTscTimerLib.inf
   PerformancePkg/Library/TscTimerLib/PeiTscTimerLib.inf
-- 
2.8.1.windows.1

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


[edk2] [PATCH 2/2] ShellPkg: Link DxeSmmPerformanceLib to make DP command generic

2017-02-28 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=412

Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 ShellPkg/ShellPkg.dsc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
index a87428ad6f76..4126e846cf71 100644
--- a/ShellPkg/ShellPkg.dsc
+++ b/ShellPkg/ShellPkg.dsc
@@ -107,7 +107,7 @@ [Components]
 
   ShellPkg/Library/UefiDpLib/UefiDpLib.inf {
 
-  
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
+  
PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
   DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
   }
 
-- 
2.8.1.windows.1

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


[edk2] [PATCH] MdeModulePkg DxeCore: Remove unreferenced symbol for memory profile

2017-03-14 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=370

Use GLOBAL_REMOVE_IF_UNREFERENCED for some memory profile global variables,
then their symbols could be removed when memory profile is disabled.

Cc: Jiewen Yao 
Cc: Feng Tian 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c 
b/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c
index b67a17c86dff..a91a719b4de5 100644
--- a/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c
+++ b/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c
@@ -63,11 +63,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED MEMORY_PROFILE_CONTEXT_DATA 
mMemoryProfileContext
 };
 GLOBAL_REMOVE_IF_UNREFERENCED MEMORY_PROFILE_CONTEXT_DATA 
*mMemoryProfileContextPtr = NULL;
 
-EFI_LOCK mMemoryProfileLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
-BOOLEAN mMemoryProfileGettingStatus = FALSE;
-BOOLEAN mMemoryProfileRecordingEnable = MEMORY_PROFILE_RECORDING_DISABLE;
-EFI_DEVICE_PATH_PROTOCOL *mMemoryProfileDriverPath;
-UINTNmMemoryProfileDriverPathSize;
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_LOCK mMemoryProfileLock = 
EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
+GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mMemoryProfileGettingStatus = FALSE;
+GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mMemoryProfileRecordingEnable = 
MEMORY_PROFILE_RECORDING_DISABLE;
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_PROTOCOL 
*mMemoryProfileDriverPath;
+GLOBAL_REMOVE_IF_UNREFERENCED UINTN
mMemoryProfileDriverPathSize;
 
 /**
   Get memory profile data.
@@ -209,7 +209,7 @@ ProfileProtocolRecord (
   IN CHAR8  *ActionString OPTIONAL
   );
 
-EDKII_MEMORY_PROFILE_PROTOCOL mProfileProtocol = {
+GLOBAL_REMOVE_IF_UNREFERENCED EDKII_MEMORY_PROFILE_PROTOCOL mProfileProtocol = 
{
   ProfileProtocolGetData,
   ProfileProtocolRegisterImage,
   ProfileProtocolUnregisterImage,
-- 
2.7.0.windows.1

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


[edk2] [PATCH] MdeModulePkg PiSmmCore: Remove unreferenced symbol for SMRAM profile

2017-03-14 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=370

Use GLOBAL_REMOVE_IF_UNREFERENCED for some SMRAM profile global variables,
then their symbols could be removed when SMRAM profile is disabled.

Cc: Jiewen Yao 
Cc: Feng Tian 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c 
b/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
index dda9f12a7dcd..410e0836fd16 100644
--- a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
+++ b/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
@@ -1,7 +1,7 @@
 /** @file
   Support routines for SMRAM profile.
 
-  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -77,11 +77,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED MEMORY_PROFILE_CONTEXT_DATA 
mSmramProfileContext =
 };
 GLOBAL_REMOVE_IF_UNREFERENCED MEMORY_PROFILE_CONTEXT_DATA 
*mSmramProfileContextPtr = NULL;
 
-BOOLEAN mSmramReadyToLock;
-BOOLEAN mSmramProfileGettingStatus = FALSE;
-BOOLEAN mSmramProfileRecordingEnable = MEMORY_PROFILE_RECORDING_DISABLE;
-EFI_DEVICE_PATH_PROTOCOL *mSmramProfileDriverPath;
-UINTNmSmramProfileDriverPathSize;
+GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSmramReadyToLock;
+GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSmramProfileGettingStatus = FALSE;
+GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSmramProfileRecordingEnable = 
MEMORY_PROFILE_RECORDING_DISABLE;
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_PROTOCOL 
*mSmramProfileDriverPath;
+GLOBAL_REMOVE_IF_UNREFERENCED UINTN
mSmramProfileDriverPathSize;
 
 /**
   Dump SMRAM infromation.
@@ -232,7 +232,7 @@ SmramProfileProtocolRecord (
   IN CHAR8  *ActionString OPTIONAL
   );
 
-EDKII_SMM_MEMORY_PROFILE_PROTOCOL mSmmProfileProtocol = {
+GLOBAL_REMOVE_IF_UNREFERENCED EDKII_SMM_MEMORY_PROFILE_PROTOCOL 
mSmmProfileProtocol = {
   SmramProfileProtocolGetData,
   SmramProfileProtocolRegisterImage,
   SmramProfileProtocolUnregisterImage,
@@ -2630,7 +2630,7 @@ typedef struct {
   CHAR8 *String;
 } ACTION_STRING;
 
-ACTION_STRING mExtActionString[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED ACTION_STRING mExtActionString[] = {
   {MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES,
"Lib:AllocatePages"},
   {MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES,
"Lib:AllocateRuntimePages"},
   {MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_PAGES,   
"Lib:AllocateReservedPages"},
@@ -2654,8 +2654,6 @@ ACTION_STRING mExtActionString[] = {
   {MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RESERVED_POOL,  
"Lib:ReallocateReservedPool"},
 };
 
-GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 mUserDefinedActionString[] = 
{"UserDefined-0x8000"};
-
 typedef struct {
   EFI_MEMORY_TYPE   MemoryType;
   CHAR8 *MemoryTypeStr;
-- 
2.7.0.windows.1

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


[edk2] [PATCH] MdeModulePkg PCD: Allow SkuId to be changed only once

2017-03-14 Thread Star Zeng
Current PI spec has no clear description about whether the
SkuId could be changed multiple times or not during one boot.

If the SkuId could be changed multiple times during one boot,
different modules may get inconsistent PCD values.
And DynamicHii PCD maps to UEFI variable, once one DynamicHii
PCD(UEFI variable) is set for one SkuId, then the PCD value
will be always from UEFI variable but not PCD database, even
the SkuId is set to other value.

This patch is to update PCD drivers to allow SkuId to be
changed only once during one boot.

Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Feng Tian 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 27 +++
 MdeModulePkg/Universal/PCD/Pei/Pcd.c | 28 
 2 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c 
b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
index 1bb9098c04cf..9d710bbf1fb7 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
@@ -3,7 +3,7 @@
   produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL 
defined in
   PI 1.4a Vol3.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -272,19 +272,38 @@ DxePcdSetSku (
   SKU_ID*SkuIdTable;
   UINTN Index;
 
+  if (SkuId == mPcdDatabase.DxeDb->SystemSkuId) {
+//
+// The input SKU Id is equal to current SKU Id, return directly.
+//
+return;
+  }
+
+  if (mPcdDatabase.DxeDb->SystemSkuId != (SKU_ID) 0) {
+DEBUG ((DEBUG_ERROR, "PcdDxe - The SKU Id could be changed only once."));
+DEBUG ((
+  DEBUG_ERROR,
+  "PcdDxe - The SKU Id was set to 0x%lx already, it could not be set to 
0x%lx any more.",
+  mPcdDatabase.DxeDb->SystemSkuId,
+  (SKU_ID) SkuId
+  ));
+ASSERT (FALSE);
+return;
+  }
+
   SkuIdTable = (SKU_ID *) ((UINT8 *) mPcdDatabase.DxeDb + 
mPcdDatabase.DxeDb->SkuIdTableOffset);
   for (Index = 0; Index < SkuIdTable[0]; Index++) {
 if (SkuId == SkuIdTable[Index + 1]) {
+  DEBUG ((EFI_D_INFO, "PcdDxe - Set current SKU Id to 0x%lx.\n", (SKU_ID) 
SkuId));
   mPcdDatabase.DxeDb->SystemSkuId = (SKU_ID) SkuId;
   return;
 }
   }
 
   //
-  // Invalid input SkuId, the default SKU Id will be used for the system.
+  // Invalid input SkuId, the default SKU Id will be still used for the system.
   //
-  DEBUG ((EFI_D_INFO, "PcdDxe - Invalid input SkuId, the default SKU Id will 
be used.\n"));
-  mPcdDatabase.DxeDb->SystemSkuId = (SKU_ID) 0;
+  DEBUG ((EFI_D_INFO, "PcdDxe - Invalid input SkuId, the default SKU Id will 
be still used.\n"));
   return;
 }
 
diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c 
b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
index 668860b61c6c..a3f7337ceca3 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
@@ -1,7 +1,7 @@
 /** @file 
   All Pcd Ppi services are implemented here.
   
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
@@ -262,19 +262,39 @@ PeiPcdSetSku (
   UINTN Index;
 
   PeiPcdDb = GetPcdDatabase();
+
+  if (SkuId == PeiPcdDb->SystemSkuId) {
+//
+// The input SKU Id is equal to current SKU Id, return directly.
+//
+return;
+  }
+
+  if (PeiPcdDb->SystemSkuId != (SKU_ID) 0) {
+DEBUG ((DEBUG_ERROR, "PcdPei - The SKU Id could be changed only once."));
+DEBUG ((
+  DEBUG_ERROR,
+  "PcdPei - The SKU Id was set to 0x%lx already, it could not be set to 
0x%lx any more.",
+  PeiPcdDb->SystemSkuId,
+  (SKU_ID) SkuId
+  ));
+ASSERT (FALSE);
+return;
+  }
+
   SkuIdTable = (SKU_ID *) ((UINT8 *) PeiPcdDb + PeiPcdDb->SkuIdTableOffset);
   for (Index = 0; Index < SkuIdTable[0]; Index++) {
 if (SkuId == SkuIdTable[Index + 1]) {
+  DEBUG ((EFI_D_INFO, "PcdPei - Set current SKU Id to 0x%lx.\n", (SKU_ID) 
SkuId));
   PeiPcdDb->SystemSkuId = (SKU_ID) SkuId;
   return;
 }
   }
 
   //
-  // Invalid input SkuId, the default SKU Id will be used for the system.
+  // Invalid input SkuId, the default SKU Id will be still used for the system.
   //
-  DEBUG ((EFI_D_INFO, "PcdPei - Invalid input SkuId, the default SKU Id will 
be used.\n"));
-  PeiPcdDb->SystemSkuId = (SKU_ID) 0;
+  

[edk2] [PATCH 0/3] DP: Handle "/" separator in debug path for GCC

2017-03-14 Thread Star Zeng
Star Zeng (3):
  PerformancePkg Dp_App: Handle "/" separator in debug path for GCC
build
  ShellPkg UefiDpLib: Handle "/" separator in debug path for GCC build
  MdeModulePkg BmPerf: Handle "/" separator in debug path for GCC build

 MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c | 4 ++--
 PerformancePkg/Dp_App/DpUtilities.c | 2 +-
 ShellPkg/Library/UefiDpLib/DpUtilities.c| 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

-- 
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/3] PerformancePkg Dp_App: Handle "/" separator in debug path for GCC build

2017-03-14 Thread Star Zeng
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 PerformancePkg/Dp_App/DpUtilities.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PerformancePkg/Dp_App/DpUtilities.c 
b/PerformancePkg/Dp_App/DpUtilities.c
index d5840e8d6f83..d3a9b6eab3fa 100644
--- a/PerformancePkg/Dp_App/DpUtilities.c
+++ b/PerformancePkg/Dp_App/DpUtilities.c
@@ -169,7 +169,7 @@ GetShortPdbFileName (
 for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
   ;
 for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) {
-  if (PdbFileName[IndexA] == '\\') {
+  if ((PdbFileName[IndexA] == '\\') || (PdbFileName[IndexA] == '/')) {
 StartIndex = IndexA + 1;
   }
 
-- 
2.7.0.windows.1

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


[edk2] [PATCH 3/3] MdeModulePkg BmPerf: Handle "/" separator in debug path for GCC build

2017-03-14 Thread Star Zeng
Cc: Liming Gao 
Cc: Ruiyu Ni 
Cc: Feng Tian 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
index 0abd0194409c..4d4495b2a826 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c
@@ -3,7 +3,7 @@
   performance, all the function will only include if the performance
   switch is set.
 
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -49,7 +49,7 @@ BmGetShortPdbFileName (
   ;
 
 for (Index = 0; PdbFileName[Index] != 0; Index++) {
-  if (PdbFileName[Index] == '\\') {
+  if ((PdbFileName[Index] == '\\') || (PdbFileName[Index] == '/')) {
 StartIndex = Index + 1;
   }
 
-- 
2.7.0.windows.1

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


[edk2] [PATCH 2/3] ShellPkg UefiDpLib: Handle "/" separator in debug path for GCC build

2017-03-14 Thread Star Zeng
Cc: Liming Gao 
Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 ShellPkg/Library/UefiDpLib/DpUtilities.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiDpLib/DpUtilities.c 
b/ShellPkg/Library/UefiDpLib/DpUtilities.c
index 64f1830fcc92..c60d27d8613f 100644
--- a/ShellPkg/Library/UefiDpLib/DpUtilities.c
+++ b/ShellPkg/Library/UefiDpLib/DpUtilities.c
@@ -154,7 +154,7 @@ DpGetShortPdbFileName (
 for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
   ;
 for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) {
-  if (PdbFileName[IndexA] == '\\') {
+  if ((PdbFileName[IndexA] == '\\') || (PdbFileName[IndexA] == '/')) {
 StartIndex = IndexA + 1;
   }
 
-- 
2.7.0.windows.1

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


[edk2] [PATCH] MdeModulePkg/AcpiTableDxe: Not make FADT.{DSDT, X_DSDT} mutual exclusion

2017-03-16 Thread Star Zeng
198a46d768fb90d2f9b16e26451b4814e7469eaf improved the DSDT and X_DSDT
fields mutual exclusion by checking FADT revision, but that breaks
some OS that has assumption to only consume X_DSDT field even the
DSDT address is < 4G.

To have better compatibility, this patch is to update the code to not
make FADT.{DSDT,X_DSDT} mutual exclusion, but always set both DSDT and
X_DSDT fields in the FADT when the DSDT address is < 4G.

Cc: Laszlo Ersek 
Cc: Jeff Fan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 

NOTE: This patch comes out from the discussion at
https://lists.01.org/pipermail/edk2-devel/2017-March/008580.html.
---
 .../Acpi/AcpiTableDxe/AcpiTableProtocol.c  | 88 +-
 1 file changed, 34 insertions(+), 54 deletions(-)

diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c 
b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
index 4bb848df5203..a4fd9aff845d 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
@@ -432,50 +432,6 @@ ReallocateAcpiTableBuffer (
 }
 
 /**
-  Determine whether the FADT table passed in as parameter requires mutual
-  exclusion between the DSDT and X_DSDT fields. (That is, whether there exists
-  an explicit requirement that at most one of those fields is permitted to be
-  nonzero.)
-
-  @param[in] Fadt  The EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE object to
-   check.
-
-  @retval TRUE Fadt requires mutual exclusion between DSDT and X_DSDT.
-  @retval FALSEOtherwise.
-**/
-BOOLEAN
-RequireDsdtXDsdtExclusion (
-  IN EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt
-  )
-{
-  //
-  // Mantis ticket #1393 was addressed in ACPI 5.1 Errata B. Unfortunately, we
-  // can't tell apart 5.1 Errata A and 5.1 Errata B just from looking at the
-  // FADT table. Therefore let's require exclusion for table versions >= 5.1.
-  //
-  // While this needlessly covers 5.1 and 5.1A too, it is safer to require
-  // DSDT<->X_DSDT exclusion for lax (5.1, 5.1A) versions of the spec than to
-  // permit DSDT<->X_DSDT duplication for strict (5.1B) versions of the spec.
-  //
-  // The same applies to 6.0 vs. 6.0A. While 6.0 does not require the
-  // exclusion, 6.0A and 6.1 do. Since we cannot distinguish 6.0 from 6.0A
-  // based on just the FADT, we lump 6.0 in with the rest of >= 5.1.
-  //
-  if ((Fadt->Header.Revision < 5) ||
-  ((Fadt->Header.Revision == 5) &&
-   (((EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE *)Fadt)->MinorVersion == 
0))) {
-//
-// version <= 5.0
-//
-return FALSE;
-  }
-  //
-  // version >= 5.1
-  //
-  return TRUE;
-}
-
-/**
   This function adds an ACPI table to the table list.  It will detect FACS and
   allocate the correct type of memory and properly align the table.
 
@@ -692,11 +648,23 @@ AddTableToList (
   }
   if ((UINT64)(UINTN)AcpiTableInstance->Dsdt3 < BASE_4GB) {
 AcpiTableInstance->Fadt3->Dsdt = (UINT32) (UINTN) 
AcpiTableInstance->Dsdt3;
-if (RequireDsdtXDsdtExclusion (AcpiTableInstance->Fadt3)) {
-  Buffer64 = 0;
-} else {
-  Buffer64 = AcpiTableInstance->Fadt3->Dsdt;
-}
+//
+// Comment block "the caller installs the tables in "DSDT, FADT" order"
+// The below comments are also in "the caller installs the tables in 
"FADT, DSDT" order" comment block.
+//
+// The ACPI specification, up to and including revision 5.1 Errata A,
+// allows the DSDT and X_DSDT fields to be both set in the FADT.
+// (Obviously, this only makes sense if the DSDT address is 
representable in 4 bytes.)
+// Starting with 5.1 Errata B, specifically for Mantis 1393 
<https://mantis.uefi.org/mantis/view.php?id=1393>,
+// the spec requires at most one of DSDT and X_DSDT fields to be set 
to a nonzero value,
+// but strangely an exception is 6.0 that has no this requirement.
+//
+// Here we do not make the DSDT and X_DSDT fields mutual exclusion 
conditionally
+// by checking FADT revision, but always set both DSDT and X_DSDT 
fields in the FADT
+// to have better compatibility as some OS may have assumption to only 
consume X_DSDT
+// field even the DSDT address is < 4G.
+//
+Buffer64 = AcpiTableInstance->Fadt3->Dsdt;
   } else {
 AcpiTableInstance->Fadt3->Dsdt = 0;
 Buffer64 = (UINT64) (UINTN) AcpiTableInstance->Dsdt3;
@@ -896,11 +864,23 @@ AddTableToList (
   if (AcpiTableInstance->Fadt3 != NULL) {
 if ((UINT64)(UINTN)AcpiTableInstance->Dsdt3 < BASE_4GB) {
   AcpiTableInstance->Fadt3->Dsdt = (UINT32) (UINTN) 
AcpiTableInstance->Dsdt3;
- 

[edk2] [PATCH] MdeModulePkg CapsuleApp: Add -NR (no-reset) option support

2017-03-20 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=388

Add -NR (no-reset) option support, once the option is specified,
no reset will be trigger for the capsule with flag
CAPSULE_FLAGS_PERSIST_ACROSS_RESET and no CAPSULE_FLAGS_INITIATE_RESET.

Cc: Jiewen Yao 
Cc: Xiaofeng Wang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 

Note: the related discussion was at
https://lists.01.org/pipermail/edk2-devel/2017-February/007513.html.
---
 MdeModulePkg/Application/CapsuleApp/CapsuleApp.c | 28 +++-
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c 
b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
index 84ed4d738bc4..62bc12a88afe 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
@@ -670,7 +670,7 @@ PrintUsage (
   )
 {
   Print(L"CapsuleApp:  usage\n");
-  Print(L"  CapsuleApp \n");
+  Print(L"  CapsuleApp  [-NR]\n");
   Print(L"  CapsuleApp -S\n");
   Print(L"  CapsuleApp -C\n");
   Print(L"  CapsuleApp -P\n");
@@ -680,6 +680,8 @@ PrintUsage (
   Print(L"  CapsuleApp -D \n");
   Print(L"  CapsuleApp -P GET   -O \n");
   Print(L"Parameter:\n");
+  Print(L"  -NR: No reset will be trigger for the capsule with flag\n");
+  Print(L"   CAPSULE_FLAGS_PERSIST_ACROSS_RESET but no 
CAPSULE_FLAGS_INITIATE_RESET.\n");
   Print(L"  -S:  Dump capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");
   Print(L"   which is defined in UEFI specification.\n");
   Print(L"  -C:  Clear capsule report variable (EFI_CAPSULE_RPORT_GUID),\n");
@@ -721,6 +723,7 @@ UefiMain (
   UINT64 MaxCapsuleSize;
   EFI_RESET_TYPE ResetType;
   BOOLEANNeedReset;
+  BOOLEANNoReset;
   CHAR16 *CapsuleName;
   UINTN  CapsuleNum;
   UINTN  Index;
@@ -783,7 +786,13 @@ UefiMain (
 return EFI_SUCCESS;
   }
   CapsuleFirstIndex = 1;
-  CapsuleLastIndex = Argc - 1;
+  NoReset = FALSE;
+  if ((Argc > 1) && (StrCmp(Argv[Argc - 1], L"-NR") == 0)) {
+NoReset = TRUE;
+CapsuleLastIndex = Argc - 2;
+  } else {
+CapsuleLastIndex = Argc - 1;
+  }
   CapsuleNum = CapsuleLastIndex - CapsuleFirstIndex + 1;
 
   if (CapsuleFirstIndex > CapsuleLastIndex) {
@@ -855,10 +864,19 @@ UefiMain (
   goto Done;
 }
 //
-// For capsule who has reset flag, after calling UpdateCapsule 
service,triger a
-// system reset to process capsule persist across a system reset.
+// For capsule with flags CAPSULE_FLAGS_PERSIST_ACROSS_RESET + 
CAPSULE_FLAGS_INITIATE_RESET,
+// a system reset should have been triggered by gRT->UpdateCapsule() 
calling above.
+//
+// For capsule with flag CAPSULE_FLAGS_PERSIST_ACROSS_RESET but no 
CAPSULE_FLAGS_INITIATE_RESET,
+// check if -NR (no-reset) has been specified or not.
 //
-gRT->ResetSystem (ResetType, EFI_SUCCESS, 0, NULL);
+if (!NoReset) {
+  //
+  // For capsule who has reset flag and no -NR (no-reset) has been 
specified, after calling UpdateCapsule service,
+  // trigger a system reset to process capsule persist across a system 
reset.
+  //
+  gRT->ResetSystem (ResetType, EFI_SUCCESS, 0, NULL);
+}
   } else {
 //
 // For capsule who has no reset flag, only call UpdateCapsule Service 
without a
-- 
2.7.0.windows.1

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


[edk2] [PATCH 00/15] Separate variable check service to library

2015-08-17 Thread Star Zeng
NOTICE: To keep git bisect, the update to platform package Nt32Pkg, OvmfPkg, 
EmulatorPkg,
ArmVirtPkg, ArmPlatformPkg and Vlv2TbltDevicePkg has been split to two patches.

For your easy review,
the forked code is at g...@github.com:lzeng14/edk2.git branch 
VariableCheckService.

What to do:
1. Add VarCheckLib library and VarCheckUefiLib NULL class library.
2. Update Variable driver to consume the separated VarCheckLib.
3. Update platform package to add VarCheckLib library mapping
and link separated VarCheckUefiLib NULL class library

Why to do: Share code.
Separate variable check service from Variable driver in MdeModulePkg.
We are going to separate generic software logic code from Variable Driver
to benefit other variable driver implementation. Auth services has been done
to be AuthVariableLib, now to cover variable check service.

What test done:
Nt32 and OVMF: Boot fine same with no code separation.
Internal real platform: Boot fine to OS.

What is the impact to platform: Only platform dsc need to be updated.

Star Zeng (15):
  MdeModulePkg: Add VarCheckLib library
  MdeModulePkg: Add VarCheckUefiLib NULL class library
  Nt32Pkg: Add VarCheckLib library mapping
  OvmfPkg: Add VarCheckLib library mapping
  EmulatorPkg: Add VarCheckLib library mapping
  ArmVirtPkg: Add VarCheckLib library mapping
  ArmPlatformPkg: Add VarCheckLib library mapping
  Vlv2TbltDevicePkg: Add VarCheckLib library mapping
  MdeModulePkg Variable: Consume the separated VarCheckLib
  Nt32Pkg: Link separated VarCheckUefiLib NULL class library instance
  OvmfPkg: Link separated VarCheckUefiLib NULL class library instance
  EmulatorPkg: Link separated VarCheckUefiLib NULL class library
instance
  ArmVirtPkg: Link separated VarCheckUefiLib NULL class library instance
  ArmPlatformPkg: Link separated VarCheckUefiLib NULL class library
instance
  Vlv2TbltDevicePkg: Link separated VarCheckUefiLib NULL class library
instance

 ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc  |5 +-
 .../ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc|5 +-
 .../ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc |5 +-
 .../ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc |5 +-
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc  |1 +
 ArmVirtPkg/ArmVirt.dsc.inc |1 +
 ArmVirtPkg/ArmVirtQemu.dsc |5 +-
 EmulatorPkg/EmulatorPkg.dsc|6 +-
 MdeModulePkg/Include/Library/VarCheckLib.h |  180 
 MdeModulePkg/Library/VarCheckLib/VarCheckLib.c |  632 +++
 MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf   |   51 +
 MdeModulePkg/Library/VarCheckLib/VarCheckLib.uni   |  Bin 0 -> 1798 bytes
 .../Library/VarCheckUefiLib/VarCheckUefiLib.inf|   88 ++
 .../Library/VarCheckUefiLib/VarCheckUefiLib.uni|  Bin 0 -> 2158 bytes
 .../VarCheckUefiLib/VarCheckUefiLibNullClass.c |  930 
 MdeModulePkg/MdeModulePkg.dec  |4 +
 MdeModulePkg/MdeModulePkg.dsc  |   13 +-
 .../Universal/Variable/RuntimeDxe/VarCheck.c   | 1117 +---
 .../Universal/Variable/RuntimeDxe/Variable.c   |  193 +---
 .../Universal/Variable/RuntimeDxe/Variable.h   |   97 +-
 .../Universal/Variable/RuntimeDxe/VariableDxe.c|   48 +-
 .../Variable/RuntimeDxe/VariableRuntimeDxe.inf |   15 +-
 .../Universal/Variable/RuntimeDxe/VariableSmm.c|   23 +-
 .../Universal/Variable/RuntimeDxe/VariableSmm.inf  |   15 +-
 Nt32Pkg/Nt32Pkg.dsc|6 +-
 OvmfPkg/OvmfPkgIa32.dsc|6 +-
 OvmfPkg/OvmfPkgIa32X64.dsc |6 +-
 OvmfPkg/OvmfPkgX64.dsc |6 +-
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc|2 +
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc  |2 +
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc   |2 +
 31 files changed, 2045 insertions(+), 1424 deletions(-)
 create mode 100644 MdeModulePkg/Include/Library/VarCheckLib.h
 create mode 100644 MdeModulePkg/Library/VarCheckLib/VarCheckLib.c
 create mode 100644 MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 create mode 100644 MdeModulePkg/Library/VarCheckLib/VarCheckLib.uni
 create mode 100644 MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
 create mode 100644 MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.uni
 create mode 100644 
MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c

-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 02/15] MdeModulePkg: Add VarCheckUefiLib NULL class library

2015-08-17 Thread Star Zeng
What to do: Implement VarCheckUefiLib NULL class library instance.
The code logic are separated from Variable driver, and it will consume 
VarCheckLib
to register var check handler and variable property set for UEFI defined 
variables.

Why to do: Share code.
Separate variable check UEFI code from Variable driver in MdeModulePkg.
We are going to separate generic software logic code from Variable Driver
to benefit other variable driver implementation. Auth services has been done
to be AuthVariableLib, now to cover variable check service.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
Reviewed-by: Jiewen Yao 
---
 .../Library/VarCheckUefiLib/VarCheckUefiLib.inf|  88 ++
 .../Library/VarCheckUefiLib/VarCheckUefiLib.uni| Bin 0 -> 2158 bytes
 .../VarCheckUefiLib/VarCheckUefiLibNullClass.c | 930 +
 3 files changed, 1018 insertions(+)
 create mode 100644 MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
 create mode 100644 MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.uni
 create mode 100644 
MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c

diff --git a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf 
b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
new file mode 100644
index 000..ecfe6b3
--- /dev/null
+++ b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
@@ -0,0 +1,88 @@
+## @file
+#  NULL class library to register var check handler and variable property set 
for UEFI defined variables.
+#
+#  Copyright (c) 2015, Intel Corporation. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions
+#  of the BSD License which accompanies this distribution.  The
+#  full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = VarCheckUefiLib
+  MODULE_UNI_FILE= VarCheckUefiLib.uni
+  FILE_GUID  = AC24A4C7-F845-4665-90E5-6431D6E28DC0
+  MODULE_TYPE= DXE_RUNTIME_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = NULL|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER
+  CONSTRUCTOR= VarCheckUefiLibNullClassConstructor
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  VarCheckUefiLibNullClass.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  DevicePathLib
+  VarCheckLib
+
+[Guids]
+  ## SOMETIMES_CONSUMES  ## Variable:L"LangCodes"
+  ## SOMETIMES_CONSUMES  ## Variable:L"Lang"
+  ## SOMETIMES_CONSUMES  ## Variable:L"Timeout"
+  ## SOMETIMES_CONSUMES  ## Variable:L"PlatformLangCodes"
+  ## SOMETIMES_CONSUMES  ## Variable:L"PlatformLang"
+  ## SOMETIMES_CONSUMES  ## Variable:L"ConIn"
+  ## SOMETIMES_CONSUMES  ## Variable:L"ConOut"
+  ## SOMETIMES_CONSUMES  ## Variable:L"ErrOut"
+  ## SOMETIMES_CONSUMES  ## Variable:L"ConInDev"
+  ## SOMETIMES_CONSUMES  ## Variable:L"ConOutDev"
+  ## SOMETIMES_CONSUMES  ## Variable:L"ErrOutDev"
+  ## SOMETIMES_CONSUMES  ## Variable:L"BootOrder"
+  ## SOMETIMES_CONSUMES  ## Variable:L"BootNext"
+  ## SOMETIMES_CONSUMES  ## Variable:L"BootCurrent"
+  ## SOMETIMES_CONSUMES  ## Variable:L"BootOptionSupport"
+  ## SOMETIMES_CONSUMES  ## Variable:L"DriverOrder"
+  ## SOMETIMES_CONSUMES  ## Variable:L"SysPrepOrder"
+  ## SOMETIMES_CONSUMES  ## Variable:L"HwErrRecSupport"
+  ## SOMETIMES_CONSUMES  ## Variable:L"SetupMode"
+  ## SOMETIMES_CONSUMES  ## Variable:L"PK"
+  ## SOMETIMES_CONSUMES  ## Variable:L"KEK"
+  ## SOMETIMES_CONSUMES  ## Variable:L"SignatureSupport"
+  ## SOMETIMES_CONSUMES  ## Variable:L"SecureBoot"
+  ## SOMETIMES_CONSUMES  ## Variable:L"KEKDefault"
+  ## SOMETIMES_CONSUMES  ## Variable:L"PKDefault"
+  ## SOMETIMES_CONSUMES  ## Variable:L"dbDefault"
+  ## SOMETIMES_CONSUMES  ## Variable:L"dbxDefault"
+  ## SOMETIMES_CONSUMES  ## Variable:L"dbtDefault"
+  ## SOMETIMES_CONSUMES  ## Variable:L"OsIndicationsSupported"
+  ## SOMETIMES_CONSUMES  ## Variable:L"OsIndications"
+  ## SOMETIMES_CONSUMES  ## Variable:L"VendorKeys"
+  ## SOMETIMES_CONSUMES  ## Variable:L"Boot"
+  ## SOMETIMES_CONSUMES  ## Variable:L"Driver"
+  ## SOMETIMES_CONSUMES  ## Variable:L"SysPre

[edk2] [PATCH 09/15] MdeModulePkg Variable: Consume the separated VarCheckLib

2015-08-17 Thread Star Zeng
Since the variable check service has be separated to VarCheckLib
from Variable driver, so update Variable driver to consume the
separated VarCheckLib.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
Reviewed-by: Jiewen Yao 
---
 MdeModulePkg/MdeModulePkg.dsc  |   13 +-
 .../Universal/Variable/RuntimeDxe/VarCheck.c   | 1117 +---
 .../Universal/Variable/RuntimeDxe/Variable.c   |  193 +---
 .../Universal/Variable/RuntimeDxe/Variable.h   |   97 +-
 .../Universal/Variable/RuntimeDxe/VariableDxe.c|   48 +-
 .../Variable/RuntimeDxe/VariableRuntimeDxe.inf |   15 +-
 .../Universal/Variable/RuntimeDxe/VariableSmm.c|   23 +-
 .../Universal/Variable/RuntimeDxe/VariableSmm.inf  |   15 +-
 8 files changed, 107 insertions(+), 1414 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 20edc08..7b14e61 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -97,6 +97,7 @@ [LibraryClasses]
   
PlatformBootManagerLib|MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManagerLibNull.inf
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 
 [LibraryClasses.EBC.PEIM]
   IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
@@ -277,6 +278,8 @@ [Components]
   
MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManagerLibNull.inf
   MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+  MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
+  MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
 
   MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
   MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
@@ -369,13 +372,19 @@ [Components.IA32, Components.X64, Components.IPF]
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
 
 [Components.IA32, Components.X64, Components.Ebc]
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
   MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
   
 [Components.IA32, Components.X64]
   MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
   MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
   MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
   MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.inf
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
index 27b4801..ad56a9f 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
@@ -1,5 +1,6 @@
 /** @file
-  Implementation functions and structures for var check protocol.
+  Implementation functions and structures for var check protocol
+  and variable lock protocol based on VarCheckLib.
 
 Copyright (c) 2015, Intel Corporation. All rights reserved.
 This program and the accompanying materials
@@ -13,900 +14,53 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 **/
 
 #include "Variable.h"
-#include 
-
-extern LIST_ENTRY mLockedVariableList;
-extern BOOLEAN mEndOfDxe;
-extern BOOLEAN mEnableLocking;
-
-#define VAR_CHECK_HANDLER_TABLE_SIZE0x8
-
-UINT32  mNumberOfHandler = 0;
-UINT32  mMaxNumberOfHandler = 0;
-VAR_CHECK_SET_VARIABLE_CHECK_HANDLER*mHandlerTable = NULL;
-
-typedef struct {
-  LIST_ENTRYLink;
-  EFI_GUID  Guid;
-  VAR_CHECK_VARIABLE_PROPERTY   VariableProperty;
-  //CHAR16*Name;
-} VAR_CHECK_VARIABLE_ENTRY;
-
-LIST_ENTRY mVarCheckVariableList = INITIALIZE_LIST_HEAD_VARIABLE 
(mVarCheckVariableList);
-
-typedef
-EFI_STATUS
-(EFIAPI *INTERNAL_VAR_CHECK_FUNCTION) (
-  IN VAR_CHECK_VARIABLE_PROPERTY*Propery,
-  IN UINTN  DataSize,
-  IN VOID   *Data
-  );
-
-typedef struct {
-  CHAR16*Name;
-  VAR_CHECK_VARIABLE_PROPERTY   VariableProperty;
-  INTERNAL_VAR_CHECK_FUNCTION   CheckFunction;
-} UEFI_DEFINED_VARIABLE_ENTRY;
-
-/**
-  Internal check for load option.
-
-  @param[in] VariableProperyPointer to variable property.
-  @param[in] DataSize   Data size.
-  @param[in] Data   Pointer to data buffer.
-

[edk2] [PATCH 11/15] OvmfPkg: Link separated VarCheckUefiLib NULL class library instance

2015-08-17 Thread Star Zeng
Cc: Jordan Justen 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 OvmfPkg/OvmfPkgIa32.dsc| 5 -
 OvmfPkg/OvmfPkgIa32X64.dsc | 5 -
 OvmfPkg/OvmfPkgX64.dsc | 5 -
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index df00011..e55f0db 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -461,7 +461,10 @@ [Components]
   PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
   }
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 355ed6a..a8fcd88 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -468,7 +468,10 @@ [Components.X64]
   PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
   }
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 4469bd1..63e8c12 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -466,7 +466,10 @@ [Components]
   PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
   }
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 07/15] ArmPlatformPkg: Add VarCheckLib library mapping

2015-08-17 Thread Star Zeng
Since Variable driver has been updated to consume the separated VarCheckLib.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc 
b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
index d2f8f5a..dc69bbb 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -130,6 +130,7 @@ [LibraryClasses.common]
 
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 
 [LibraryClasses.common.SEC]
   
ArmPlatformSecExtraActionLib|ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 03/15] Nt32Pkg: Add VarCheckLib library mapping

2015-08-17 Thread Star Zeng
Since Variable driver has been updated to consume the separated VarCheckLib.

Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 Nt32Pkg/Nt32Pkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc
index 2b1d8c0..a95f4e9 100644
--- a/Nt32Pkg/Nt32Pkg.dsc
+++ b/Nt32Pkg/Nt32Pkg.dsc
@@ -141,6 +141,7 @@ [LibraryClasses]
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 
 [LibraryClasses.common.USER_DEFINED]
   DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 04/15] OvmfPkg: Add VarCheckLib library mapping

2015-08-17 Thread Star Zeng
Since Variable driver has been updated to consume the separated VarCheckLib.

Cc: Jordan Justen 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 OvmfPkg/OvmfPkgIa32.dsc| 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.dsc | 1 +
 3 files changed, 3 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 4ab618d..df00011 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -128,6 +128,7 @@ [LibraryClasses]
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 
   
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 90ca42a..355ed6a 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -133,6 +133,7 @@ [LibraryClasses]
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 
   
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index b72eaa9..4469bd1 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -133,6 +133,7 @@ [LibraryClasses]
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 
   
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 08/15] Vlv2TbltDevicePkg: Add VarCheckLib library mapping

2015-08-17 Thread Star Zeng
Since Variable driver has been updated to consume the separated VarCheckLib.

Cc: David Wei 
Cc: Tim He 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 1 +
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 1 +
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc| 1 +
 3 files changed, 3 insertions(+)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index 45008a0..39884af 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -267,6 +267,7 @@ [LibraryClasses.common]
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 !if $(RC_BINARY_RELEASE) == TRUE
   I2cLib|Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf
 !endif
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index 2fa7a36..e89b5f9 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -267,6 +267,7 @@ [LibraryClasses.common]
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 !if $(RC_BINARY_RELEASE) == TRUE
   I2cLib|Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf
 !endif
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index 4e0a9f8..fc8334f 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -267,6 +267,7 @@ [LibraryClasses.common]
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 !if $(RC_BINARY_RELEASE) == TRUE
   I2cLib|Vlv2TbltDevicePkg/Library/I2CLib/I2CLibNull.inf
 !endif
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 01/15] MdeModulePkg: Add VarCheckLib library

2015-08-17 Thread Star Zeng
What to do:
1. Add VarCheckLib LibraryClass definitions.
2. Implement VarCheckLib library instance.
The code logic are separated from Variable driver.

Why to do: Share code.
Separate variable check service from Variable driver in MdeModulePkg.
We are going to separate generic software logic code from Variable Driver
to benefit other variable driver implementation. Auth services has been done
to be AuthVariableLib, now to cover variable check service.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
Reviewed-by: Jiewen Yao 
---
 MdeModulePkg/Include/Library/VarCheckLib.h   | 180 +++
 MdeModulePkg/Library/VarCheckLib/VarCheckLib.c   | 632 +++
 MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf |  51 ++
 MdeModulePkg/Library/VarCheckLib/VarCheckLib.uni | Bin 0 -> 1798 bytes
 MdeModulePkg/MdeModulePkg.dec|   4 +
 5 files changed, 867 insertions(+)
 create mode 100644 MdeModulePkg/Include/Library/VarCheckLib.h
 create mode 100644 MdeModulePkg/Library/VarCheckLib/VarCheckLib.c
 create mode 100644 MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 create mode 100644 MdeModulePkg/Library/VarCheckLib/VarCheckLib.uni

diff --git a/MdeModulePkg/Include/Library/VarCheckLib.h 
b/MdeModulePkg/Include/Library/VarCheckLib.h
new file mode 100644
index 000..a423bc0
--- /dev/null
+++ b/MdeModulePkg/Include/Library/VarCheckLib.h
@@ -0,0 +1,180 @@
+/** @file
+  Provides variable check services and database management.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available 
under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _VARIABLE_CHECK_LIB_H_
+#define _VARIABLE_CHECK_LIB_H_
+
+#include 
+
+typedef enum {
+  VarCheckRequestReserved0 = 0,
+  VarCheckRequestReserved1 = 1,
+  VarCheckFromTrusted = 2,
+  VarCheckFromUntrusted = 3,
+} VAR_CHECK_REQUEST_SOURCE;
+
+typedef
+VOID
+(EFIAPI *VAR_CHECK_END_OF_DXE_CALLBACK) (
+  VOID
+  );
+
+/**
+  Register END_OF_DXE callback.
+  The callback will be invoked by VarCheckLibInitializeAtEndOfDxe().
+
+  @param[in] Callback   END_OF_DXE callback.
+
+  @retval EFI_SUCCESS   The callback was registered successfully.
+  @retval EFI_INVALID_PARAMETER Callback is NULL.
+  @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or 
EFI_EVENT_GROUP_READY_TO_BOOT has
+already been signaled.
+  @retval EFI_OUT_OF_RESOURCES  There is not enough resource for the callback 
register request.
+
+**/
+EFI_STATUS
+EFIAPI
+VarCheckLibRegisterEndOfDxeCallback (
+  IN VAR_CHECK_END_OF_DXE_CALLBACK  Callback
+  );
+
+/**
+  Var check initialize at END_OF_DXE.
+
+  This function needs to be called at END_OF_DXE.
+  Address pointers may be returned,
+  and caller needs to ConvertPointer() for the pointers.
+
+  @param[in, out] AddressPointerCount   Output pointer to address pointer 
count.
+
+  @return Address pointer buffer, NULL if input AddressPointerCount is NULL.
+
+**/
+VOID ***
+EFIAPI
+VarCheckLibInitializeAtEndOfDxe (
+  IN OUT UINTN  *AddressPointerCount OPTIONAL
+  );
+
+/**
+  Register address pointer.
+  The AddressPointer may be returned by VarCheckLibInitializeAtEndOfDxe().
+
+  @param[in] AddressPointer Address pointer.
+
+  @retval EFI_SUCCESS   The address pointer was registered 
successfully.
+  @retval EFI_INVALID_PARAMETER AddressPointer is NULL.
+  @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or 
EFI_EVENT_GROUP_READY_TO_BOOT has
+already been signaled.
+  @retval EFI_OUT_OF_RESOURCES  There is not enough resource for the address 
pointer register request.
+
+**/
+EFI_STATUS
+EFIAPI
+VarCheckLibRegisterAddressPointer (
+  IN VOID   **AddressPointer
+  );
+
+/**
+  Register SetVariable check handler.
+
+  @param[in] HandlerPointer to check handler.
+
+  @retval EFI_SUCCESS   The SetVariable check handler was registered 
successfully.
+  @retval EFI_INVALID_PARAMETER Handler is NULL.
+  @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or 
EFI_EVENT_GROUP_READY_TO_BOOT has
+already been signaled.
+  @retval EFI_OUT_OF_RESOURCES  There is not enough resource for the 
SetVariable check handler register request.
+  @retval EFI_UNSUPPORTED   This interface is not implemented.
+For example, it is unsupported in VarCheck 
protocol if both VarCheck and SmmVarCheck protocols are present.
+
+**/
+EFI_STATUS
+EFIAPI
+VarCheckLibRegisterSetVariableCheckHa

[edk2] [PATCH 06/15] ArmVirtPkg: Add VarCheckLib library mapping

2015-08-17 Thread Star Zeng
Since Variable driver has been updated to consume the separated VarCheckLib.

Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 ArmVirtPkg/ArmVirt.dsc.inc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 7bba6eb..8372c58 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -134,6 +134,7 @@ [LibraryClasses.common]
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 
 [LibraryClasses.common.SEC]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 10/15] Nt32Pkg: Link separated VarCheckUefiLib NULL class library instance

2015-08-17 Thread Star Zeng
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 Nt32Pkg/Nt32Pkg.dsc | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc
index a95f4e9..90a7b75 100644
--- a/Nt32Pkg/Nt32Pkg.dsc
+++ b/Nt32Pkg/Nt32Pkg.dsc
@@ -373,7 +373,10 @@ [Components]
   
MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
   
MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf
   Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
 !if $(SECURE_BOOT_ENABLE) == TRUE
   SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
 !endif
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 15/15] Vlv2TbltDevicePkg: Link separated VarCheckUefiLib NULL class library instance

2015-08-17 Thread Star Zeng
Cc: David Wei 
Cc: Tim He 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 1 +
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 1 +
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc| 1 +
 3 files changed, 3 insertions(+)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index 39884af..5c0b68a 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -1157,6 +1157,7 @@ [Components.X64]
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
 
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
   SerialPortLib|$(PLATFORM_PACKAGE)/Library/SerialPortLib/SerialPortLib.inf
   }
   $(PLATFORM_PACKAGE)/FvbRuntimeDxe/FvbSmm.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index e89b5f9..dad2eb0 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -1144,6 +1144,7 @@ [Components.IA32]
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
 
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
   SerialPortLib|$(PLATFORM_PACKAGE)/Library/SerialPortLib/SerialPortLib.inf
   }
   $(PLATFORM_PACKAGE)/FvbRuntimeDxe/FvbSmm.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index fc8334f..e32092e 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -1150,6 +1150,7 @@ [Components.X64]
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
 
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
   SerialPortLib|$(PLATFORM_PACKAGE)/Library/SerialPortLib/SerialPortLib.inf
   }
   $(PLATFORM_PACKAGE)/FvbRuntimeDxe/FvbSmm.inf
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 14/15] ArmPlatformPkg: Link separated VarCheckUefiLib NULL class library instance

2015-08-17 Thread Star Zeng
Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc | 5 -
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc| 5 -
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc | 5 -
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc | 5 -
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc 
b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
index 09ec5b3..f5af426 100644
--- a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
+++ b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
@@ -220,7 +220,10 @@ [Components.common]
   MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
   EmbeddedPkg/SerialDxe/SerialDxe.inf
 
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
 
   #
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc 
b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
index c1e3513..c76d729 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -233,7 +233,10 @@ [Components.common]
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc 
b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
index 119ba3a..71c794b 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -262,7 +262,10 @@ [Components.common]
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc 
b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
index 37f3648..72103e2 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
@@ -245,7 +245,10 @@ [Components.common]
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 05/15] EmulatorPkg: Add VarCheckLib library mapping

2015-08-17 Thread Star Zeng
Since Variable driver has been updated to consume the separated VarCheckLib.

Cc: Jordan Justen 
Cc: Andrew Fish 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 EmulatorPkg/EmulatorPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index dfcd476..71943e4 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -107,6 +107,7 @@ [LibraryClasses]
   
CpuExceptionHandlerLib|MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 
 [LibraryClasses.common.SEC]
   PeiServicesLib|EmulatorPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 13/15] ArmVirtPkg: Link separated VarCheckUefiLib NULL class library instance

2015-08-17 Thread Star Zeng
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 ArmVirtPkg/ArmVirtQemu.dsc | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 216f130..f1af968 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -256,7 +256,10 @@ [Components.common]
   #
   ArmPkg/Drivers/CpuDxe/CpuDxe.inf
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
 !if $(SECURE_BOOT_ENABLE) == TRUE
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
 
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 12/15] EmulatorPkg: Link separated VarCheckUefiLib NULL class library instance

2015-08-17 Thread Star Zeng
Cc: Jordan Justen 
Cc: Andrew Fish 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 EmulatorPkg/EmulatorPkg.dsc | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 71943e4..8eff20e 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -315,7 +315,10 @@ [Components]
   EmulatorPkg/TimerDxe/Timer.inf
 
 
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH] MdeModulePkg: Add VarCheckHiiLib NULL class library

2015-08-18 Thread Star Zeng
The check will be based on VarCheckHiiBin that generated
from FV and Hii Database.

Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../VarCheckHiiLib/InternalVarCheckStructure.h |   82 ++
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h  |   63 +
 .../Library/VarCheckHiiLib/VarCheckHiiGen.c| 1483 
 .../Library/VarCheckHiiLib/VarCheckHiiGen.h|  136 ++
 .../Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c  |  443 ++
 .../Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c |   73 +
 .../Library/VarCheckHiiLib/VarCheckHiiLib.inf  |   58 +
 .../Library/VarCheckHiiLib/VarCheckHiiLib.uni  |  Bin 0 -> 1766 bytes
 .../VarCheckHiiLib/VarCheckHiiLibNullClass.c   |  539 +++
 MdeModulePkg/MdeModulePkg.dec  |6 +
 MdeModulePkg/MdeModulePkg.dsc  |3 +
 MdeModulePkg/MdeModulePkg.uni  |  Bin 182392 -> 183916 
bytes
 12 files changed, 2886 insertions(+)
 create mode 100644 
MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h
 create mode 100644 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h
 create mode 100644 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c
 create mode 100644 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.h
 create mode 100644 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c
 create mode 100644 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c
 create mode 100644 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf
 create mode 100644 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.uni
 create mode 100644 
MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c

diff --git a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h 
b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h
new file mode 100644
index 000..a9faed4
--- /dev/null
+++ b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h
@@ -0,0 +1,82 @@
+/** @file
+  Internal structure for Var Check Hii.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD 
License
+which accompanies this distribution.  The full text of the license may be 
found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _VAR_CHECK_STRUCTURE_H_
+#define _VAR_CHECK_STRUCTURE_H_
+
+//
+// Alignment for Hii Variable and Question header.
+//
+#define HEADER_ALIGNMENT  4
+#define HEADER_ALIGN(Header)  (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & 
(~(HEADER_ALIGNMENT - 1)))
+
+#pragma pack (1)
+
+#define VAR_CHECK_HII_REVISION  0x0001
+
+typedef struct {
+  UINT16Revision;
+  UINT16HeaderLength;
+  UINT32Length; // Length include this header
+  UINT8 OpCode;
+  UINT8 Reserved;
+  UINT16Size;
+  UINT32Attributes;
+  EFI_GUID  Guid;
+//CHAR16  Name[];
+} VAR_CHECK_HII_VARIABLE_HEADER;
+
+typedef struct {
+  UINT8 OpCode;
+  UINT8 Length; // Length include this header
+  UINT16VarOffset;
+  UINT8 StorageWidth;
+} VAR_CHECK_HII_QUESTION_HEADER;
+
+typedef struct {
+  UINT8 OpCode;
+  UINT8 Length; // Length include this header
+  UINT16VarOffset;
+  UINT8 StorageWidth;
+//UINTx   Data[]; // x = UINT8/UINT16/UINT32/UINT64;
+} VAR_CHECK_HII_QUESTION_ONEOF;
+
+typedef struct {
+  UINT8 OpCode;
+  UINT8 Length; // Length include this header
+  UINT16VarOffset;
+  UINT8 StorageWidth;
+} VAR_CHECK_HII_QUESTION_CHECKBOX;
+
+typedef struct {
+  UINT8 OpCode;
+  UINT8 Length; // Length include this header
+  UINT16VarOffset;
+  UINT8 StorageWidth;
+//UINTx   Minimum; // x = UINT8/UINT16/UINT32/UINT64;
+//UINTx   Maximum; // x = UINT8/UINT16/UINT32/UINT64;
+} VAR_CHECK_HII_QUESTION_NUMERIC;
+
+typedef struct {
+  UINT8 OpCode;
+  UINT8 Length; // Length include this header
+  UINT16VarOffset;
+  UINT8 StorageWidth;
+  UINT8 MaxContainers;
+//UINTx   Data[]; // x = UINT8/UINT16/UINT32/UINT64;
+} VAR_CHECK_HII_QUESTION_ORDEREDLIST;
+
+#pragma pack ()
+
+#endif
diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h 
b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h
new file mode 100644
index 000..d770785
--- /dev/null
+++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h
@@ -0,0 +1,63 @@
+/** @file
+  Include file for Var Check Hii handler and bin.
+
+Copyright (c) 2015, Intel Corporation. All rights reserve

[edk2] [PATCH] MdeModulePkg: Add VarCheckPcdLib NULL class library

2015-08-18 Thread Star Zeng
The check will be based on PcdVarCheck binary that generated
by BaseTools.

Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../Library/VarCheckPcdLib/VarCheckPcdLib.inf  |  65 +++
 .../Library/VarCheckPcdLib/VarCheckPcdLib.uni  | Bin 0 -> 1766 bytes
 .../VarCheckPcdLib/VarCheckPcdLibNullClass.c   | 474 +
 .../Library/VarCheckPcdLib/VarCheckPcdStructure.h  |  76 
 MdeModulePkg/MdeModulePkg.dsc  |   3 +
 5 files changed, 618 insertions(+)
 create mode 100644 MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLib.inf
 create mode 100644 MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLib.uni
 create mode 100644 
MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c
 create mode 100644 MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdStructure.h

diff --git a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLib.inf 
b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLib.inf
new file mode 100644
index 000..b9d235b
--- /dev/null
+++ b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLib.inf
@@ -0,0 +1,65 @@
+## @file
+#  NULL class library to register var check PCD handler.
+#
+#  In platform *.fdf, the example build rule for the driver this library 
linked to.
+#[Rule.Common.DXE_RUNTIME_DRIVER.VARCHECKPCD]
+#  FILE DRIVER = $(NAMED_GUID) {
+#RAW  BIN 
$(WORKSPACE)/$(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/FV/PcdVarCheck.bin
+#DXE_DEPEXDXE_DEPEX Optional  
$(INF_OUTPUT)/$(MODULE_NAME).depex
+#PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
+#UI   STRING="$(MODULE_NAME)" Optional
+#VERSION  STRING="$(INF_VERSION)" Optional 
BUILD_NUM=$(BUILD_NUMBER)
+#  }
+#
+#or
+#
+#[Rule.Common.DXE_SMM_DRIVER.VARCHECKPCD]
+#  FILE SMM = $(NAMED_GUID) {
+#RAW  BIN 
$(WORKSPACE)/$(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/FV/PcdVarCheck.bin
+#DXE_DEPEXDXE_DEPEX Optional  
$(INF_OUTPUT)/$(MODULE_NAME).depex
+#PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
+#UI   STRING="$(MODULE_NAME)" Optional
+#VERSION  STRING="$(INF_VERSION)" Optional 
BUILD_NUM=$(BUILD_NUMBER)
+#  }
+#
+#  In platform *.dsc, also need add one line below to enable PcdVarCheck.bin 
generation by BaseTools.
+#PCD_VAR_CHECK_GENERATION= TRUE
+#
+#  Copyright (c) 2015, Intel Corporation. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions
+#  of the BSD License which accompanies this distribution.  The
+#  full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = VarCheckPcdLib
+  MODULE_UNI_FILE= VarCheckPcdLib.uni
+  FILE_GUID  = D4FA5311-5F1F-4B1E-9AC3-90C4DFC029F1
+  MODULE_TYPE= DXE_RUNTIME_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = NULL|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER
+  CONSTRUCTOR= VarCheckPcdLibNullClassConstructor
+
+[Sources]
+  VarCheckPcdLibNullClass.c
+  VarCheckPcdStructure.h
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  BaseMemoryLib
+  DxeServicesLib
+  MemoryAllocationLib
+  VarCheckLib
diff --git a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLib.uni 
b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLib.uni
new file mode 100644
index 
..4a3d932be930275c9edef85e51cec9dd381d8427
GIT binary patch
literal 1766
zcmd6nTW`}q5QWb(692(UUjVfUAn}3_B54d*lqSkWg{LZ)HnGSBIib)$4}52x*l7q7
zPpGoIyE8jGbLPzK{`y%{O%eYSzDRF$tyD8z>7gE=_1?MqI^&BpVrQTgU&JcaP#JQj
zTjaHtj2R~X}~Xm~}!9&UVJyXEIKC9H32EEyyfVoqb!B-pr!;S_P(V7{^$?QbQfR
zKEOo}3}!aMe}>;lh%rabS#%A|vE>opQgbZ5cgwj2_7NJRa%EChGrW~tyOKWb%8pnq
z0zw@C6>^MHDb(#UL?7W_D;C7oBEYp5GKz_R$K_J4nWEon!W}wT+|ZR&TL&^v}#6*fDb7zjzZR
z&mz{R!cXZvfr~b8m}52%zBGRSY5}`B^?y|KOn!HA{x0#{0)Gt
B5%T~5

literal 0
HcmV?d1

diff --git a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c 
b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c
new file mode 100644
index 000..72b0363
--- /dev/null
+++ b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c
@@ -0,0 +1,474 @@
+/** @file
+  Var Check PCD handler.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials
+are licensed and made available unde

[edk2] [PATCH] MdeModulePkg: Add PlatformVarCleanupLib library

2015-08-18 Thread Star Zeng
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../Include/Library/PlatformVarCleanupLib.h|   61 +
 .../Library/PlatformVarCleanupLib/PlatVarCleanup.h |  111 ++
 .../PlatformVarCleanupLib/PlatVarCleanup.vfr   |   41 +
 .../PlatformVarCleanupLib/PlatVarCleanupHii.h  |   59 +
 .../PlatformVarCleanupLib/PlatVarCleanupLib.c  | 1250 
 .../PlatformVarCleanupLib.inf  |   74 ++
 .../PlatformVarCleanupLib.uni  |  Bin 0 -> 1766 bytes
 .../Library/PlatformVarCleanupLib/VfrStrings.uni   |  Bin 0 -> 4528 bytes
 MdeModulePkg/MdeModulePkg.dec  |4 +
 MdeModulePkg/MdeModulePkg.dsc  |1 +
 10 files changed, 1601 insertions(+)
 create mode 100644 MdeModulePkg/Include/Library/PlatformVarCleanupLib.h
 create mode 100644 MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h
 create mode 100644 
MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.vfr
 create mode 100644 
MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupHii.h
 create mode 100644 
MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c
 create mode 100644 
MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf
 create mode 100644 
MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.uni
 create mode 100644 MdeModulePkg/Library/PlatformVarCleanupLib/VfrStrings.uni

diff --git a/MdeModulePkg/Include/Library/PlatformVarCleanupLib.h 
b/MdeModulePkg/Include/Library/PlatformVarCleanupLib.h
new file mode 100644
index 000..a4691f0
--- /dev/null
+++ b/MdeModulePkg/Include/Library/PlatformVarCleanupLib.h
@@ -0,0 +1,61 @@
+/** @file
+  The library class provides platform variable cleanup services.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD 
License
+which accompanies this distribution.  The full text of the license may be 
found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PLATFORM_VARIABLE_CLEANUP_LIB_
+#define _PLATFORM_VARIABLE_CLEANUP_LIB_
+
+#include 
+
+typedef enum {
+  VarCleanupAll,
+  VarCleanupManually,
+  VarCleanupMax,
+} VAR_CLEANUP_TYPE;
+
+/**
+  Get last boot variable error flag.
+
+  @return   Last boot variable error flag.
+
+**/
+VAR_ERROR_FLAG
+EFIAPI
+GetLastBootVarErrorFlag (
+  );
+
+/**
+  Platform variable cleanup.
+
+  @param[in] Flag   Variable error flag.
+  @param[in] Type   Variable cleanup type.
+If it is VarCleanupManually, the interface 
must be called after console connected.
+
+  @retval EFI_SUCCESS   No error or error processed.
+  @retval EFI_UNSUPPORTED   The specified Flag or Type is not 
supported.
+For example, system error may be not 
supported to process and Platform should have mechanism to reset system to 
manufacture mode.
+Another, if system and user variables are 
wanted to be distinguished to process, the interface must be called after 
EndOfDxe.
+  @retval EFI_OUT_OF_RESOURCES  Not enough resource to process the error.
+  @retval EFI_INVALID_PARAMETER The specified Flag or Type is an invalid 
value.
+  @retval OthersOther failure occurs.
+
+**/
+EFI_STATUS
+EFIAPI
+PlatformVarCleanup (
+  IN VAR_ERROR_FLAG Flag,
+  IN VAR_CLEANUP_TYPE   Type
+  );
+
+#endif
+
diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h 
b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h
new file mode 100644
index 000..30c2595
--- /dev/null
+++ b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h
@@ -0,0 +1,111 @@
+/** @file
+  Include file for platform variable cleanup.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD 
License
+which accompanies this distribution.  The full text of the license may be 
found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PLAT_VAR_CLEANUP_
+#define _PLAT_VAR_CLEANUP_
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "PlatVarCleanupHii.h"
+
+//
+// This is the generated IFR binary data for each formset de

[edk2] [PATCH 1/2] BaseTools: Follow PI spec to update ExtendedSize in EFI_FFS_FILE_HEADER2

2015-08-20 Thread Star Zeng
for FFS data above 16 bytes alignment requirement.

PI spec requires FFS header to be at 8 bytes alignment to FV header.
And, FFS data alignment requires the beginning of the file data must
be aligned on a particular boundary, such as 1, 16, 128 bytes or above.
If FFS data alignment requires to be above 16 bytes, and FFS header
must be at 8 byte alignment, so FFS header size must be multiple of 8.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 BaseTools/Source/C/Common/FirmwareVolumeBuffer.c   | 4 ++--
 BaseTools/Source/C/Common/FvLib.c  | 4 ++--
 BaseTools/Source/C/Include/Common/PiFirmwareFile.h | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c 
b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
index 01d4e72..7988d8e 100644
--- a/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
+++ b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
@@ -1,7 +1,7 @@
 /** @file
 EFI Firmware Volume routines which work on a Fv image in buffers.
 
-Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 1999 - 2015, 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
@@ -864,7 +864,7 @@ Returns:
 return 0;
   }
   if (Ffs->Attributes & FFS_ATTRIB_LARGE_FILE) {
-return ((EFI_FFS_FILE_HEADER2 *)Ffs)->ExtendedSize;
+return (UINT32) ((EFI_FFS_FILE_HEADER2 *)Ffs)->ExtendedSize;
   }
   return FvBufExpand3ByteSize(Ffs->Size);
 }
diff --git a/BaseTools/Source/C/Common/FvLib.c 
b/BaseTools/Source/C/Common/FvLib.c
index 1b3c08b..938aa09 100644
--- a/BaseTools/Source/C/Common/FvLib.c
+++ b/BaseTools/Source/C/Common/FvLib.c
@@ -1,7 +1,7 @@
 /** @file
 These functions assist in parsing and manipulating a Firmware Volume.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2015, 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
@@ -784,7 +784,7 @@ Returns:
 return 0;
   }
   if (FfsHeader->Attributes & FFS_ATTRIB_LARGE_FILE) {
-return ((EFI_FFS_FILE_HEADER2 *)FfsHeader)->ExtendedSize;
+return (UINT32) ((EFI_FFS_FILE_HEADER2 *)FfsHeader)->ExtendedSize;
   } else {
 return GetLength(FfsHeader->Size);
   }
diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h 
b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
index ec31eab..2984860 100644
--- a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
+++ b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
@@ -2,9 +2,9 @@
   The firmware file related definitions in PI.
   
   @par Revision Reference:
-  Version 1.0.
+  Version 1.4.
 
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2015, 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
@@ -110,7 +110,7 @@ typedef struct {
   EFI_FFS_FILE_ATTRIBUTES Attributes;
   UINT8   Size[3];
   EFI_FFS_FILE_STATE  State;
-  UINT32  ExtendedSize;
+  UINT64  ExtendedSize;
 } EFI_FFS_FILE_HEADER2;
 
 #define MAX_FFS_SIZE0x100
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 0/2] Follow PI spec to update ExtendedSize in EFI_FFS_FILE_HEADER2

2015-08-20 Thread Star Zeng
for FFS data above 16 bytes alignment requirement.

PI spec requires FFS header to be at 8 bytes alignment to FV header.
And, FFS data alignment requires the beginning of the file data must
be aligned on a particular boundary, such as 1, 16, 128 bytes or above.
If FFS data alignment requires to be above 16 bytes, and FFS header
must be at 8 byte alignment, so FFS header size must be multiple of 8.

Star Zeng (2):
  BaseTools: Follow PI spec to update ExtendedSize in
EFI_FFS_FILE_HEADER2
  MdePkg: Follow PI spec to update ExtendedSize in EFI_FFS_FILE_HEADER2

 BaseTools/Source/C/Common/FirmwareVolumeBuffer.c   | 4 ++--
 BaseTools/Source/C/Common/FvLib.c  | 4 ++--
 BaseTools/Source/C/Include/Common/PiFirmwareFile.h | 6 +++---
 MdePkg/Include/Pi/PiFirmwareFile.h | 8 
 4 files changed, 11 insertions(+), 11 deletions(-)

-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 2/2] MdePkg: Follow PI spec to update ExtendedSize in EFI_FFS_FILE_HEADER2

2015-08-20 Thread Star Zeng
for FFS data above 16 bytes alignment requirement.

PI spec requires FFS header to be at 8 bytes alignment to FV header.
And, FFS data alignment requires the beginning of the file data must
be aligned on a particular boundary, such as 1, 16, 128 bytes or above.
If FFS data alignment requires to be above 16 bytes, and FFS header
must be at 8 byte alignment, so FFS header size must be multiple of 8.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdePkg/Include/Pi/PiFirmwareFile.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Include/Pi/PiFirmwareFile.h 
b/MdePkg/Include/Pi/PiFirmwareFile.h
index 1f94429..7343444 100644
--- a/MdePkg/Include/Pi/PiFirmwareFile.h
+++ b/MdePkg/Include/Pi/PiFirmwareFile.h
@@ -1,7 +1,7 @@
 /** @file
   The firmware file related definitions in PI.
 
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
 This program and the accompanying materials are licensed and made available 
under
 the terms and conditions of the BSD License that accompanies this distribution.
 The full text of the license may be found at
@@ -11,7 +11,7 @@ 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:
-  PI Version 1.2.
+  PI Version 1.4.
 
 **/
 
@@ -173,7 +173,7 @@ typedef struct {
   /// If FFS_ATTRIB_LARGE_FILE is set in Attributes, then ExtendedSize exists 
and Size must be set to zero.
   /// If FFS_ATTRIB_LARGE_FILE is not set then EFI_FFS_FILE_HEADER is used.
   ///
-  UINT32ExtendedSize;
+  UINT64ExtendedSize;
 } EFI_FFS_FILE_HEADER2;
 
 #define IS_FFS_FILE2(FfsFileHeaderPtr) \
@@ -183,7 +183,7 @@ typedef struct {
 ((UINT32) (*((UINT32 *) ((EFI_FFS_FILE_HEADER *) (UINTN) 
FfsFileHeaderPtr)->Size) & 0x00ff))
 
 #define FFS_FILE2_SIZE(FfsFileHeaderPtr) \
-(((EFI_FFS_FILE_HEADER2 *) (UINTN) FfsFileHeaderPtr)->ExtendedSize)
+((UINT32) (((EFI_FFS_FILE_HEADER2 *) (UINTN) 
FfsFileHeaderPtr)->ExtendedSize))
 
 typedef UINT8 EFI_SECTION_TYPE;
 
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH] MdeModulePkg PeiCore: Recheck SwitchStackSignal after ProcessNotifyList()

2015-08-21 Thread Star Zeng
in case PeiInstallPeiMemory() is done in a callback with
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH, and the callback is registered on
a PPI that is installed in the last PEIM.

At the case, PeiCore SwitchStack code will be not being invoked.

Cc: Jiewen Yao 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 547 +-
 1 file changed, 284 insertions(+), 263 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c 
b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 46e990d..b6e71b8 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -626,6 +626,282 @@ PeiCoreEntry (
   PeiCore (SecCoreData, NULL, Private);
 }
 
+VOID
+PeiCheckAndSwitchStack (
+  IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
+  IN PEI_CORE_INSTANCE  *Private
+  )
+{
+  VOID  *LoadFixPeiCodeBegin;
+  EFI_STATUSStatus;
+  CONST EFI_PEI_SERVICES**PeiServices;
+  UINT64NewStackSize;
+  EFI_PHYSICAL_ADDRESS  TopOfOldStack;
+  EFI_PHYSICAL_ADDRESS  TopOfNewStack;
+  UINTN StackOffset;
+  BOOLEAN   StackOffsetPositive;
+  EFI_PHYSICAL_ADDRESS  TemporaryRamBase;
+  UINTN TemporaryRamSize;
+  UINTN TemporaryStackSize;
+  VOID  *TemporaryStackBase;
+  UINTN PeiTemporaryRamSize;
+  VOID  *PeiTemporaryRamBase;
+  EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI *TemporaryRamSupportPpi;
+  EFI_PHYSICAL_ADDRESS  BaseOfNewHeap;
+  EFI_PHYSICAL_ADDRESS  HoleMemBase;
+  UINTN HoleMemSize;
+  UINTN HeapTemporaryRamSize;
+  EFI_PHYSICAL_ADDRESS  TempBase1;
+  UINTN TempSize1;
+  EFI_PHYSICAL_ADDRESS  TempBase2;
+  UINTN TempSize2;
+  UINTN Index;
+
+  PeiServices = (CONST EFI_PEI_SERVICES **) &Private->Ps;
+
+  if (Private->SwitchStackSignal) {
+//
+// Before switch stack from temporary memory to permenent memory, 
calculate the heap and stack
+// usage in temporary memory for debuging.
+//
+DEBUG_CODE_BEGIN ();
+  UINT32  *StackPointer;
+
+  for (StackPointer = (UINT32*)SecCoreData->StackBase;
+   (StackPointer < (UINT32*)((UINTN)SecCoreData->StackBase + 
SecCoreData->StackSize)) \
+   && (*StackPointer == INIT_CAR_VALUE);
+   StackPointer ++);
+
+DEBUG ((EFI_D_INFO, "Temp Stack : BaseAddress=0x%p Length=0x%X\n", 
SecCoreData->StackBase, (UINT32)SecCoreData->StackSize));
+DEBUG ((EFI_D_INFO, "Temp Heap  : BaseAddress=0x%p Length=0x%X\n", 
Private->HobList.Raw, (UINT32)((UINTN) 
Private->HobList.HandoffInformationTable->EfiFreeMemoryBottom - (UINTN) 
Private->HobList.Raw)));
+DEBUG ((EFI_D_INFO, "Total temporary memory:%d bytes.\n", 
(UINT32)SecCoreData->TemporaryRamSize));
+DEBUG ((EFI_D_INFO, "  temporary memory stack ever used: %d bytes.\n",
+   (UINT32)(SecCoreData->StackSize - ((UINTN) StackPointer - 
(UINTN)SecCoreData->StackBase))
+  ));
+DEBUG ((EFI_D_INFO, "  temporary memory heap used:   %d bytes.\n",
+   
(UINT32)((UINTN)Private->HobList.HandoffInformationTable->EfiFreeMemoryBottom - 
(UINTN)Private->HobList.Raw)
+  ));
+DEBUG_CODE_END ();
+
+if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 && 
(Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
+  //
+  // Loading Module at Fixed Address is enabled
+  //
+  PeiLoadFixAddressHook (Private);
+
+  //
+  // If Loading Module at Fixed Address is enabled, Allocating memory 
range for Pei code range.
+  //
+  LoadFixPeiCodeBegin = 
AllocatePages((UINTN)PcdGet32(PcdLoadFixAddressPeiCodePageNumber));
+  DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PeiCodeBegin = 0x%lX, 
PeiCodeTop= 0x%lX\n", (UINT64)(UINTN)LoadFixPeiCodeBegin, 
(UINT64)((UINTN)LoadFixPeiCodeBegin + 
PcdGet32(PcdLoadFixAddressPeiCodePageNumber) * EFI_PAGE_SIZE)));
+}
+
+//
+// Reserve the size of new stack at bottom of physical memory
+//
+// The size of new stack in permenent memory must be the same size 
+// or larger than the size of old stack in temporary memory.
+// But if new stack is smaller than the size of old stack, we also reserve
+// the 

[edk2] [PATCH] MdeModulePkg PiSmmCore: Prevent overlap for gSmmCorePrivate and CommBuffer

2015-08-24 Thread Star Zeng
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c 
b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
index 55dcf31..9f47d27 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
@@ -427,9 +427,13 @@ SmmEntryPoint (
   //
   // Synchronous SMI for SMM Core or request from Communicate protocol
   //
-  if (!SmmIsBufferOutsideSmmValid 
((UINTN)gSmmCorePrivate->CommunicationBuffer, gSmmCorePrivate->BufferSize)) {
+  if (!SmmIsBufferOutsideSmmValid 
((UINTN)gSmmCorePrivate->CommunicationBuffer, gSmmCorePrivate->BufferSize) ||
+  !UINTN) gSmmCorePrivate->CommunicationBuffer + 
gSmmCorePrivate->BufferSize) <= (UINTN) gSmmCorePrivate) ||
+((UINTN) gSmmCorePrivate->CommunicationBuffer >= ((UINTN) 
gSmmCorePrivate + sizeof (*gSmmCorePrivate) {
 //
-// If CommunicationBuffer is not in valid address scope, return 
EFI_INVALID_PARAMETER
+// If CommunicationBuffer is not in valid address scope,
+// or there is overlap between gSmmCorePrivate and CommunicationBuffer,
+// return EFI_INVALID_PARAMETER
 //
 gSmmCorePrivate->CommunicationBuffer = NULL;
 gSmmCorePrivate->ReturnStatus = EFI_INVALID_PARAMETER;
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH V2] MdeModulePkg PiSmmCore: Prevent overlap for gSmmCorePrivate and CommBuffer

2015-08-25 Thread Star Zeng
InternalIsBufferOverlapped() is created to check overlap between buffers.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
Reviewed-by: Jiewen Yao 
---
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 44 +++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c 
b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
index 55dcf31..496638a 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
@@ -379,6 +379,37 @@ SmmEndOfDxeHandler (
 }
 
 /**
+  Determine if two buffers overlap in memory.
+
+  @param[in] Buff1  Pointer to first buffer
+  @param[in] Size1  Size of Buff1
+  @param[in] Buff2  Pointer to second buffer
+  @param[in] Size2  Size of Buff2
+
+  @retval TRUE  Buffers overlap in memory.
+  @retval FALSE Buffer doesn't overlap.
+
+**/
+BOOLEAN
+InternalIsBufferOverlapped (
+  IN UINT8  *Buff1,
+  IN UINTN  Size1,
+  IN UINT8  *Buff2,
+  IN UINTN  Size2
+  )
+{
+  //
+  // If buff1's end is less than the start of buff2, then it's ok.
+  // Also, if buff1's start is beyond buff2's end, then it's ok.
+  //
+  if (((Buff1 + Size1) <= Buff2) || (Buff1 >= (Buff2 + Size2))) {
+return FALSE;
+  }
+
+  return TRUE;
+}
+
+/**
   The main entry point to SMM Foundation.
 
   Note: This function is only used by SMRAM invocation.  It is never used by 
DXE invocation.
@@ -396,6 +427,7 @@ SmmEntryPoint (
   EFI_STATUS  Status;
   EFI_SMM_COMMUNICATE_HEADER  *CommunicateHeader;
   BOOLEAN InLegacyBoot;
+  BOOLEAN IsOverlapped;
 
   PERF_START (NULL, "SMM", NULL, 0) ;
 
@@ -427,9 +459,17 @@ SmmEntryPoint (
   //
   // Synchronous SMI for SMM Core or request from Communicate protocol
   //
-  if (!SmmIsBufferOutsideSmmValid 
((UINTN)gSmmCorePrivate->CommunicationBuffer, gSmmCorePrivate->BufferSize)) {
+  IsOverlapped = InternalIsBufferOverlapped (
+   (UINT8 *) gSmmCorePrivate->CommunicationBuffer,
+   gSmmCorePrivate->BufferSize,
+   (UINT8 *) gSmmCorePrivate,
+   sizeof (*gSmmCorePrivate)
+   );
+  if (!SmmIsBufferOutsideSmmValid 
((UINTN)gSmmCorePrivate->CommunicationBuffer, gSmmCorePrivate->BufferSize) || 
IsOverlapped) {
 //
-// If CommunicationBuffer is not in valid address scope, return 
EFI_INVALID_PARAMETER
+// If CommunicationBuffer is not in valid address scope,
+// or there is overlap between gSmmCorePrivate and CommunicationBuffer,
+// return EFI_INVALID_PARAMETER
 //
 gSmmCorePrivate->CommunicationBuffer = NULL;
 gSmmCorePrivate->ReturnStatus = EFI_INVALID_PARAMETER;
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH] MdeModulePkg FaultTolerantWrite: Error handling for erase operation failure

2015-08-25 Thread Star Zeng
There may be anti-flash wear out feature to forbid erase operation after end of 
dxe.
The code is missing some error handling for erase operation failure,
it should return directly after the erase operation failed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
Cc: Liming Gao 
---
 .../Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c | 16 ++--
 .../Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c | 11 ++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c
index f08f280..7a6c377 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c
@@ -3,7 +3,7 @@
   These are the common Fault Tolerant Write (FTW) functions that are shared 
   by DXE FTW driver and SMM FTW driver.
 
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2015, 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
@@ -526,6 +526,11 @@ FtwWrite (
   // Do not assume Spare Block and Target Block have same block size
   //
   Status  = FtwEraseSpareBlock (FtwDevice);
+  if (EFI_ERROR (Status)) {
+FreePool (MyBuffer);
+FreePool (SpareBuffer);
+return EFI_ABORTED;
+  }
   Ptr = MyBuffer;
   for (Index = 0; MyBufferSize > 0; Index += 1) {
 if (MyBufferSize > FtwDevice->SpareBlockSize) {
@@ -585,6 +590,10 @@ FtwWrite (
   // Restore spare backup buffer into spare block , if no failure happened 
during FtwWrite.
   //
   Status  = FtwEraseSpareBlock (FtwDevice);
+  if (EFI_ERROR (Status)) {
+FreePool (SpareBuffer);
+return EFI_ABORTED;
+  }
   Ptr = SpareBuffer;
   for (Index = 0; Index < FtwDevice->NumberOfSpareBlock; Index += 1) {
 MyLength = FtwDevice->SpareBlockSize;
@@ -706,7 +715,10 @@ FtwRestart (
   // Erase Spare block
   // This is restart, no need to keep spareblock content.
   //
-  FtwEraseSpareBlock (FtwDevice);
+  Status = FtwEraseSpareBlock (FtwDevice);
+  if (EFI_ERROR (Status)) {
+return EFI_ABORTED;
+  }
 
   DEBUG ((EFI_D_ERROR, "Ftw: Restart() success \n"));
   return EFI_SUCCESS;
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
index f3e6eac..31f1e0b 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
@@ -2,7 +2,7 @@
 
Internal functions to operate Working Block Space.
 
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2015, 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
@@ -510,6 +510,11 @@ FtwReclaimWorkSpace (
   // Write the memory buffer to spare block
   //
   Status  = FtwEraseSpareBlock (FtwDevice);
+  if (EFI_ERROR (Status)) {
+FreePool (TempBuffer);
+FreePool (SpareBuffer);
+return EFI_ABORTED;
+  }
   Ptr = TempBuffer;
   for (Index = 0; TempBufferSize > 0; Index += 1) {
 if (TempBufferSize > FtwDevice->SpareBlockSize) {
@@ -584,6 +589,10 @@ FtwReclaimWorkSpace (
   // Restore spare backup buffer into spare block , if no failure happened 
during FtwWrite.
   //
   Status  = FtwEraseSpareBlock (FtwDevice);
+  if (EFI_ERROR (Status)) {
+FreePool (SpareBuffer);
+return EFI_ABORTED;
+  }
   Ptr = SpareBuffer;
   for (Index = 0; Index < FtwDevice->NumberOfSpareBlock; Index += 1) {
 Length = FtwDevice->SpareBlockSize;
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH] Vlv2TbltDevicePkg FvbRuntimeDxe: Fix CalculateCheckSum16 input incorrect length

2015-09-11 Thread Star Zeng
The input length should be "The size, in bytes, of Buffer.",
the divide sizeof (UINT16) operation is not needed and incorrect.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
Cc: David Wei 
Cc: Tim He 
---
 Vlv2TbltDevicePkg/FvbRuntimeDxe/FvbInfo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Vlv2TbltDevicePkg/FvbRuntimeDxe/FvbInfo.c 
b/Vlv2TbltDevicePkg/FvbRuntimeDxe/FvbInfo.c
index 832e246..ad039fb 100644
--- a/Vlv2TbltDevicePkg/FvbRuntimeDxe/FvbInfo.c
+++ b/Vlv2TbltDevicePkg/FvbRuntimeDxe/FvbInfo.c
@@ -2,7 +2,7 @@
   Defines data structure that is the volume header found.
   These data is intent to decouple FVB driver with FV header.
 
-Copyright (c) 2006  - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006  - 2015, Intel Corporation. All rights reserved.



   This program and the accompanying materials are licensed and made available 
under

   the terms and conditions of the BSD License that accompanies this 
distribution.  

@@ -156,7 +156,7 @@ GetFvbInfo (
   //
   // Update the checksum value of FV header.
   //
-  FvHeader->Checksum = CalculateCheckSum16 ((UINT16 *) FvHeader, 
FvHeader->HeaderLength / sizeof (UINT16));
+  FvHeader->Checksum = CalculateCheckSum16 ((UINT16 *) FvHeader, 
FvHeader->HeaderLength);
 
   *FvbInfo = FvHeader;
 
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH] MdeModulePkg PiDxeS3BootScriptLib: Remove a hidden assumption.

2015-09-14 Thread Star Zeng
What to do:
1. Remove a hidden assumption "No SMM driver writes BootScript between
SmmReadyToLock and S3SleepEntryCallback".
 1.1. Use SmmExitBootServices and SmmLegacyBoot notification to record
  AtRuntime flag.
 1.2. Use mBootScriptDataBootTimeGuid LockBox to save boot time boot
  script data to handle potential INSERT boot script at runtime in SMM.
2. Do not depend on OS to help restore ACPINvs data and use
EfiReservedMemoryType instead of EfiACPIMemoryNVS.
 2.1. Use mBootScriptSmmPrivateDataGuid LockBox to save boot script
  SMM private data with BackFromS3 = TRUE at runtime. S3 resume
  will help restore it to tell the Library the system is back
  from S3.

Why to do:
1. The hidden assumption "No SMM driver writes BootScript between
SmmReadyToLock and S3SleepEntryCallback" will cause confusion to
the library's consumer and block the usage of "SMM driver writes
BootScript after SmmReadyToLock". So Remove the assumption.
2. In original code, there might be a corner case that malicious
code patch ACPINvs boot TableLength field same as SMM boot script.
So that it can skip the table restore. The impact is that BootScript
in SMM may be overridden by malicious code.

CopyMem ((VOID*)&TableHeader, (VOID*)mS3BootScriptTablePtr->TableBase, 
sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));
if (mS3BootScriptTablePtr->TableLength + sizeof(EFI_BOOT_SCRIPT_TERMINATE) 
!= TableHeader.TableLength) { // TableLength is in NVS
  ..
  //
  // NOTE: We should NOT use TableHeader.TableLength, because it is already 
updated to be whole length.
  //
  mS3BootScriptTablePtr->TableLength = (UINT32)(mLockBoxLength - 
sizeof(EFI_BOOT_SCRIPT_TERMINATE)); ? This line can be skipped.

So use EfiReservedMemoryType instead of EfiACPIMemoryNVS as the code
has been updated to not depend on OS to help restore ACPINvs data.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
Reviewed-by: Jiewen Yao 
---
 .../Library/PiDxeS3BootScriptLib/BootScriptSave.c  | 477 ++---
 .../PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf|   4 +-
 .../PiDxeS3BootScriptLib/InternalBootScriptLib.h   |  17 +-
 MdeModulePkg/MdeModulePkg.dec  |   8 +-
 MdeModulePkg/MdeModulePkg.uni  | Bin 183916 -> 184014 bytes
 5 files changed, 345 insertions(+), 161 deletions(-)

diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c 
b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
index 586a205..24c6798 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
@@ -19,45 +19,111 @@
 
   Data structure usage:
 
-  +--+<-- PcdS3BootScriptTablePrivateDataPtr
+  +--+<--- PcdS3BootScriptTablePrivateDataPtr
+  | SCRIPT_TABLE_PRIVATE_DATA|  (mS3BootScriptTablePtr, Before 
SmmReadyToLock)
+  |TableBase |---  
PcdS3BootScriptTablePrivateSmmDataPtr
+  |TableLength   |--|-- (mS3BootScriptTablePtr = 
mS3BootScriptTableSmmPtr, After SmmReadyToLock InSmm)
+  |TableMemoryPageNumber |--|-|
+  |AtRuntime |  | |   |
+  |InSmm |  | |   |
+  |BootTimeScriptLength  |--|-|---|---
+  |SmmLocked |  | |   |  |
+  |BackFromS3|  | |   |  |
+  +--+  | |   |  |
+| |   |  |
+  +--+<-- |   |  |
+  | EFI_BOOT_SCRIPT_TABLE_HEADER ||   |  |
+  |TableLength   ||-- |  |
+  +--+| | |  |
+  | ..   || | |  |
+  +--+< | |  |
+  | EFI_BOOT_SCRIPT_TERMINATE|  | |  |
+  +--+<-- |  |
+  |  |
+  |  |
+  mBootScriptDataBootTimeGuid LockBox:|  |
+   Used to restore data after back from S3|  |
+   to handle potential INSERT boot script |  |
+   at runtime.|  |
+  +--+|  |
+  | Boot Time Boot Script||  |
+  | Before SmmReadyToLock||  |
+  |  ||  |
+  |  ||  |
+  +--+|  |
+  | Boot Time Boot Script||  |
+  | After SmmReadyToLock InSmm   ||  |
+  |  ||  |
+  +--+<---|--|
+  |  |
+  |  |
+  mBootScriptDataGuid LockBox: (IN_PLACE) |  |
+   Used to restore data at S3 resume.   

[edk2] [PATCH] MdeModulePkg DxeCore: Relocate HOB List after other tested memory resources added

2015-09-16 Thread Star Zeng
The HOB List relocation should be at after all the tested memory resources added
(except the memory space that covers HOB List) to the memory services,
because the memory resource found in CoreInitializeMemoryServices()
may have not enough remaining resource for HOB List.

And the memory space that covers HOB List should be processed
after HOB List relocation to avoid the resources allocated by others
to corrupt HOB List before its relocation.

Cc: Jiewen Yao 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 65 +
 1 file changed, 53 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index a50fda2..77586a9 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -2311,6 +2311,7 @@ CoreInitializeGcdServices (
   UINTN  Index;
   UINT64 Capabilities;
   EFI_HOB_CPU *  CpuHob;
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR*MemorySpaceMapHobList;
 
   //
   // Cache the PHIT HOB for later use
@@ -2494,23 +2495,12 @@ CoreInitializeGcdServices (
   }
 
   //
-  // Relocate HOB List to an allocated pool buffer.
-  //
-  NewHobList = AllocateCopyPool (
- (UINTN)PhitHob->EfiFreeMemoryBottom - (UINTN)(*HobStart),
- *HobStart
- );
-  ASSERT (NewHobList != NULL);
-
-  *HobStart = NewHobList;
-  gHobList  = NewHobList;
-
-  //
   // Add and allocate the remaining unallocated system memory to the memory 
services.
   //
   Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
   ASSERT (Status == EFI_SUCCESS);
 
+  MemorySpaceMapHobList = NULL;
   for (Index = 0; Index < NumberOfDescriptors; Index++) {
 if ((MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) 
||
 (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeMoreReliable)) 
{
@@ -2520,6 +2510,16 @@ CoreInitializeGcdServices (
 if (Length == 0 || MemorySpaceMap[Index].BaseAddress + 
MemorySpaceMap[Index].Length < BaseAddress) {
   continue;
 }
+if (((UINTN) MemorySpaceMap[Index].BaseAddress <= (UINTN) (*HobStart)) 
&&
+((UINTN) (MemorySpaceMap[Index].BaseAddress + 
MemorySpaceMap[Index].Length) >= (UINTN) PhitHob->EfiFreeMemoryBottom)) {
+  //
+  // Skip the memory space that covers HOB List, it should be processed
+  // after HOB List relocation to avoid the resources allocated by 
others
+  // to corrupt HOB List before its relocation.
+  //
+  MemorySpaceMapHobList = &MemorySpaceMap[Index];
+  continue;
+}
 CoreAddMemoryDescriptor (
   EfiConventionalMemory,
   BaseAddress,
@@ -2538,6 +2538,47 @@ CoreInitializeGcdServices (
   }
 }
   }
+
+  //
+  // Relocate HOB List to an allocated pool buffer.
+  // The relocation should be at after all the tested memory resources added
+  // (except the memory space that covers HOB List) to the memory services,
+  // because the memory resource found in CoreInitializeMemoryServices()
+  // may have not enough remaining resource for HOB List.
+  //
+  NewHobList = AllocateCopyPool (
+ (UINTN) PhitHob->EfiFreeMemoryBottom - (UINTN) (*HobStart),
+ *HobStart
+ );
+  ASSERT (NewHobList != NULL);
+
+  *HobStart = NewHobList;
+  gHobList  = NewHobList;
+
+  if (MemorySpaceMapHobList != NULL) {
+//
+// Add and allocate the memory space that covers HOB List to the memory 
services
+// after HOB List relocation.
+//
+BaseAddress = PageAlignAddress (MemorySpaceMapHobList->BaseAddress);
+Length  = PageAlignLength  (MemorySpaceMapHobList->BaseAddress + 
MemorySpaceMapHobList->Length - BaseAddress);
+CoreAddMemoryDescriptor (
+  EfiConventionalMemory,
+  BaseAddress,
+  RShiftU64 (Length, EFI_PAGE_SHIFT),
+  MemorySpaceMapHobList->Capabilities & (~EFI_MEMORY_RUNTIME)
+  );
+Status = CoreAllocateMemorySpace (
+   EfiGcdAllocateAddress,
+   MemorySpaceMapHobList->GcdMemoryType,
+   0,
+   Length,
+   &BaseAddress,
+   gDxeCoreImageHandle,
+   NULL
+   );
+  }
+
   CoreFreePool (MemorySpaceMap);
 
   return EFI_SUCCESS;
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH] MdeModulePkg DxeCore: Take the range in resource HOB for PHIT as higher priority

2015-09-16 Thread Star Zeng
Take the range in the resource descriptor HOB for the memory region described
by the PHIT as higher priority if it is big enough. It can make the memory bin
allocated to be at the same memory region with PHIT that has more better 
compatibility
to avoid memory fragmentation for some code practices assume and allocate <4G 
ACPI memory.

Also let the minimal memory size needed include the total memory bin size 
needed to
make sure memory bin could be allocated successfully.

Cc: Jiewen Yao 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 161 +++-
 1 file changed, 94 insertions(+), 67 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index 77586a9..505f83b 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -2003,6 +2003,30 @@ CoreConvertResourceDescriptorHobAttributesToCapabilities 
(
   return Capabilities;
 }
 
+/**
+  Calculate total memory bin size neeeded.
+
+  @return The total memory bin size neeeded.
+
+**/
+UINT64
+CalculateTotalMemoryBinSizeNeeded (
+  VOID
+  )
+{
+  UINTN Index;
+  UINT64TotalSize;
+
+  //
+  // Loop through each memory type in the order specified by the 
gMemoryTypeInformation[] array
+  //
+  TotalSize = 0;
+  for (Index = 0; gMemoryTypeInformation[Index].Type != EfiMaxMemoryType; 
Index++) {
+TotalSize += LShiftU64 (gMemoryTypeInformation[Index].NumberOfPages, 
EFI_PAGE_SHIFT);
+  }
+
+  return TotalSize;
+}
 
 /**
   External function. Initializes memory services based on the memory
@@ -2044,7 +2068,8 @@ CoreInitializeMemoryServices (
   UINT64 TestedMemoryLength;
   EFI_PHYSICAL_ADDRESS   HighAddress;
   EFI_HOB_GUID_TYPE  *GuidHob;
-  UINT32  ReservedCodePageNumber;
+  UINT32 ReservedCodePageNumber;
+  UINT64 MinimalMemorySizeNeeded;
 
   //
   // Point at the first HOB.  This must be the PHIT HOB.
@@ -2098,9 +2123,13 @@ CoreInitializeMemoryServices (
   }
 
   //
+  // Include the total memory bin size needed to make sure memory bin could be 
allocated successfully.
+  //
+  MinimalMemorySizeNeeded = MINIMUM_INITIAL_MEMORY_SIZE + 
CalculateTotalMemoryBinSizeNeeded ();
+
+  //
   // Find the Resource Descriptor HOB that contains PHIT range 
EfiFreeMemoryBottom..EfiFreeMemoryTop
   //
-  Length = 0;
   Found  = FALSE;
   for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = 
GET_NEXT_HOB(Hob)) {
 //
@@ -2143,14 +2172,14 @@ CoreInitializeMemoryServices (
 Attributes  = PhitResourceHob->ResourceAttribute;
 BaseAddress = PageAlignAddress (PhitHob->EfiMemoryTop);
 Length  = PageAlignLength  (ResourceHob->PhysicalStart + 
ResourceHob->ResourceLength - BaseAddress);
-if (Length < MINIMUM_INITIAL_MEMORY_SIZE) {
+if (Length < MinimalMemorySizeNeeded) {
   //
   // If that range is not large enough to intialize the DXE Core, then 
   // Compute range between PHIT EfiFreeMemoryBottom and PHIT 
EfiFreeMemoryTop
   //
   BaseAddress = PageAlignAddress (PhitHob->EfiFreeMemoryBottom);
   Length  = PageAlignLength  (PhitHob->EfiFreeMemoryTop - BaseAddress);
-  if (Length < MINIMUM_INITIAL_MEMORY_SIZE) {
+  if (Length < MinimalMemorySizeNeeded) {
 //
 // If that range is not large enough to intialize the DXE Core, then 
 // Compute range between the start of the Resource Descriptor HOB and 
the start of the HOB List
@@ -2168,81 +2197,79 @@ CoreInitializeMemoryServices (
   ASSERT (Found);
 
   //
-  // Search all the resource descriptor HOBs from the highest possible 
addresses down for a memory
-  // region that is big enough to initialize the DXE core.  Always skip the 
PHIT Resource HOB.
-  // The max address must be within the physically addressible range for the 
processor.
+  // Take the range in the resource descriptor HOB for the memory region 
described
+  // by the PHIT as higher priority if it is big enough. It can make the 
memory bin
+  // allocated to be at the same memory region with PHIT that has more better 
compatibility
+  // to avoid memory fragmentation for some code practices assume and allocate 
<4G ACPI memory.
   //
-  HighAddress = MAX_ADDRESS;
-  for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = 
GET_NEXT_HOB(Hob)) {
-//
-// Skip the Resource Descriptor HOB that contains the PHIT
-//
-if (Hob.ResourceDescriptor == PhitResourceHob) {
-  continue;
-}
+  if (Length < MinimalMemorySizeNeeded) {
 //
-// Skip all HOBs except Resource Descriptor HOBs
+// Search all the resource descriptor HOBs from the highest possible 
addresses down for a memory
+// region that is big enough to initialize the DXE core.  Always skip the 
PHIT Resource HOB.
+  

[edk2] [PATCH V2] MdeModulePkg DxeCore: Take the range in resource HOB for PHIT as higher priority

2015-09-17 Thread Star Zeng
Take the range in the resource descriptor HOB for the memory region described
by the PHIT as higher priority if it is big enough. It can make the memory bin
allocated to be at the same memory region with PHIT that has more better 
compatibility
to avoid memory fragmentation for some code practices assume and allocate <4G 
ACPI memory.

Also let the minimal memory size needed include the total memory bin size 
needed to
make sure memory bin could be allocated successfully.

V2 corrects a comment in original code and a missing 
MINIMUM_INITIAL_MEMORY_SIZE updated
to MinimalMemorySizeNeeded in V1.

Cc: Jiewen Yao 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
Reviewed-by: Jiewen Yao 
---
 MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 163 +++-
 1 file changed, 95 insertions(+), 68 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index 77586a9..c276962 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -2003,6 +2003,30 @@ CoreConvertResourceDescriptorHobAttributesToCapabilities 
(
   return Capabilities;
 }
 
+/**
+  Calculate total memory bin size neeeded.
+
+  @return The total memory bin size neeeded.
+
+**/
+UINT64
+CalculateTotalMemoryBinSizeNeeded (
+  VOID
+  )
+{
+  UINTN Index;
+  UINT64TotalSize;
+
+  //
+  // Loop through each memory type in the order specified by the 
gMemoryTypeInformation[] array
+  //
+  TotalSize = 0;
+  for (Index = 0; gMemoryTypeInformation[Index].Type != EfiMaxMemoryType; 
Index++) {
+TotalSize += LShiftU64 (gMemoryTypeInformation[Index].NumberOfPages, 
EFI_PAGE_SHIFT);
+  }
+
+  return TotalSize;
+}
 
 /**
   External function. Initializes memory services based on the memory
@@ -2044,7 +2068,8 @@ CoreInitializeMemoryServices (
   UINT64 TestedMemoryLength;
   EFI_PHYSICAL_ADDRESS   HighAddress;
   EFI_HOB_GUID_TYPE  *GuidHob;
-  UINT32  ReservedCodePageNumber;
+  UINT32 ReservedCodePageNumber;
+  UINT64 MinimalMemorySizeNeeded;
 
   //
   // Point at the first HOB.  This must be the PHIT HOB.
@@ -2098,9 +2123,13 @@ CoreInitializeMemoryServices (
   }
 
   //
+  // Include the total memory bin size needed to make sure memory bin could be 
allocated successfully.
+  //
+  MinimalMemorySizeNeeded = MINIMUM_INITIAL_MEMORY_SIZE + 
CalculateTotalMemoryBinSizeNeeded ();
+
+  //
   // Find the Resource Descriptor HOB that contains PHIT range 
EfiFreeMemoryBottom..EfiFreeMemoryTop
   //
-  Length = 0;
   Found  = FALSE;
   for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = 
GET_NEXT_HOB(Hob)) {
 //
@@ -2138,19 +2167,19 @@ CoreInitializeMemoryServices (
 Found = TRUE;
 
 //
-// Compute range between PHIT EfiFreeMemoryTop and the end of the Resource 
Descriptor HOB
+// Compute range between PHIT EfiMemoryTop and the end of the Resource 
Descriptor HOB
 //
 Attributes  = PhitResourceHob->ResourceAttribute;
 BaseAddress = PageAlignAddress (PhitHob->EfiMemoryTop);
 Length  = PageAlignLength  (ResourceHob->PhysicalStart + 
ResourceHob->ResourceLength - BaseAddress);
-if (Length < MINIMUM_INITIAL_MEMORY_SIZE) {
+if (Length < MinimalMemorySizeNeeded) {
   //
   // If that range is not large enough to intialize the DXE Core, then 
   // Compute range between PHIT EfiFreeMemoryBottom and PHIT 
EfiFreeMemoryTop
   //
   BaseAddress = PageAlignAddress (PhitHob->EfiFreeMemoryBottom);
   Length  = PageAlignLength  (PhitHob->EfiFreeMemoryTop - BaseAddress);
-  if (Length < MINIMUM_INITIAL_MEMORY_SIZE) {
+  if (Length < MinimalMemorySizeNeeded) {
 //
 // If that range is not large enough to intialize the DXE Core, then 
 // Compute range between the start of the Resource Descriptor HOB and 
the start of the HOB List
@@ -2168,81 +2197,79 @@ CoreInitializeMemoryServices (
   ASSERT (Found);
 
   //
-  // Search all the resource descriptor HOBs from the highest possible 
addresses down for a memory
-  // region that is big enough to initialize the DXE core.  Always skip the 
PHIT Resource HOB.
-  // The max address must be within the physically addressible range for the 
processor.
+  // Take the range in the resource descriptor HOB for the memory region 
described
+  // by the PHIT as higher priority if it is big enough. It can make the 
memory bin
+  // allocated to be at the same memory region with PHIT that has more better 
compatibility
+  // to avoid memory fragmentation for some code practices assume and allocate 
<4G ACPI memory.
   //
-  HighAddress = MAX_ADDRESS;
-  for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = 
GET_NEXT_HOB(Hob)) {
-//
-// Skip the Resource Descriptor HOB that contains the PHIT
-//
-if (Hob.R

[edk2] [PATCH 2/2] IntelFrameworkModulePkg GenericBdsLib: Do not assume perf entry count has no change

2015-09-29 Thread Star Zeng
Current implementation assumes the performance entry count has no change from
multiple GetPerformanceMeasurement() while loops, it may cause the allocated 
buffer
for PerfEntriesAsDxeHandle at the first loop to be overflowed if the following 
loop has
the count changed.

This patch is also to sync the change at
commit R18417 "MdeModulePkg: Fix a performance data buffer overrun issue".

Cc: Ruiyu Ni 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../Library/GenericBdsLib/Performance.c| 111 ++---
 1 file changed, 33 insertions(+), 78 deletions(-)

diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c 
b/IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c
index 78039e7..e50345a 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c
@@ -168,13 +168,8 @@ WriteBootToOsPerformanceData (
   UINT64StartValue;
   UINT64EndValue;
   BOOLEAN   CountUp;
-  UINTN EntryIndex;
-  UINTN NumPerfEntries;
-  //
-  // List of flags indicating PerfEntry contains DXE handle
-  //
-  BOOLEAN   *PerfEntriesAsDxeHandle;
   UINTN VarSize;
+  BOOLEAN   Found;
 
   //
   // Record the performance data for End of BDS
@@ -203,6 +198,11 @@ WriteBootToOsPerformanceData (
 CountUp= FALSE;
   }
 
+  //
+  // Reset the entry count
+  //
+  mPerfHeader.Count = 0;
+
   if (mAcpiLowMemoryBase == 0x0) {
 VarSize = sizeof (EFI_PHYSICAL_ADDRESS);
 Status = gRT->GetVariable (
@@ -238,73 +238,10 @@ WriteBootToOsPerformanceData (
   Ptr= (UINT8 *) ((UINT32) mAcpiLowMemoryBase + sizeof (PERF_HEADER));
   LimitCount = (UINT32) (PERF_DATA_MAX_LENGTH - sizeof (PERF_HEADER)) / sizeof 
(PERF_DATA);
 
-  NumPerfEntries = 0;
-  LogEntryKey= 0;
-  while ((LogEntryKey = GetPerformanceMeasurement (
-  LogEntryKey,
-  &Handle,
-  &Token,
-  &Module,
-  &StartTicker,
-  &EndTicker)) != 0) {
-NumPerfEntries++;
-  }
-  PerfEntriesAsDxeHandle = AllocateZeroPool (NumPerfEntries * sizeof 
(BOOLEAN));
-  ASSERT (PerfEntriesAsDxeHandle != NULL);
-  
-  //
-  // Get DXE drivers performance
-  //
-  for (Index = 0; Index < NoHandles; Index++) {
-Ticker = 0;
-LogEntryKey = 0;
-EntryIndex  = 0;
-while ((LogEntryKey = GetPerformanceMeasurement (
-LogEntryKey,
-&Handle,
-&Token,
-&Module,
-&StartTicker,
-&EndTicker)) != 0) {
-  if (Handle == Handles[Index] && !PerfEntriesAsDxeHandle[EntryIndex]) {
-PerfEntriesAsDxeHandle[EntryIndex] = TRUE;
-  }
-  EntryIndex++;
-  if ((Handle == Handles[Index]) && (EndTicker != 0)) {
-if (StartTicker == 1) {
-  StartTicker = StartValue;
-}
-if (EndTicker == 1) {
-  EndTicker = StartValue;
-}
-Ticker += CountUp ? (EndTicker - StartTicker) : (StartTicker - 
EndTicker);
-  }
-}
-
-Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
-
-if (Duration > 0) {
-
-  GetNameFromHandle (Handles[Index], GaugeString);
-
-  AsciiStrCpyS (mPerfData.Token, PERF_TOKEN_SIZE, GaugeString);
-  mPerfData.Duration = Duration;
-
-  CopyMem (Ptr, &mPerfData, sizeof (PERF_DATA));
-  Ptr += sizeof (PERF_DATA);
-
-  mPerfHeader.Count++;
-  if (mPerfHeader.Count == LimitCount) {
-goto Done;
-  }
-}
-  }
-
   //
-  // Get inserted performance data
+  // Get performance data
   //
   LogEntryKey = 0;
-  EntryIndex  = 0;
   while ((LogEntryKey = GetPerformanceMeasurement (
   LogEntryKey,
   &Handle,
@@ -312,11 +249,7 @@ WriteBootToOsPerformanceData (
   &Module,
   &StartTicker,
   &EndTicker)) != 0) {
-if (!PerfEntriesAsDxeHandle[EntryIndex] && EndTicker != 0) {
-
-  ZeroMem (&mPerfData, sizeof (PERF_DATA));
-
-  AsciiStrnCpyS (mPerfData.Token, PERF_TOKEN_SIZE, Token, 
PERF_TOKEN_LENGTH);
+if (EndTicker != 0) {
   if (StartTicker == 1) {
 StartTicker = StartValue;
   }
@@ -325,7 +258,31 @@ WriteBootToOsPerformanceData (
   }
   Ticker = CountUp ? (EndTicker - StartTicker) : (StartTicker - EndTicker);
 
-  mPerfData.Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
+  Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
+  if (Duration == 0) {

[edk2] [PATCH 0/2] Do not assume perf entry count has no change

2015-09-29 Thread Star Zeng
Current implementation assumes the performance entry count has no change from
multiple GetPerformanceMeasurement() while loops, it may cause the allocated 
buffer
for PerfEntriesAsDxeHandle at the first loop to be overflowed if the following 
loop has
the count changed.

Star Zeng (2):
  MdeModulePkg UefiBootManagerLib: Do not assume perf entry count has no
change
  IntelFrameworkModulePkg GenericBdsLib: Do not assume perf entry count
has no change

 .../Library/GenericBdsLib/Performance.c| 111 ++-
 .../Library/UefiBootManagerLib/BmPerformance.c | 120 ++---
 2 files changed, 68 insertions(+), 163 deletions(-)

-- 
1.9.5.msysgit.0

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


<    1   2   3   4   5   6   7   8   9   >