[edk2] [PATCH edk2-platforms v6 0/2] add platform boot options

2018-04-25 Thread Haojian Zhuang
Changelog:
v6:
  * Remove redundant definition -- "GRUB_FILE_NAME".
v5:
  * Avoid to merge device path and grub's file path in driver.
Merge them directly in DSC file.
  * Avoid duplicated code to create boot options.
  * Use goto to handle error condition.
v4:
  * Add BootCount parameter in the interface.
v3:
  * Move in initilization of boot entry.
  * Update the name of interface in platform boot manager protocol.
v2:
  * Update with platform boot manager protocol.

Haojian Zhuang (2):
  Platform/HiKey960: register predefined boot options
  Platform/HiKey: create 4 boot options

 Platform/Hisilicon/HiKey/HiKey.dec |   8 +-
 Platform/Hisilicon/HiKey/HiKey.dsc |   7 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 169 
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  11 ++
 .../{HiKey/HiKey.dec => HiKey960/HiKey960.dec} |  17 +--
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |   6 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 170 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  11 ++
 8 files changed, 387 insertions(+), 12 deletions(-)
 copy Platform/Hisilicon/{HiKey/HiKey.dec => HiKey960/HiKey960.dec} (56%)

Cc: Laszlo Ersek 
Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
-- 
2.7.4

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


[edk2] [PATCH edk2-platforms v6 1/2] Platform/HiKey960: register predefined boot options

2018-04-25 Thread Haojian Zhuang
Create 4 boot options on HiKey960 platform. They're "Boot from SD",
"Grub", "Android Boot" and "Android Fastboot".

Cc: Laszlo Ersek 
Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dec   |  35 +
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |   6 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 170 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  11 ++
 4 files changed, 222 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960.dec

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dec 
b/Platform/Hisilicon/HiKey960/HiKey960.dec
new file mode 100644
index ..922d7199c5a5
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dec
@@ -0,0 +1,35 @@
+#
+#  Copyright (c) 2018, Linaro Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+
+[Defines]
+  DEC_SPECIFICATION  = 0x00010019
+  PACKAGE_NAME   = HiKey960
+  PACKAGE_GUID   = 1892b5b5-d18d-47a3-8fab-e3ae6b4226b0
+  PACKAGE_VERSION= 0.1
+
+
+#
+# Include Section - list of Include Paths that are provided by this package.
+#   Comments are used for Keywords and Module Types.
+#
+# Supported Module Types:
+#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
+#
+
+[Guids.common]
+  gHiKey960TokenSpaceGuid= { 0x99a14446, 0xaad7, 0xe460, {0xb4, 0xe5, 
0x1f, 0x79, 0xaa, 0xa4, 0x93, 0xfd } }
+
+[PcdsFixedAtBuild.common]
+  gHiKey960TokenSpaceGuid.PcdAndroidBootDevicePath|L""|VOID*|0x0001
+  gHiKey960TokenSpaceGuid.PcdAndroidBootFile|{ 0x36, 0x8b, 0x73, 0x3a, 0xc5, 
0xb9, 0x63, 0x47, 0xab, 0xbd, 0x6c, 0xbd, 0x4b, 0x25, 0xf9, 0xff 
}|VOID*|0x0002
+  gHiKey960TokenSpaceGuid.PcdAndroidFastbootFile|{ 0x2a, 0x50, 0x88, 0x95, 
0x70, 0x53, 0xe3, 0x11, 0x86, 0x31, 0xd7, 0xc5, 0x95, 0x13, 0x64, 0xc8 
}|VOID*|0x0003
+  gHiKey960TokenSpaceGuid.PcdSdBootDevicePath|L""|VOID*|0x0004
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 859ab84f8415..4097fbfd77f5 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -132,6 +132,12 @@ [PcdsFixedAtBuild.common]
   gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbVendorId|0x18d1
   gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbProductId|0xd00d
 
+  #
+  # Android Loader
+  #
+  
gHiKey960TokenSpaceGuid.PcdAndroidBootDevicePath|L"VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,3BFF00)/UFS(0x0,0x3)/HD(7,GPT,D3340696-9B95-4C64-8DF6-E6D4548FBA41,0x12100,0x4000)/\\EFI\\BOOT\\GRUBAA64.EFI"
+  
gHiKey960TokenSpaceGuid.PcdSdBootDevicePath|L"VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,00F037FF00)/SD(0x0)"
+
 

 #
 # Components Section - list of all EDK II Modules needed by this Platform
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
index 473d61ed384e..b6a88daf4f99 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
@@ -30,10 +30,16 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include 
 
 #define ADC_ADCIN0   0
@@ -86,6 +92,8 @@
 
 #define DETECT_SW_FASTBOOT   68// GPIO8_4
 
+#define HIKEY960_BOOT_OPTION_NUM 4
+
 typedef struct {
   UINT64Magic;
   UINT64Data;
@@ -359,6 +367,158 @@ OnEndOfDxe (
   }
 }
 
+STATIC
+EFI_STATUS
+CreatePlatformBootOptionFromPath (
+  IN CHAR16  *PathStr,
+  IN CHAR16  *Description,
+  IN OUT EFI_BOOT_MANAGER_LOAD_OPTION*BootOption
+  )
+{
+  EFI_STATUS   Status;
+  EFI_DEVICE_PATH  *DevicePath;
+
+  DevicePath = (EFI_DEVICE_PATH *)ConvertTextToDevicePath (PathStr);
+  ASSERT (DevicePath != NULL);
+  Status = EfiBootManagerInitializeLoadOption (
+ BootOption,
+ 

[edk2] [PATCH edk2-platforms v6 2/2] Platform/HiKey: create 4 boot options

2018-04-25 Thread Haojian Zhuang
Create 4 predefined boot options for HiKey. They're
"Boot from SD", "Grub", "Android Boot" and "Android Fastboot".

Cc: Laszlo Ersek 
Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dec |   8 +-
 Platform/Hisilicon/HiKey/HiKey.dsc |   7 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 169 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  11 ++
 4 files changed, 192 insertions(+), 3 deletions(-)

diff --git a/Platform/Hisilicon/HiKey/HiKey.dec 
b/Platform/Hisilicon/HiKey/HiKey.dec
index 537138eb45a1..bb94c5cab13f 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dec
+++ b/Platform/Hisilicon/HiKey/HiKey.dec
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
+#  Copyright (c) 2014-2018, Linaro Limited. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -32,5 +32,7 @@ [Guids.common]
   gHiKeyTokenSpaceGuid  =  { 0x91148425, 0xcdd2, 0x4830, { 0x8b, 0xd0, 
0xc6, 0x1c, 0x6d, 0xea, 0x36, 0x21 } }
 
 [PcdsFixedAtBuild.common]
-  gHiKeyTokenSpaceGuid.PcdAndroidFastbootNvmDevicePath|L""|VOID*|0x0001
-  gHiKeyTokenSpaceGuid.PcdArmFastbootFlashLimit|L""|VOID*|0x0002
+  gHiKeyTokenSpaceGuid.PcdAndroidBootDevicePath|L""|VOID*|0x0001
+  gHiKeyTokenSpaceGuid.PcdAndroidBootFile|{ 0x36, 0x8b, 0x73, 0x3a, 0xc5, 
0xb9, 0x63, 0x47, 0xab, 0xbd, 0x6c, 0xbd, 0x4b, 0x25, 0xf9, 0xff 
}|VOID*|0x0002
+  gHiKeyTokenSpaceGuid.PcdAndroidFastbootFile|{ 0x2a, 0x50, 0x88, 0x95, 0x70, 
0x53, 0xe3, 0x11, 0x86, 0x31, 0xd7, 0xc5, 0x95, 0x13, 0x64, 0xc8 
}|VOID*|0x0003
+  gHiKeyTokenSpaceGuid.PcdSdBootDevicePath|L""|VOID*|0x0004
diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 83dd68a820b1..9c1fc2e1b40d 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -138,6 +138,13 @@ [PcdsFixedAtBuild.common]
   gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbVendorId|0x18d1
   gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbProductId|0xd00d
 
+  #
+  # Android Loader
+  #
+  
gHiKeyTokenSpaceGuid.PcdAndroidBootDevicePath|L"VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,00D023F700)/eMMC(0x0)/Ctrl(0x0)/HD(6,GPT,5C0F213C-17E1-4149-88C8-8B50FB4EC70E,0x7000,0x2)/\\EFI\\BOOT\\GRUBAA64.EFI"
+  
gHiKeyTokenSpaceGuid.PcdSdBootDevicePath|L"VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,00E023F700)/SD(0x0)"
+
+
 

 #
 # Components Section - list of all EDK II Modules needed by this Platform
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
index 65e800116b76..fec43f3fb4c1 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
@@ -18,12 +18,18 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -42,6 +48,7 @@
 #define ADB_REBOOT_BOOTLOADER0x77665500
 #define ADB_REBOOT_NONE  0x77665501
 
+#define HIKEY_BOOT_OPTION_NUM4
 
 typedef struct {
   UINT64Magic;
@@ -121,6 +128,158 @@ HiKeyInitPeripherals (
   return EFI_SUCCESS;
 }
 
+STATIC
+EFI_STATUS
+CreatePlatformBootOptionFromPath (
+  IN CHAR16  *PathStr,
+  IN CHAR16  *Description,
+  IN OUT EFI_BOOT_MANAGER_LOAD_OPTION*BootOption
+  )
+{
+  EFI_STATUS   Status;
+  EFI_DEVICE_PATH  *DevicePath;
+
+  DevicePath = (EFI_DEVICE_PATH *)ConvertTextToDevicePath (PathStr);
+  ASSERT (DevicePath != NULL);
+  Status = EfiBootManagerInitializeLoadOption (
+ BootOption,
+ LoadOptionNumberUnassigned,
+ LoadOptionTypeBoot,
+ LOAD_OPTION_ACTIVE,
+ Description,
+ DevicePath,
+ NULL,
+ 0
+ );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  FreePool (DevicePath);
+  return Status;
+}
+
+STATIC
+EFI_STATUS
+CreatePlatformBootOptionFromGuid (
+  IN EFI_GUID*FileGuid,
+  IN CHAR16  *Description,
+  IN OUT EFI_BOOT_MANAGER_LOAD_OPTION*BootOption
+  )
+{
+  EFI_STATUS Status;
+  EFI_DEVICE_PATH*DevicePath;
+  EFI_DEVICE_PATH*TempDevicePath;
+  EFI_LOADED_IMAGE_PROTOCOL  *LoadedImage;
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  FileNode;
+
+  Status = gBS->HandleProtocol (
+  gImageHandle,
+ 

Re: [edk2] [PATCH edk2-platforms v5 0/2] add platform boot options

2018-04-25 Thread Haojian Zhuang
On 26 April 2018 at 00:10, Laszlo Ersek  wrote:
> Hello Haojian,
>
> On 04/25/18 06:59, Haojian Zhuang wrote:
>> Changelog:
>> v5:
>>   * Avoid to merge device path and grub's file path in driver.
>> Merge them directly in DSC file.
>>   * Avoid duplicated code to create boot options.
>>   * Use goto to handle error condition.
>> v4:
>>   * Add BootCount parameter in the interface.
>> v3:
>>   * Move in initilization of boot entry.
>>   * Update the name of interface in platform boot manager protocol.
>> v2:
>>   * Update with platform boot manager protocol.
>>
>> Haojian Zhuang (2):
>>   Platform/HiKey960: register predefined boot options
>>   Platform/HiKey: create 4 boot options
>>
>>  Platform/Hisilicon/HiKey/HiKey.dec |   8 +-
>>  Platform/Hisilicon/HiKey/HiKey.dsc |   7 +
>>  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 171 
>> 
>>  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  11 ++
>>  .../{HiKey/HiKey.dec => HiKey960/HiKey960.dec} |  17 +-
>>  Platform/Hisilicon/HiKey960/HiKey960.dsc   |   6 +
>>  .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 172 
>> +
>>  .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  11 ++
>>  8 files changed, 391 insertions(+), 12 deletions(-)
>>  copy Platform/Hisilicon/{HiKey/HiKey.dec => HiKey960/HiKey960.dec} (56%)
>>
>
> (1) in the future, please CC the blurb -- patch 0/xxx -- to everyone who
> are CC'd on any of the patches. What I usually do is:
>
> - format all the patches
> - grep them for '^Cc:'
> - sort the resultant list uniquely
> - paste the output into the blurb message
>
> This way, if a person is CC'd at least on one of the patches in the
> series, they will receive a copy of the cover letter too.
>
OK

>
> (2) As of commit b581a4934d8f ("ARM/JunoPkg: Add HDLCD platform
> library", 2018-04-23), I cannot find HiKeyDxe or HiKey960Dxe in the
> edk2-platforms tree. That's not a problem, it just means that I cannot
> verify the resource management / error handling in the
> HiKey960EntryPoint() and HiKeyEntryPoint() functions. For this reason, I
> cannot give R-b, just A-b. I hope that will suffice -- please do not
> repost because of this.
>

Yes, it's depend on another patch series on virtual keyboard.

>
> (3) The GRUB_FILE_NAME macro is now superfluous in both of the patches.
> Again, it's not necessary for me to review the series just because of
> such an update. Perhaps Leif or Ard can remove the macro defs for you
> when they push the patches.
>

OK. I'll remove it.

>
> (4) In both patches, in both of the CreatePlatformBootOptionFromPath()
> and CreatePlatformBootOptionFromGuid() helper functions, the
> "DevicePath" variable is leaked when
> EfiBootManagerInitializeLoadOption() fails.
>
> "DevicePath" should be freed unconditionally at that point, in both
> patches and in both helper functions (4 instances in total). Simply
> eliminate the following:
>
>   if (EFI_ERROR (Status)) {
> return Status;
>   }
>
> and you will be left with:
>
>   Status = EfiBootManagerInitializeLoadOption (
>  ...
>  );
>   FreePool (DevicePath);
>   return Status;
>
> I believe I need not separately review this update either.
>

For this one, I have a different opinion.

EFI_STATUS
EFIAPI
EfiBootManagerInitializeLoadOption (
  ...
  )
{
  if ((Option == NULL) || (Description == NULL) || (FilePath == NULL)) {
return EFI_INVALID_PARAMETER;
  }

  if (((OptionalData != NULL) && (OptionalDataSize == 0)) ||
  ((OptionalData == NULL) && (OptionalDataSize != 0))) {
return EFI_INVALID_PARAMETER;
  }
  if ((UINT32) OptionType >= LoadOptionTypeMax) {
return EFI_INVALID_PARAMETER;
  }

  ZeroMem (Option, sizeof (EFI_BOOT_MANAGER_LOAD_OPTION));
  Option->OptionNumber   = OptionNumber;
  Option->OptionType = OptionType;
  Option->Attributes = Attributes;
  Option->Description= AllocateCopyPool (StrSize
(Description), Description);
  Option->FilePath   = DuplicateDevicePath (FilePath);
  if (OptionalData != NULL) {
Option->OptionalData = AllocateCopyPool (OptionalDataSize,
OptionalData);
Option->OptionalDataSize = OptionalDataSize;
  }

  return EFI_SUCCESS;
}

We can find that no memory is allocated to "DevicePath" if it returns
with error.

So we shouldn't free memory on "DevicePath" if "Status" is error code.

Other issues will be fixed in v6.

>
> With (3) and (4) addressed, for the series:
>
> Acked-by: Laszlo Ersek 
>

Thanks a lot.

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


[edk2] [EDK2]How to do source level debug (OVMF & QEMU & Intel UEFI Development Debugger Tool)

2018-04-25 Thread krishnaLee
Hi everyone,
I know nothing about this source level debug mode so I had read some articles 
and  tried to make this environment,but failed.
I do this as I want to observe how SEC phase jump to PEI phase. 


#1 build ovmf:
build -p OvmfPkg/OvmfPkgIa32.dsc -a IA32 -D DEBUG_ON_SERIAL_PORT -D 
SOURCE_DEBUG_ENABLE
#2 run it alone,ok
qemu-system-x86_64.exe -machine pc-q35-2.9 -pflash OVMF32-source-debug.fd 
-serial stdio 
#3 redirect serial to tcp,it hints "info: QEMU waiting for connection on: 
disconnected:tcp:::1:1234,server"
qemu-system-x86_64.exe -machine pc-q35-2.9 -pflash OVMF32_source_debug.fd 
-serial tcp:localhost:1234,server
#4,execute "C:\Program Files (x86)\Intel\Intel(R) UEFI Development Kit Debugger 
Tool\eXdi.exe" /LaunchWinDbg" with follow settings,but failed connect to qemu.
# error message box"Unable to open TCP address(localhost:1234):No connection 
could be made because the target machine actively refused it"
[Debug Port]
Channel = TCP
Server = localhost
Port = 1234


I also tried using pipe and com port, all can't connect to qemu,it is very 
appreciate if anyone could give any baby steps...


# other information:
my windows:win10 x64
QEMU version:2.10
UDK2017
Microsoft (R) Windows Debugger Version 6.12.0002.633 X86(install by default 
settings)
Intel UEFI Development Debugger Tool 1.5(install by default settings)




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


[edk2] [PATCH] MdeModulePkg/PciHostBridge: Count the (mm)io overhead when polling

2018-04-25 Thread Ruiyu Ni
RootBridgeIo.PollMem()/PollIo() originally don't count the IO/MMIO
access overhead when delaying.
The patch changes the implementation to count the access overhead
so that the actually delay equals to user required delay.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Star Zeng 
Cc: Chasel Chiu 
---
 .../Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf  |   3 +-
 .../Bus/Pci/PciHostBridgeDxe/PciRootBridge.h   |   3 +-
 .../Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 151 +++--
 3 files changed, 115 insertions(+), 42 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf 
b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
index 42bd8a23cb..2e56959a8f 100644
--- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
+++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
@@ -1,7 +1,7 @@
 ## @file
 #   Generic PCI Host Bridge driver.
 #
-#  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+#  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -43,6 +43,7 @@ [LibraryClasses]
   PciSegmentLib
   UefiLib
   PciHostBridgeLib
+  TimerLib
 
 [Protocols]
   gEfiMetronomeArchProtocolGuid   ## CONSUMES
diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h 
b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h
index d3dfb57fc6..e2f651aee4 100644
--- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h
+++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h
@@ -2,7 +2,7 @@
 
   The PCI Root Bridge header file.
 
-Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -36,6 +36,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
+#include 
 #include "PciHostResource.h"
 
 
diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c 
b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c
index 5764c2f49f..459e962fe7 100644
--- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c
+++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c
@@ -2,7 +2,7 @@
 
   PCI Root Bridge Io Protocol code.
 
-Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -468,6 +468,85 @@ RootBridgeIoGetMemTranslationByAddress (
   return EFI_SUCCESS;
 }
 
+/**
+  Return the result of (Multiplicand * Multiplier / Divisor).
+
+  @param Multiplicand A 64-bit unsigned value.
+  @param Multiplier   A 64-bit unsigned value.
+  @param Divisor  A 32-bit unsigned value.
+  @param RemainderA pointer to a 32-bit unsigned value. This parameter is
+  optional and may be NULL.
+
+  @return Multiplicand * Multiplier / Divisor.
+**/
+UINT64
+MultThenDivU64x64x32 (
+  IN  UINT64Multiplicand,
+  IN  UINT64Multiplier,
+  IN  UINT32Divisor,
+  OUT UINT32*Remainder  OPTIONAL
+  )
+{
+  UINT64Uint64;
+  UINT32LocalRemainder;
+  UINT32Uint32;
+  if (Multiplicand >= DivU64x64Remainder (MAX_UINT64, Multiplier, NULL)) {
+//
+// Make sure Multiplicand is the bigger one.
+//
+if (Multiplicand < Multiplier) {
+  Uint64   = Multiplicand;
+  Multiplicand = Multiplier;
+  Multiplier   = Uint64;
+}
+//
+// Because Multiplicand * Multiplier overflows,
+//   Multiplicand * Multiplier / Divisor
+// = (2 * Multiplicand' + 1) * Multiplier / Divisor
+// = 2 * (Multiplicand' * Multiplier / Divisor) + Multiplier / Divisor
+//
+Uint64 = MultThenDivU64x64x32 (RShiftU64 (Multiplicand, 1), Multiplier, 
Divisor, );
+Uint64 = LShiftU64 (Uint64, 1);
+Uint32 = 0;
+if ((Multiplicand & 0x1) == 1) {
+  Uint64 += DivU64x32Remainder (Multiplier, Divisor, );
+}
+return Uint64 + DivU64x32Remainder (Uint32 + LShiftU64 (LocalRemainder, 
1), Divisor, Remainder);
+  } else {
+return DivU64x32Remainder (MultU64x64 (Multiplicand, Multiplier), Divisor, 
Remainder);
+  }
+}
+
+/**
+  Return the elapsed tick count from CurrentTick.
+
+  @param  CurrentTick  On 

Re: [edk2] [PATCH] CryptoPkg/OpensslLib: remove OpenSSL version number from OpenSSL-HOWTO.txt

2018-04-25 Thread Long, Qin
Yes, this was not refreshed at last upgrade. And I agree it's better to remove 
this statement.

Reviewed-by: Long Qin 


Best Regards & Thanks,
LONG, Qin

-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Thursday, April 26, 2018 1:58 AM
To: edk2-devel-01 
Cc: Long, Qin ; Ye, Ting 
Subject: [PATCH] CryptoPkg/OpensslLib: remove OpenSSL version number from 
OpenSSL-HOWTO.txt

Remove any concrete OpenSSL version numbers from "OpenSSL-HOWTO.txt". That 
information is out of date and there's no reason for us to refresh it:

We now track stable OpenSSL releases via a git submodule. CryptoPkg maintainers 
push such submodule updates to edk2 that identify the correct stable releases 
of OpenSSL. "OpenSSL-HOWTO.txt" already provides instructions to users for 
updating their local submodules.

Cc: Qin Long 
Cc: Ting Ye 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek 
---
 CryptoPkg/Library/OpensslLib/OpenSSL-HOWTO.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/CryptoPkg/Library/OpensslLib/OpenSSL-HOWTO.txt 
b/CryptoPkg/Library/OpensslLib/OpenSSL-HOWTO.txt
index 36f8e711dda3..db45eb88d17a 100644
--- a/CryptoPkg/Library/OpensslLib/OpenSSL-HOWTO.txt
+++ b/CryptoPkg/Library/OpensslLib/OpenSSL-HOWTO.txt
@@ -18,7 +18,6 @@ on the cryptography.
  OpenSSL-Version  
=
   EDKII supports building with the latest release of OpenSSL.
-  The latest official release is OpenSSL-1.1.0g (Released at 2017-Nov-02).
   NOTE: Only latest release version was fully validated.
 And no guarantees on build & functionality if using other versions.
 
--
2.14.1.3.gb7cf6e02401b

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


Re: [edk2] Incorrect Author on patch

2018-04-25 Thread Laszlo Ersek
On 04/25/18 17:02, Evan Lloyd wrote:
> Hi Ruiyu.
> When we look at the edk2 git log, or GitHub 
> https://github.com/tianocore/edk2/commit/ee4dc24f57c32a445e7c747396c9bfbd8b221568
> we see that Sami's AcpiView patch shows you as the Author.
> I'm not sure what might have caused that (and it is obviously accidental), 
> but it is a little unfortunate in that the commit doesn't show up on Sami's 
> GitHub stats.
> Fortunately, this is not currently significant for our organisation, although 
> I'm sure Sami would prefer to have the credit.
> This is a trivial matter, but you may wish to understand what caused it so 
> that you don't accidentally upset someone for whom the stats are significant.

Right, this occurred at least one other time as well: see commit
8b5c80e0296c ("MdeModulePkg/UefiBootManagerLib: fix
AddLoadOptionVariable docs/prototype", 2018-04-23). Ray pushed the patch
(so the Committer field is certainly right), but Ray's name+email
replaced mine in the Author field. I had noticed that earlier, but now
I'm seeing it as a pattern.

I believe this is a tooling issue. I notice the following bit on the
commit message:

Change-Id: I8a609d6502b6f8929b2f568acaa147065003b6f4

I certainly didn't post the patch with that, and I doubt Ray added it
manually. So, whatever tool Ray used to handle the patch lost the
authorship information.

And, I see the exact same kind of tag, namely

Change-Id: Ifa23dc80ab8ab042c56e88424847e796a8122a7c

on commit ee4dc24f57c3 ("ShellPkg: Add acpiview tool to dump ACPI
tables", 2018-04-23), which you mention.

... In fact, my patch happens to be the direct ancestor of Sami's, in
the git history, and their commit times are just ~3 minutes apart. I'm
quite certain Ray has started using a new tool.

For example, commit bc2288f59ba2 ("UefiCpuPkg/MpInitLib: put
mReservedApLoopFunc in executable memory", 2018-03-08) was also
committed by Ray, *but* Jian's authorship was preserved fine. (No
"Change-Id" either.)

... Oh... it looks like those Change-Id's were added by Gerrit:

https://git.eclipse.org/r/Documentation/user-changeid.html

And then, please look at this:

https://gerrit-review.googlesource.com/Documentation/error-invalid-author.html

For every pushed commit Gerrit verifies that the e-mail address of
the author matches one of the registered e-mail addresses of the
pushing user. If this is not the case pushing the commit fails with
the error message "invalid author". This policy can be bypassed by
having the access right 'Forge Author'.

Uh, what?... Gerrit says "invalid author" if Ray pushes a patch that
wasn't authored by himself? And the option to override that is called
"forge" author? O_o

Anyway, the page continues,

If pushing to Gerrit fails with the error message "invalid author"
and somebody else is author of the commit for which the push fails,
then you have no permissions to forge the author identity. In this
case you may contact the project owner to request the access right
'+1 Forge Author Identity' in the 'Forge Identity' category or ask
the maintainer to commit this change on the author’s behalf.

Ray, if you absolutely must use Gerrit, please make sure that you have
the '+1 Forge Author Identity' access right. IMO, we maintainers are
responsible for preserving git metadata the best we can.

(For example, if a patch is applied from the mailing list with "git am",
it preserves the authorship information -- the documentation says, 'The
commit author name is taken from the "From: " line of the message, and
commit author date is taken from the "Date: " line of the message.')

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


Re: [edk2] [PATCH] QemuVideoDxe: round up FrameBufferSize to full page

2018-04-25 Thread Laszlo Ersek
On 04/25/18 16:08, Laszlo Ersek wrote:

> (1) Please use the EFI_SIZE_TO_PAGES() macro for rounding up the size.
> 
> (EFI_SIZE_TO_PAGES() takes one UINTN argument, but there's no need for
> an explicit cast, because
> "EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.FrameBufferSize" is already UINTN.)

Argh, this request was incomplete. I meant to say:

* Please use EFI_SIZE_TO_PAGES() *with* EFI_PAGES_TO_SIZE() to round up
  the value -- this is a pattern we use in edk2 quite a bit, see:

  git grep -w -e EFI_PAGES_TO_SIZE --and -e EFI_SIZE_TO_PAGES

(ALIGN_VALUE(), EFI_PAGE_SIZE, EFI_PAGE_MASK etc are also OK to use, but
they generally require casting even the constants to UINTN first --
because those are genuinely "int", i.e. INT32 --, and the casting is
arguably uglier than the above-proposed pattern, where the size that we
start out with is already UINTN.)

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


[edk2] [PATCH] CryptoPkg/OpensslLib: remove OpenSSL version number from OpenSSL-HOWTO.txt

2018-04-25 Thread Laszlo Ersek
Remove any concrete OpenSSL version numbers from "OpenSSL-HOWTO.txt". That
information is out of date and there's no reason for us to refresh it:

We now track stable OpenSSL releases via a git submodule. CryptoPkg
maintainers push such submodule updates to edk2 that identify the correct
stable releases of OpenSSL. "OpenSSL-HOWTO.txt" already provides
instructions to users for updating their local submodules.

Cc: Qin Long 
Cc: Ting Ye 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek 
---
 CryptoPkg/Library/OpensslLib/OpenSSL-HOWTO.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/CryptoPkg/Library/OpensslLib/OpenSSL-HOWTO.txt 
b/CryptoPkg/Library/OpensslLib/OpenSSL-HOWTO.txt
index 36f8e711dda3..db45eb88d17a 100644
--- a/CryptoPkg/Library/OpensslLib/OpenSSL-HOWTO.txt
+++ b/CryptoPkg/Library/OpensslLib/OpenSSL-HOWTO.txt
@@ -18,7 +18,6 @@ on the cryptography.
  OpenSSL-Version
 =
   EDKII supports building with the latest release of OpenSSL.
-  The latest official release is OpenSSL-1.1.0g (Released at 2017-Nov-02).
   NOTE: Only latest release version was fully validated.
 And no guarantees on build & functionality if using other versions.
 
-- 
2.14.1.3.gb7cf6e02401b

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


Re: [edk2] [PATCH 0/2] Reenable timer mask quirk for Xen

2018-04-25 Thread Julien Grall

Hi Ard,

Thank you for the series, I confirm it fixes EDK2 boot in Xen guest.

Tested-by: Julien Grall 
Acked-by: Julien Grall 

Cheers,

On 23/04/18 16:00, Ard Biesheuvel wrote:

Reinstate the timer mask quirk for Xen that we recently removed under the
assumption that only ancient KVM host implementations still needed it.

Ard Biesheuvel (2):
   ArmPkg: add reenable hook to ArmGenericTimerCounterLib
   ArmVirtPkg: reinstate timer unmask quirk for Xen

  ArmPkg/Drivers/TimerDxe/TimerDxe.c|   1 +
  .../Library/ArmGenericTimerCounterLib.h   |   6 +
  .../ArmGenericTimerPhyCounterLib.c|   8 +
  .../ArmGenericTimerVirtCounterLib.c   |   8 +
  ArmVirtPkg/ArmVirtXen.dsc |   1 +
  .../XenArmGenericTimerVirtCounterLib.c| 146 ++
  .../XenArmGenericTimerVirtCounterLib.inf  |  33 
  7 files changed, 203 insertions(+)
  create mode 100644 
ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.c
  create mode 100644 
ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf



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


Re: [edk2] [PATCH edk2-platforms v5 0/2] add platform boot options

2018-04-25 Thread Laszlo Ersek
Hello Haojian,

On 04/25/18 06:59, Haojian Zhuang wrote:
> Changelog:
> v5:
>   * Avoid to merge device path and grub's file path in driver.
> Merge them directly in DSC file.
>   * Avoid duplicated code to create boot options.
>   * Use goto to handle error condition.
> v4:
>   * Add BootCount parameter in the interface.
> v3:
>   * Move in initilization of boot entry.
>   * Update the name of interface in platform boot manager protocol.
> v2:
>   * Update with platform boot manager protocol.
> 
> Haojian Zhuang (2):
>   Platform/HiKey960: register predefined boot options
>   Platform/HiKey: create 4 boot options
> 
>  Platform/Hisilicon/HiKey/HiKey.dec |   8 +-
>  Platform/Hisilicon/HiKey/HiKey.dsc |   7 +
>  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 171 
>  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  11 ++
>  .../{HiKey/HiKey.dec => HiKey960/HiKey960.dec} |  17 +-
>  Platform/Hisilicon/HiKey960/HiKey960.dsc   |   6 +
>  .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 172 
> +
>  .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  11 ++
>  8 files changed, 391 insertions(+), 12 deletions(-)
>  copy Platform/Hisilicon/{HiKey/HiKey.dec => HiKey960/HiKey960.dec} (56%)
> 

(1) in the future, please CC the blurb -- patch 0/xxx -- to everyone who
are CC'd on any of the patches. What I usually do is:

- format all the patches
- grep them for '^Cc:'
- sort the resultant list uniquely
- paste the output into the blurb message

This way, if a person is CC'd at least on one of the patches in the
series, they will receive a copy of the cover letter too.


(2) As of commit b581a4934d8f ("ARM/JunoPkg: Add HDLCD platform
library", 2018-04-23), I cannot find HiKeyDxe or HiKey960Dxe in the
edk2-platforms tree. That's not a problem, it just means that I cannot
verify the resource management / error handling in the
HiKey960EntryPoint() and HiKeyEntryPoint() functions. For this reason, I
cannot give R-b, just A-b. I hope that will suffice -- please do not
repost because of this.


(3) The GRUB_FILE_NAME macro is now superfluous in both of the patches.
Again, it's not necessary for me to review the series just because of
such an update. Perhaps Leif or Ard can remove the macro defs for you
when they push the patches.


(4) In both patches, in both of the CreatePlatformBootOptionFromPath()
and CreatePlatformBootOptionFromGuid() helper functions, the
"DevicePath" variable is leaked when
EfiBootManagerInitializeLoadOption() fails.

"DevicePath" should be freed unconditionally at that point, in both
patches and in both helper functions (4 instances in total). Simply
eliminate the following:

  if (EFI_ERROR (Status)) {
return Status;
  }

and you will be left with:

  Status = EfiBootManagerInitializeLoadOption (
 ...
 );
  FreePool (DevicePath);
  return Status;

I believe I need not separately review this update either.


With (3) and (4) addressed, for the series:

Acked-by: Laszlo Ersek 

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


[edk2] Incorrect Author on patch

2018-04-25 Thread Evan Lloyd
Hi Ruiyu.
When we look at the edk2 git log, or GitHub 
https://github.com/tianocore/edk2/commit/ee4dc24f57c32a445e7c747396c9bfbd8b221568
we see that Sami's AcpiView patch shows you as the Author.
I'm not sure what might have caused that (and it is obviously accidental), but 
it is a little unfortunate in that the commit doesn't show up on Sami's GitHub 
stats.
Fortunately, this is not currently significant for our organisation, although 
I'm sure Sami would prefer to have the credit.
This is a trivial matter, but you may wish to understand what caused it so that 
you don't accidentally upset someone for whom the stats are significant.

Regards,
Evan



Evan Lloyd | Technical Lead for Windows on Arm | Arm
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
m. +44 (0)7825256132
110 Fulbourn Road, Cambridge, CB1 9NJ
Arm.com

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


Re: [edk2] [PATCH v1 10/18] StandaloneMmPkg/HobLib: Add AARCH64 Specific HOB Library for management mode.

2018-04-25 Thread Achin Gupta
Hi Supreeth,

On Fri, Apr 06, 2018 at 03:42:15PM +0100, Supreeth Venkatesh wrote:
> The Standalone MM environment is initialized during the SEC phase on ARM
> Standard Platforms. The MM Core driver implements an entry point module
> which is architecture specific and runs prior to the generic core driver
> code. The former creates a Hob list that the latter consumes. This
> happens in the same phase.
> 
> This patch implements a Hob library that can be used by the entry point
> module to produce a Hob list and by the core driver code to consume it.

References to DXE core need to be removed and the copyright years needs to be
updated.

I think it is worth getting this hoblib reviewed by the ArmPkg maintainers. 

Acked-by: Achin Gupta 

> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Achin Gupta 
> Signed-off-by: Supreeth Venkatesh 
> ---
>  StandaloneMmPkg/Library/HobLib/Arm/HobLib.c | 697 
> 
>  StandaloneMmPkg/Library/HobLib/HobLib.inf   |  45 ++
>  2 files changed, 742 insertions(+)
>  create mode 100644 StandaloneMmPkg/Library/HobLib/Arm/HobLib.c
>  create mode 100644 StandaloneMmPkg/Library/HobLib/HobLib.inf
> 
> diff --git a/StandaloneMmPkg/Library/HobLib/Arm/HobLib.c 
> b/StandaloneMmPkg/Library/HobLib/Arm/HobLib.c
> new file mode 100644
> index 00..62abf47f95
> --- /dev/null
> +++ b/StandaloneMmPkg/Library/HobLib/Arm/HobLib.c
> @@ -0,0 +1,697 @@
> +/** @file
> +  HOB Library implementation for DxeCore driver.
> +
> +Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
> +Copyright (c) 2017, ARM Limited. All rights reserved.
> +
> +This program and the accompanying materials
> +are licensed and made available under the terms and conditions of the BSD 
> License
> +which accompanies this distribution.  The full text of the license may be 
> found at
> +http://opensource.org/licenses/bsd-license.php.
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +//
> +// Cache copy of HobList pointer.
> +//
> +VOID *gHobList = NULL;
> +
> +/**
> +  Returns the pointer to the HOB list.
> +
> +  This function returns the pointer to first HOB in the list.
> +  For PEI phase, the PEI service GetHobList() can be used to retrieve the 
> pointer
> +  to the HOB list.  For the DXE phase, the HOB list pointer can be retrieved 
> through
> +  the EFI System Table by looking up theHOB list GUID in the System 
> Configuration Table.
> +  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().
> +
> +  @return The pointer to the HOB list.
> +
> +**/
> +VOID *
> +EFIAPI
> +GetHobList (
> +  VOID
> +  )
> +{
> +  ASSERT (gHobList != NULL);
> +  return gHobList;
> +}
> +
> +/**
> +  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.
> +  If there does not exist such HOB type from the starting HOB pointer, it 
> will return NULL.
> +  In contrast with macro GET_NEXT_HOB(), this function does not skip the 
> starting HOB pointer
> +  unconditionally: it returns HobStart back if HobStart itself meets the 
> requirement;
> +  caller is required to use GET_NEXT_HOB() if it wishes to skip current 
> HobStart.
> +
> +  If HobStart is NULL, then ASSERT().
> +
> +  @param  Type  The HOB type to return.
> +  @param  HobStart  The starting HOB pointer to search from.
> +
> +  @return The next instance of a HOB type from the starting HOB.
> +
> +**/
> +VOID *
> +EFIAPI
> +GetNextHob (
> +  IN UINT16 Type,
> +  IN CONST VOID *HobStart
> +  )
> +{
> +  EFI_PEI_HOB_POINTERS  Hob;
> +
> +  ASSERT (HobStart != NULL);
> +
> +  Hob.Raw = (UINT8 *) HobStart;
> +  //
> +  // Parse the HOB list until end of list or matching type is found.
> +  //
> +  while (!END_OF_HOB_LIST (Hob)) {
> +if (Hob.Header->HobType == Type) {
> +  return Hob.Raw;
> +}
> +Hob.Raw = GET_NEXT_HOB (Hob);
> +  }
> +  return NULL;
> +}
> +
> +/**
> +  Returns the first instance of a HOB type among the whole HOB list.
> +
> +  This function searches the first instance of a HOB type among the whole 
> HOB list.
> +  If there does not exist such HOB type in the HOB list, it will return NULL.
> +
> +  If the pointer to the HOB list is NULL, then ASSERT().
> +
> +  @param  Type  The HOB type to return.
> +
> +  @return The next instance of a HOB type from the starting HOB.
> +
> +**/
> +VOID *
> +EFIAPI
> +GetFirstHob (
> +  IN UINT16   

Re: [edk2] [PATCH v1 09/18] StandaloneMmPkg/MemoryAllocationLib: Add MM memory allocation library.

2018-04-25 Thread Achin Gupta
Hi Supreeth,

On Fri, Apr 06, 2018 at 03:42:14PM +0100, Supreeth Venkatesh wrote:
> This patch implements management mode memory allocation services.The
> implementation borrows the MM Core Memory Allocation services as the
> primitive for memory allocation instead of using MM System Table
> services.

The commit message did not really register with me. Once the MMRAM ranges have
been conveyed to the MMST memory allocation services (through
MemoryAllocationLibConstructor()), all functions in MemoryAllocationLib.c use
the MMST services. The message seems to indicate otherwise.

On Arm, the gEfiMmPeiMmramMemoryReserveGuid HOB is used to convey the MMRAM
ranges. It seems x86 uses gMmCoreDataHobGuid HOB. So it worth getting this
reviewed by Jiewen.

The copyright years in the files need to be updated.

With that in mind..

Acked-by: Achin Gupta 

> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Achin Gupta 
> Signed-off-by: Supreeth Venkatesh 
> ---
>  StandaloneMmPkg/Include/Guid/MmCoreData.h  | 132 +++
>  StandaloneMmPkg/Include/Guid/MmramMemoryReserve.h  |  62 ++
>  .../MemoryAllocationLib/MemoryAllocationLib.c  | 907 
> +
>  .../MemoryAllocationLib/MemoryAllocationLib.inf|  49 ++
>  .../MemoryAllocationLib/MemoryAllocationServices.h |  38 +
>  5 files changed, 1188 insertions(+)
>  create mode 100644 StandaloneMmPkg/Include/Guid/MmCoreData.h
>  create mode 100644 StandaloneMmPkg/Include/Guid/MmramMemoryReserve.h
>  create mode 100644 
> StandaloneMmPkg/Library/MemoryAllocationLib/MemoryAllocationLib.c
>  create mode 100644 
> StandaloneMmPkg/Library/MemoryAllocationLib/MemoryAllocationLib.inf
>  create mode 100644 
> StandaloneMmPkg/Library/MemoryAllocationLib/MemoryAllocationServices.h
> 
> diff --git a/StandaloneMmPkg/Include/Guid/MmCoreData.h 
> b/StandaloneMmPkg/Include/Guid/MmCoreData.h
> new file mode 100644
> index 00..c0ac772014
> --- /dev/null
> +++ b/StandaloneMmPkg/Include/Guid/MmCoreData.h
> @@ -0,0 +1,132 @@
> +/** @file
> +  MM Core data.
> +
> +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 __MM_CORE_DATA_H__
> +#define __MM_CORE_DATA_H__
> +
> +#define MM_CORE_DATA_HOB_GUID \
> +  { 0xa160bf99, 0x2aa4, 0x4d7d, { 0x99, 0x93, 0x89, 0x9c, 0xb1, 0x2d, 0xf3, 
> 0x76 }}
> +
> +extern EFI_GUID gMmCoreDataHobGuid;
> +
> +typedef struct {
> +  //
> +  // Address pointer to MM_CORE_PRIVATE_DATA
> +  //
> +  EFI_PHYSICAL_ADDRESS   Address;
> +} MM_CORE_DATA_HOB_DATA;
> +
> +
> +///
> +/// Define values for the communications buffer used when 
> gEfiEventDxeDispatchGuid is
> +/// event signaled.  This event is signaled by the DXE Core each time the 
> DXE Core
> +/// dispatcher has completed its work.  When this event is signaled, the MM 
> Core
> +/// if notified, so the MM Core can dispatch MM drivers.  If 
> COMM_BUFFER_MM_DISPATCH_ERROR
> +/// is returned in the communication buffer, then an error occurred 
> dispatching MM
> +/// Drivers.  If COMM_BUFFER_MM_DISPATCH_SUCCESS is returned, then the MM 
> Core
> +/// dispatched all the drivers it could.  If COMM_BUFFER_MM_DISPATCH_RESTART 
> is
> +/// returned, then the MM Core just dispatched the MM Driver that registered
> +/// the MM Entry Point enabling the use of MM Mode.  In this case, the MM 
> Core
> +/// should be notified again to dispatch more MM Drivers using MM Mode.
> +///
> +#define COMM_BUFFER_MM_DISPATCH_ERROR0x00
> +#define COMM_BUFFER_MM_DISPATCH_SUCCESS  0x01
> +#define COMM_BUFFER_MM_DISPATCH_RESTART  0x02
> +
> +///
> +/// Signature for the private structure shared between the MM IPL and the MM 
> Core
> +///
> +#define MM_CORE_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('m', 'm', 'i', 'c')
> +
> +///
> +/// Private structure that is used to share information between the MM IPL 
> and
> +/// the MM Core.  This structure is allocated from memory of type 
> EfiRuntimeServicesData.
> +/// Since runtime memory types are converted to available memory when a 
> legacy boot
> +/// is performed, the MM Core must not access any fields of this structure 
> if a legacy
> +/// boot is performed.  As a result, the MM IPL must create an event 
> notification
> +/// for the Legacy Boot event and notify the MM Core that a legacy boot is 
> being
> +/// performed.  The MM Core can then use this information to filter accesses 
> to
> +/// thos structure.
> +///
> +typedef struct {
> +  UINT64  Signature;
> +
> +  ///
> +  

Re: [edk2] [PATCH] MdeModulePkg/ConPlatform: Support short-form USB device path

2018-04-25 Thread Laszlo Ersek
Hello Ray,

On 04/25/18 07:44, Ruiyu Ni wrote:
> Today's implementation does an exact device path match to check
> whether the device path of a console is in ConIn/ConOut/ErrOut.
> But that doesn't work for the USB keyboard.
> Because when a platform have multiple USB port, ConIn needs to
> carry all device paths corresponding to each port.
> Even worse, today's BDS core logic removes the device path from
> ConIn/ConOut/ErrOut when the connection to that device path fails.
> So if user switches the USB keyboard from one port to another across
> boot, the USB keyboard doesn't work in the second boot.
>
> ConPlatform driver solved this problem by adding the
> IsHotPlugDevice() function. So that for USB keyboard, ConPlatform
> doesn't care whether its device path is in ConIn or not.
> But the rule is too loose, and now causes platform BDS cannot control
> whether to enable USB keyboard as an active console.
>
> The patch changes ConPlatform to support USB short-form device path
> when checking whether the device path of a console is in
> ConIn/ConOut/ErrOut.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni 
> Cc: Hao A Wu 
> Cc: Michael D Kinney 
> Cc: Star Zeng 
> ---
>  .../Universal/Console/ConPlatformDxe/ConPlatform.c | 526 
> ++---
>  .../Universal/Console/ConPlatformDxe/ConPlatform.h |  20 +-
>  2 files changed, 353 insertions(+), 193 deletions(-)

just a quick question: in OvmfPkg and ArmVirtPkg (more precisely:
ArmVirtQemu*), we add a "wild card" USB keyboard to ConIn:

> STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
>   //
>   // USB_CLASS_DEVICE_PATH Keyboard
>   //
>   {
> {
>   MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP,
>   DP_NODE_LEN (USB_CLASS_DEVICE_PATH)
> },
> 0x, // VendorId: any
> 0x, // ProductId: any
> 3,  // DeviceClass: HID
> 1,  // DeviceSubClass: boot
> 1   // DeviceProtocol: keyboard
>   },
>
>   //
>   // EFI_DEVICE_PATH_PROTOCOL End
>   //
>   {
> END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
> DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
>   }
> };
>
> [...]
>
>   //
>   // Add the hardcoded short-form USB keyboard device path to ConIn.
>   //
>   EfiBootManagerUpdateConsoleVariable (ConIn,
> (EFI_DEVICE_PATH_PROTOCOL *), NULL);

The idea is to connect any USB keyboard(s) that the virtual machine
might have.

This patch for ConPlatformDxe will keep that working, right?

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


Re: [edk2] [PATCH] QemuVideoDxe: round up FrameBufferSize to full page

2018-04-25 Thread Laszlo Ersek
Hi Gerd,

On 04/25/18 14:10, Gerd Hoffmann wrote:
> Guests do the same, because the framebuffer is mapped somewhere, which
> obviously works with page granularity only.
> 
> When not rounding up to full page size we get messages like this one
> (linux kernel):
> 
> efifb: framebuffer at 0x8000, using 1876k, total 1875k
> ^^
> Also sysfb is confused and throws an error:
> 
> sysfb: VRAM smaller than advertised
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Gerd Hoffmann 
> ---
>  OvmfPkg/QemuVideoDxe/Gop.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c
> index d51efc2a83..2bd905efea 100644
> --- a/OvmfPkg/QemuVideoDxe/Gop.c
> +++ b/OvmfPkg/QemuVideoDxe/Gop.c
> @@ -69,6 +69,8 @@ QemuVideoCompleteModeData (
>Mode->FrameBufferBase = FrameBufDesc->AddrRangeMin;
>Mode->FrameBufferSize = Info->HorizontalResolution * 
> Info->VerticalResolution;
>Mode->FrameBufferSize = Mode->FrameBufferSize * ((ModeData->ColorDepth + 
> 7) / 8);
> +  Mode->FrameBufferSize =
> +(Mode->FrameBufferSize + EFI_PAGE_SIZE - 1) & ~EFI_PAGE_MASK;
>DEBUG ((EFI_D_INFO, "FrameBufferBase: 0x%Lx, FrameBufferSize: 0x%Lx\n",
>  Mode->FrameBufferBase, (UINT64)Mode->FrameBufferSize));
>  
> 

thanks for the patch; can you please implement three updates:

(1) Please use the EFI_SIZE_TO_PAGES() macro for rounding up the size.

(EFI_SIZE_TO_PAGES() takes one UINTN argument, but there's no need for
an explicit cast, because
"EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.FrameBufferSize" is already UINTN.)


(2) Please do the same rounding-up in the
QemuVideoVmwareSvgaCompleteModeData() function.

(I'm copying Phil, should he want to comment.)


(3) Please replace "QemuVideoDxe" with "OvmfPkg/QemuVideoDxe" in the
subject line.


Also, can you please verify that the "basic MS video adapter" works in
Windows 8 / Windows 10, after this change? (Apologies if you've already
done that.)


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


[edk2] [PATCH] Add QemuIGDHelperDxe

2018-04-25 Thread Gerd Hoffmann
Little driver to setup the OpRegion for Intel vgpu devices.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/QemuIGDHelperDxe/QemuIGDHelper.c  | 262 ++
 OvmfPkg/OvmfPkgIa32.dsc   |   1 +
 OvmfPkg/OvmfPkgIa32.fdf   |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc|   1 +
 OvmfPkg/OvmfPkgIa32X64.fdf|   1 +
 OvmfPkg/OvmfPkgX64.dsc|   1 +
 OvmfPkg/OvmfPkgX64.fdf|   1 +
 OvmfPkg/QemuIGDHelperDxe/QemuIGDHelperDxe.inf |  32 
 8 files changed, 300 insertions(+)
 create mode 100644 OvmfPkg/QemuIGDHelperDxe/QemuIGDHelper.c
 create mode 100644 OvmfPkg/QemuIGDHelperDxe/QemuIGDHelperDxe.inf

diff --git a/OvmfPkg/QemuIGDHelperDxe/QemuIGDHelper.c 
b/OvmfPkg/QemuIGDHelperDxe/QemuIGDHelper.c
new file mode 100644
index 00..f314049bb4
--- /dev/null
+++ b/OvmfPkg/QemuIGDHelperDxe/QemuIGDHelper.c
@@ -0,0 +1,262 @@
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+VOID *QemuIGDHelperOpRegion;
+
+EFI_STATUS
+EFIAPI
+QemuIGDHelperControllerDriverSupported (
+  IN EFI_DRIVER_BINDING_PROTOCOL*This,
+  IN EFI_HANDLE Controller,
+  IN EFI_DEVICE_PATH_PROTOCOL   *RemainingDevicePath
+  )
+{
+  EFI_STATUS  Status;
+  EFI_PCI_IO_PROTOCOL *PciIo;
+  PCI_TYPE00  Pci;
+  UINT32  OpRegion;
+
+  Status = gBS->OpenProtocol (
+  Controller,
+  ,
+  (VOID **) ,
+  This->DriverBindingHandle,
+  Controller,
+  EFI_OPEN_PROTOCOL_BY_DRIVER
+  );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  Status = PciIo->Pci.Read (
+PciIo,
+EfiPciIoWidthUint32,
+0,
+sizeof (Pci) / sizeof (UINT32),
+
+);
+  if (EFI_ERROR (Status)) {
+goto Done;
+  }
+
+  Status = EFI_UNSUPPORTED;
+  if (!IS_PCI_VGA ()) {
+goto Done;
+  }
+  if (Pci.Hdr.VendorId != 0x8086 /* Intel */) {
+goto Done;
+  }
+
+  DEBUG ((EFI_D_INFO, "IGDHelper: intel gfx %x:%x found\n",
+  Pci.Hdr.VendorId, Pci.Hdr.DeviceId));
+  OpRegion = (UINTN)QemuIGDHelperOpRegion;
+  Status = PciIo->Pci.Write (
+PciIo,
+EfiPciIoWidthUint32,
+0xFC,
+1,
+
+);
+  if (EFI_ERROR (Status)) {
+DEBUG ((EFI_D_INFO, "IGDHelper: write error: %d\n", Status));
+  } else {
+DEBUG ((EFI_D_INFO, "IGDHelper: opregion setup OK\n"));
+  }
+
+Done:
+  gBS->CloseProtocol (
+Controller,
+,
+This->DriverBindingHandle,
+Controller
+);
+
+  return Status;
+}
+
+EFI_STATUS
+EFIAPI
+QemuIGDHelperControllerDriverStart (
+  IN EFI_DRIVER_BINDING_PROTOCOL*This,
+  IN EFI_HANDLE Controller,
+  IN EFI_DEVICE_PATH_PROTOCOL   *RemainingDevicePath
+  )
+{
+  DEBUG ((EFI_D_INFO, "QemuIGDHelperControllerDriverStart\n"));
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+QemuIGDHelperControllerDriverStop (
+  IN EFI_DRIVER_BINDING_PROTOCOL*This,
+  IN EFI_HANDLE Controller,
+  IN UINTN  NumberOfChildren,
+  IN EFI_HANDLE *ChildHandleBuffer
+  )
+{
+  DEBUG ((EFI_D_INFO, "QemuIGDHelperControllerDriverStop\n"));
+  return EFI_SUCCESS;
+}
+
+EFI_DRIVER_BINDING_PROTOCOL gQemuIGDHelperDriverBinding = {
+  QemuIGDHelperControllerDriverSupported,
+  QemuIGDHelperControllerDriverStart,
+  QemuIGDHelperControllerDriverStop,
+  0x10,
+  NULL,
+  NULL
+};
+
+EFI_STATUS
+EFIAPI
+QemuIGDHelperComponentNameGetDriverName (
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
+  IN  CHAR8*Language,
+  OUT CHAR16   **DriverName
+  );
+
+EFI_STATUS
+EFIAPI
+QemuIGDHelperComponentNameGetControllerName (
+  IN  EFI_COMPONENT_NAME_PROTOCOL *This,
+  IN  EFI_HANDLE  ControllerHandle,
+  IN  EFI_HANDLE  ChildHandle
OPTIONAL,
+  IN  CHAR8   *Language,
+  OUT CHAR16  **ControllerName
+  );
+
+EFI_UNICODE_STRING_TABLE mQemuIGDHelperDriverNameTable[] = {
+  { "eng;en", L"QEMU IGD Helper" },
+  { NULL , NULL }
+};
+
+EFI_UNICODE_STRING_TABLE mQemuIGDHelperControllerNameTable[] = {
+  { "eng;en", L"IGD" },
+  { NULL , NULL }
+};
+
+EFI_COMPONENT_NAME_PROTOCOL  gQemuIGDHelperComponentName = {
+  QemuIGDHelperComponentNameGetDriverName,
+  QemuIGDHelperComponentNameGetControllerName,
+  "eng"
+};
+

[edk2] [PATCH] QemuVideoDxe: round up FrameBufferSize to full page

2018-04-25 Thread Gerd Hoffmann
Guests do the same, because the framebuffer is mapped somewhere, which
obviously works with page granularity only.

When not rounding up to full page size we get messages like this one
(linux kernel):

efifb: framebuffer at 0x8000, using 1876k, total 1875k
^^
Also sysfb is confused and throws an error:

sysfb: VRAM smaller than advertised

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/QemuVideoDxe/Gop.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c
index d51efc2a83..2bd905efea 100644
--- a/OvmfPkg/QemuVideoDxe/Gop.c
+++ b/OvmfPkg/QemuVideoDxe/Gop.c
@@ -69,6 +69,8 @@ QemuVideoCompleteModeData (
   Mode->FrameBufferBase = FrameBufDesc->AddrRangeMin;
   Mode->FrameBufferSize = Info->HorizontalResolution * 
Info->VerticalResolution;
   Mode->FrameBufferSize = Mode->FrameBufferSize * ((ModeData->ColorDepth + 7) 
/ 8);
+  Mode->FrameBufferSize =
+(Mode->FrameBufferSize + EFI_PAGE_SIZE - 1) & ~EFI_PAGE_MASK;
   DEBUG ((EFI_D_INFO, "FrameBufferBase: 0x%Lx, FrameBufferSize: 0x%Lx\n",
 Mode->FrameBufferBase, (UINT64)Mode->FrameBufferSize));
 
-- 
2.9.3

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


Re: [edk2] [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64 Specific instance of memory check library.

2018-04-25 Thread Achin Gupta
Hi Jiewen,

On Mon, Apr 16, 2018 at 10:30:55PM +, Yao, Jiewen wrote:
> Hi
> I don't think this lib is generic, because it hardcode the physical address 
> bits.
> 
> PhysicalAddressBits = 36;
> 
> For X86 CPU, we get it from CPUID. :-)
> 
> As enhancement, we may put most common C-code logic (such as CopyMem, or 
> memmap calculation) to StandaloneMmPkg/MemLib, and only include the 
> PhysicalAddresBit calculation under StandaloneMmPkg/MemLib/Arm folder.
> 
> As such, we know clearly on which one is ARM specific.

My point was that the hardocoded PA bits were not introduced to make this code
work on Arm. This has been present in the StandaloneMmPkg from the outset. I
guess for x86 you have moved on to getting this information from the
CPUID. Afaics, this function is not be used on Arm platforms but Supreeth will
double check. If that is the case then only the generic library will be required
minus this function.

cheers,
Achin

> 
> Thank you
> Yao Jiewen
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Achin
> > Gupta
> > Sent: Monday, April 16, 2018 11:13 PM
> > To: Supreeth Venkatesh 
> > Cc: ard.biesheu...@linaro.org; edk2-devel@lists.01.org;
> > leif.lindh...@linaro.org; Yao, Jiewen ; Gao, Liming
> > ; Kinney, Michael D ;
> > n...@arm.com
> > Subject: Re: [edk2] [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64
> > Specific instance of memory check library.
> > 
> > Hi Supreeth,
> > 
> > On Fri, Apr 06, 2018 at 03:42:13PM +0100, Supreeth Venkatesh wrote:
> > > MM memory check library library implementation. This library consumes
> > > MM_ACCESS_PROTOCOL to get MMRAM information. In order to use this
> > > library instance, the platform should produce all MMRAM range via
> > > MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core
> > > and MM driver) and/or specific dedicated hardware.
> > >
> > > This patch provides services for MM Memory Operation.
> > > The management mode Mem Library provides function for checking if buffer
> > > is outside MMRAM and valid. It also provides functions for copy data
> > > from MMRAM to non-MMRAM, from non-MMRAM to MMRAM,
> > > from non-MMRAM to non-MMRAM, or set data in non-MMRAM.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Achin Gupta 
> > > Signed-off-by: Supreeth Venkatesh 
> > > ---
> > >  StandaloneMmPkg/Include/Library/MemLib.h| 140 ++
> > >  StandaloneMmPkg/Library/MemLib/Arm/MemLib.c | 276
> > 
> > 
> > Why is this Library Arm specific. Apart from cosmetics tweaks, it has not
> > changed since it was originally contributed?
> > 
> > cheers,
> > Achin
> > 
> > >  StandaloneMmPkg/Library/MemLib/MemLib.inf   |  47 +
> > >  3 files changed, 463 insertions(+)
> > >  create mode 100644 StandaloneMmPkg/Include/Library/MemLib.h
> > >  create mode 100644 StandaloneMmPkg/Library/MemLib/Arm/MemLib.c
> > >  create mode 100644 StandaloneMmPkg/Library/MemLib/MemLib.inf
> > >
> > > diff --git a/StandaloneMmPkg/Include/Library/MemLib.h
> > b/StandaloneMmPkg/Include/Library/MemLib.h
> > > new file mode 100644
> > > index 00..3264f10010
> > > --- /dev/null
> > > +++ b/StandaloneMmPkg/Include/Library/MemLib.h
> > > @@ -0,0 +1,140 @@
> > > +/** @file
> > > +  Provides services for MM Memory Operation.
> > > +
> > > +  The MM Mem Library provides function for checking if buffer is outside
> > MMRAM and valid.
> > > +  It also provides functions for copy data from MMRAM to non-MMRAM,
> > from non-MMRAM to MMRAM,
> > > +  from non-MMRAM to non-MMRAM, or set data in non-MMRAM.
> > > +
> > > +  Copyright (c) 2015, Intel Corporation. All rights reserved.
> > > +  Copyright (c) 2016 - 2017, ARM Limited. All rights reserved.
> > > +
> > > +  This program and the accompanying materials
> > > +  are licensed and made available under the terms and conditions of the 
> > > BSD
> > License
> > > +  which accompanies this distribution.  The full text of the license may 
> > > be
> > found at
> > > +  http://opensource.org/licenses/bsd-license.php
> > > +
> > > +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> > BASIS,
> > > +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> > EXPRESS OR IMPLIED.
> > > +
> > > +**/
> > > +
> > > +#ifndef _MM_MEM_LIB_H_
> > > +#define _MM_MEM_LIB_H_
> > > +
> > > +/**
> > > +  This function check if the buffer is valid per processor architecture 
> > > and not
> > overlap with MMRAM.
> > > +
> > > +  @param Buffer  The buffer start address to be checked.
> > > +  @param Length  The buffer length to be checked.
> > > +
> > > +  @retval TRUE  This buffer is valid per processor architecture and not
> > overlap with MMRAM.
> > > +  @retval FALSE This buffer is not valid per processor architecture or 
> > > overlap

[edk2] [Patch] BaseTools: Separate HOST and PREFIX env for GCC tool chain

2018-04-25 Thread Liming Gao
The crossing GCC compiler may use the different path for make and gcc tool.
So, GCC_HOST_BIN is introduced for make path. GCC5_BIN is still kept for
gcc path. User needs to set GCC_HOST_BIN besides set GCC5_BIN env if
the default make and gcc is not used.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
---
 BaseTools/Conf/tools_def.template | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 5da229a..48a38e1 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -209,6 +209,7 @@ DEFINE GCC49_X64_PREFIX= ENV(GCC49_BIN)
 
 DEFINE GCC5_IA32_PREFIX= ENV(GCC5_BIN)
 DEFINE GCC5_X64_PREFIX = ENV(GCC5_BIN)
+DEFINE GCC_HOST_PREFIX = ENV(GCC_HOST_BIN)
 
 DEFINE UNIX_IASL_BIN   = ENV(IASL_PREFIX)iasl
 DEFINE WIN_IASL_BIN= ENV(IASL_PREFIX)iasl.exe
@@ -4788,7 +4789,7 @@ DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = 
DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
 

 *_GCC44_*_*_FAMILY   = GCC
 
-*_GCC44_*_MAKE_PATH= DEF(GCC44_IA32_PREFIX)make
+*_GCC44_*_MAKE_PATH= DEF(GCC_HOST_PREFIX)make
 *_GCC44_*_*_DLL= ENV(GCC44_DLL)
 *_GCC44_*_ASL_PATH = DEF(UNIX_IASL_BIN)
 
@@ -4864,7 +4865,7 @@ RELEASE_GCC44_X64_CC_FLAGS   = 
DEF(GCC44_X64_CC_FLAGS) -Os
 

 *_GCC45_*_*_FAMILY   = GCC
 
-*_GCC45_*_MAKE_PATH= DEF(GCC45_IA32_PREFIX)make
+*_GCC45_*_MAKE_PATH= DEF(GCC_HOST_PREFIX)make
 *_GCC45_*_*_DLL= ENV(GCC45_DLL)
 *_GCC45_*_ASL_PATH = DEF(UNIX_IASL_BIN)
 
@@ -4940,7 +4941,7 @@ RELEASE_GCC45_X64_CC_FLAGS   = 
DEF(GCC45_X64_CC_FLAGS) -Os
 

 *_GCC46_*_*_FAMILY   = GCC
 
-*_GCC46_*_MAKE_PATH= DEF(GCC46_IA32_PREFIX)make
+*_GCC46_*_MAKE_PATH= DEF(GCC_HOST_PREFIX)make
 *_GCC46_*_*_DLL= ENV(GCC46_DLL)
 *_GCC46_*_ASL_PATH = DEF(UNIX_IASL_BIN)
 
@@ -5050,7 +5051,7 @@ RELEASE_GCC46_ARM_CC_FLAGS   = 
DEF(GCC46_ARM_CC_FLAGS) -Wno-unused-but-set-v
 

 *_GCC47_*_*_FAMILY   = GCC
 
-*_GCC47_*_MAKE_PATH= DEF(GCC47_IA32_PREFIX)make
+*_GCC47_*_MAKE_PATH= DEF(GCC_HOST_PREFIX)make
 *_GCC47_*_*_DLL= ENV(GCC47_DLL)
 *_GCC47_*_ASL_PATH = DEF(UNIX_IASL_BIN)
 
@@ -5189,7 +5190,7 @@ RELEASE_GCC47_AARCH64_CC_FLAGS   = 
DEF(GCC47_AARCH64_CC_FLAGS) -Wno-unused-but-s
 

 *_GCC48_*_*_FAMILY   = GCC
 
-*_GCC48_*_MAKE_PATH= DEF(GCC48_IA32_PREFIX)make
+*_GCC48_*_MAKE_PATH= DEF(GCC_HOST_PREFIX)make
 *_GCC48_*_*_DLL= ENV(GCC48_DLL)
 *_GCC48_*_ASL_PATH = DEF(UNIX_IASL_BIN)
 
@@ -5328,7 +5329,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS   = 
DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
 

 *_GCC49_*_*_FAMILY   = GCC
 
-*_GCC49_*_MAKE_PATH= DEF(GCC49_IA32_PREFIX)make
+*_GCC49_*_MAKE_PATH= DEF(GCC_HOST_PREFIX)make
 *_GCC49_*_*_DLL= ENV(GCC49_DLL)
 *_GCC49_*_ASL_PATH = DEF(UNIX_IASL_BIN)
 
@@ -5473,7 +5474,7 @@ RELEASE_GCC49_AARCH64_DLINK_FLAGS  = 
DEF(GCC49_AARCH64_DLINK_FLAGS)
 

 *_GCC5_*_*_FAMILY= GCC
 
-*_GCC5_*_MAKE_PATH   = DEF(GCC5_IA32_PREFIX)make
+*_GCC5_*_MAKE_PATH   = DEF(GCC_HOST_PREFIX)make
 *_GCC5_*_*_DLL   = ENV(GCC5_DLL)
 *_GCC5_*_ASL_PATH= DEF(UNIX_IASL_BIN)
 
-- 
2.8.0.windows.1

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


Re: [edk2] [PATCH v1 20/27] BaseTools: remove duplicate variable

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 20/27] BaseTools: remove duplicate variable

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

diff --git a/BaseTools/Source/Python/Common/DataType.py 
b/BaseTools/Source/Python/Common/DataType.py
index 40a162adf33c..5c8cc82fc915 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -128,8 +128,6 @@ PLATFORM_COMPONENT_TYPE_LIBRARY = 
EDK_COMPONENT_TYPE_LIBRARY  PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS = 
'LIBRARY_CLASS'
 PLATFORM_COMPONENT_TYPE_MODULE = 'MODULE'
 
-TAB_LIBRARIES = 'Libraries'
-
 TAB_SOURCES = 'Sources'
 TAB_SOURCES_COMMON = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_COMMON
 TAB_SOURCES_IA32 = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_IA32
--
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 09/27] BaseTools: AutoGen - remove unused variables.

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 09/27] BaseTools: AutoGen - remove unused variables.

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

diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py 
b/BaseTools/Source/Python/AutoGen/GenMake.py
index 1bb5163e73e0..a37350742240 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -427,8 +427,6 @@ cleanlib:
 self.ResultFileList = []
 self.IntermediateDirectoryList = ["$(DEBUG_DIR)", "$(OUTPUT_DIR)"]
 
-self.SourceFileDatabase = {}# {file type : file path}
-self.DestFileDatabase = {}  # {file type : file path}
 self.FileBuildTargetList = []   # [(src, target string)]
 self.BuildTargetList = []   # [target string]
 self.PendingBuildTargetList = []# [FileBuildRule objects]
-- 
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 27/27] BaseTools: CommonClass - remove unused classes

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 27/27] BaseTools: CommonClass - remove unused classes

CommonDataClass/CommonClass has only 1 used class: SkuInfoClass remove all 
unused classes

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/CommonDataClass/CommonClass.py | 397 
+---
 1 file changed, 1 insertion(+), 396 deletions(-)

diff --git a/BaseTools/Source/Python/CommonDataClass/CommonClass.py 
b/BaseTools/Source/Python/CommonDataClass/CommonClass.py
index 6a8262e5e964..e29f5211d5c7 100644
--- a/BaseTools/Source/Python/CommonDataClass/CommonClass.py
+++ b/BaseTools/Source/Python/CommonDataClass/CommonClass.py
@@ -1,7 +1,7 @@
 ## @file
 # This file is used to define common items of class object  # -# Copyright (c) 
2007 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights 
+reserved.
 # This program and the accompanying materials  # are licensed and made 
available under the terms and conditions of the BSD License
 # which accompanies this distribution.The full text of the license may be 
found at
@@ -11,240 +11,6 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 
-#
-# Generate help text
-#
-def GenerateHelpText(Text, Lang):
-if Text:
-Ht = HelpTextClass()
-Ht.Lang = Lang
-Ht.String = Text
-
-return Ht
-
-return None
-
-## CommonClass
-#
-# This class defined common items used in Module/Platform/Package files -# 
-# @param object:   Inherited from object class
-# @param Usage:Input value for Usage, default is [] 
-# @param FeatureFlag:  Input value for FeatureFalg, default is ''
-# @param SupArchList:  Input value for SupArchList, default is []
-# @param HelpText: Input value for HelpText, default is ''
-#
-# @var Usage:  To store value for Usage, selection scope is in below 
list
-#  ALWAYS_CONSUMED | SOMETIMES_CONSUMED | ALWAYS_PRODUCED 
| SOMETIMES_PRODUCED | TO_START | BY_START | PRIVATE
-# @var FeatureFlag:To store value for FeatureFlag
-# @var SupArchList:To store value for SupArchList, selection scope is in 
below list
-#  EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64
-# @var HelpText:   To store value for HelpText
-#
-class CommonClass(object):
-def __init__(self, Usage = None, FeatureFlag = '', SupArchList = None, 
HelpText = ''):
-self.Usage = Usage
-if self.Usage is None:
-self.Usage = []
-self.FeatureFlag = FeatureFlag
-self.SupArchList = SupArchList
-if self.SupArchList is None:
-self.SupArchList = []
-self.HelpText = HelpText
-self.HelpTextList = []
-
-## CommonHeaderClass
-#
-# This class defined common items used in Module/Platform/Package files -# 
-# @param object:  Inherited from object class
-#
-# @var Abstract:  To store value for Abstract
-# @var Description:   To store value for Description
-# @var Copyright: To store value for Copyright
-# @var License:   To store value for License
-# @var Specification: To store value for Specification
-#
-class CommonHeaderClass(object):
-def __init__(self):
-self.Abstract = ''
-self.Description = ''
-self.Copyright = ''
-self.License = ''
-self.Specification = {}
-
-## HelpTextClass
-#
-# This class defined HelpText item used in PKG file -# 
-# @param object: Inherited from object class
-#
-# @var Lang: To store value for Lang
-# @var String:   To store value for String
-#
-class HelpTextClass(object):
-def __init__(self):
-self.Lang = ''
-self.String = ''
-
-## DefineClass
-#
-# This class defined item DEFINE used in Module/Platform/Package files -# -# 
@param object:  Inherited from object class -#
-# @var Define:To store value for Define, it is a set structure as
-# { (DefineName, Arch) : DefineValue, ... }
-#
-class DefineClass(object):
-def __init__(self):
-self.Define = {}
-
-## ClonedRecordClass
-#
-# This class defined ClonedRecord items used in Module/Platform/Package files 
-# 
-# @param object:Inherited from object class
-#
-# @var Id:  To store value for Id
-# @var FarGuid: To store value for FarGuid
-# @var PackageGuid: To store value for PackageGuid
-# @var PackageVersion:  To store value for PackageVersion
-# @var ModuleGuid:  To store value for ModuleGuid
-# @var ModuleVersion:   To store value for ModuleVersion

Re: [edk2] [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto initialize

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto 
initialize

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/AutoGen/GenVar.py | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py 
b/BaseTools/Source/Python/AutoGen/GenVar.py
index 37c168a84b43..99c6ed640c00 100644
--- a/BaseTools/Source/Python/AutoGen/GenVar.py
+++ b/BaseTools/Source/Python/AutoGen/GenVar.py
@@ -128,7 +128,7 @@ class VariableMgr(object):
 return var_value
 def process_variable_data(self):
 
-var_data = dict()
+var_data = collections.defaultdict(collections.OrderedDict)
 
 indexedvarinfo = collections.OrderedDict()
 for item in self.VarInfo:
@@ -155,8 +155,6 @@ class VariableMgr(object):
 for item in default_data_buffer:
 default_data_array += unpack("B",item)
 
-if (DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT) not 
in var_data:
-
var_data[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)] = 
collections.OrderedDict()
 
var_data[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)][index] = 
(default_data_buffer,sku_var_info[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)])
 
 for (skuid,defaultstoragename) in indexedvarinfo.get(index):
@@ -177,8 +175,6 @@ class VariableMgr(object):
 
 data_delta = self.calculate_delta(default_data_array, 
others_data_array)
 
-if (skuid,defaultstoragename) not in var_data:
-var_data[(skuid,defaultstoragename)] = 
collections.OrderedDict()
 var_data[(skuid,defaultstoragename)][index] = 
(data_delta,sku_var_info[(skuid,defaultstoragename)])
 return var_data
 
-- 
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 03/27] BaseTools: Share RegEx between files

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 03/27] BaseTools: Share RegEx between files

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/Common/Misc.py   | 22 
+++-
 BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 15 +
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index bc7d0c2d9d00..4a6a29c7ae80 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -42,6 +42,13 @@ import subprocess
 ## Regular expression used to find out place holders in string template  
gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
 
+## regular expressions for map file processing startPatternGeneral = 
+re.compile("^Start[' ']+Length[' ']+Name[' ']+Class") 
+addressPatternGeneral = re.compile("^Address[' ']+Publics by Value[' 
+']+Rva\+Base") valuePatternGcc = re.compile('^([\w_\.]+) 
++([\da-fA-Fx]+) +([\da-fA-Fx]+)$') pcdPatternGcc = 
+re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)') secReGeneral = 
+re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? 
++([.\w\$]+) +(\w+)', re.UNICODE)
+
 ## Dictionary used to store file time stamp for quick re-access
 gFileTimeStampCache = {}# {file path : file time stamp}
 
@@ -92,8 +99,6 @@ def _parseForXcode(lines, efifilepath, varnames):
 
 def _parseForGCC(lines, efifilepath, varnames):
 """ Parse map file generated by GCC linker """
-valuePattern = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
-pcdPattern = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
 status = 0
 sections = []
 varoffset = []
@@ -112,7 +117,7 @@ def _parseForGCC(lines, efifilepath, varnames):
 
 # status handler
 if status == 3:
-m = valuePattern.match(line)
+m = valuePatternGcc.match(line)
 if m is not None:
 sections.append(m.groups(0))
 for varname in varnames:
@@ -125,7 +130,7 @@ def _parseForGCC(lines, efifilepath, varnames):
 else:
 Str = line[len(".data.%s" % varname):]
 if Str:
-m = pcdPattern.match(Str.strip())
+m = pcdPatternGcc.match(Str.strip())
 if m is not None:
 varoffset.append((varname, int(m.groups(0)[0], 16) 
, int(sections[-1][1], 16), sections[-1][0]))
 
@@ -153,24 +158,21 @@ def _parseGeneral(lines, efifilepath, varnames):
 status = 0#0 - beginning of file; 1 - PE section definition; 2 - 
symbol table
 secs  = []# key = section name
 varoffset = []
-secRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? 
+([.\w\$]+) +(\w+)', re.UNICODE)
 symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\w\?@\$]+) 
+([\da-fA-F]+)', re.UNICODE)
-startRe = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
-addressRe = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
 
 for line in lines:
 line = line.strip()
-if startRe.match(line):
+if startPatternGeneral.match(line):
 status = 1
 continue
-if addressRe.match(line):
+if addressPatternGeneral.match(line):
 status = 2
 continue
 if line.startswith("entry point at"):
 status = 3
 continue
 if status == 1 and len(line) != 0:
-m =  secRe.match(line)
+m =  secReGeneral.match(line)
 assert m is not None, "Fail to parse the section in map file , 
line is %s" % line
 sec_no, sec_start, sec_length, sec_name, sec_class = m.groups(0)
 secs.append([int(sec_no, 16), int(sec_start, 16), int(sec_length, 
16), sec_name, sec_class]) diff --git 
a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py 
b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index 59748763a553..2a039480a00a 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -24,7 +24,7 @@ import array
 
 from Common.BuildToolError import *
 import Common.EdkLogger as EdkLogger
-from Common.Misc import PeImageClass
+from Common.Misc import PeImageClass, startPatternGeneral, 
+addressPatternGeneral, valuePatternGcc, pcdPatternGcc, secReGeneral
 from Common.BuildVersion import gBUILD_VERSION  from 

Re: [edk2] [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number

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

diff --git a/BaseTools/Source/Python/Common/GlobalData.py 
b/BaseTools/Source/Python/Common/GlobalData.py
index f58dc5a8dda2..e3131b86cc60 100644
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -62,6 +62,7 @@ gGuidPatternEnd = re.compile(r'{}$'.format(_GuidPattern))
 ## Regular expressions for HEX matching  g4HexChar = 
re.compile(r'{}{{4}}'.format(_HexChar))
 gHexPattern = re.compile(r'0[xX]{}+'.format(_HexChar))
+gHexPatternAll = re.compile(r'0[xX]{}+$'.format(_HexChar))
 
 ## Regular expressions for string identifier checking  gIdentifierPattern = 
re.compile('^[a-zA-Z][a-zA-Z0-9_]*$', re.UNICODE) diff --git 
a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index b8848a25b4b2..fe4f2df0e1e1 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1183,13 +1183,6 @@ class FdfParser:
 
 self.__GetOneChar()
 
-def __IsHex(self, HexStr):
-if not HexStr.upper().startswith("0X"):
-return False
-if len(self.__Token) <= 2:
-return False
-return True if all(x in string.hexdigits for x in HexStr[2:]) else 
False
-
 ## __GetNextHexNumber() method
 #
 #   Get next HEX data before a seperator
@@ -1202,7 +1195,7 @@ class FdfParser:
 def __GetNextHexNumber(self):
 if not self.__GetNextToken():
 return False
-if self.__IsHex(self.__Token):
+if gHexPatternAll.match(self.__Token):
 return True
 else:
 self.__UndoToken()
--
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 10/27] BaseTools: Remove extra .keys()

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Zhu, Yonghong ; Gao, Liming 
Subject: [PATCH v1 10/27] BaseTools: Remove extra .keys()

Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/GenFds/Fv.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/GenFds/Fv.py 
b/BaseTools/Source/Python/GenFds/Fv.py
index 5228e155267f..71bcd4c72170 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -316,7 +316,7 @@ class FV (FvClassObject):
   ' %s' %ErasePloarity+ \
   T_CHAR_LF)
 if not (self.FvAttributeDict is None):
-for FvAttribute in self.FvAttributeDict:
+for FvAttribute in self.FvAttributeDict.keys() :
 if FvAttribute == "FvUsedSizeEnable":
 if self.FvAttributeDict[FvAttribute].upper() in ('TRUE', 
'1') :
 self.UsedSizeEnable = True
-- 
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 02/27] BaseTools: GenPatchPcdTable - refactor RegEx to minimize multiple compiling

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 02/27] BaseTools: GenPatchPcdTable - refactor RegEx to 
minimize multiple compiling

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 24 

 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py 
b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index dc2ceaf775d8..59748763a553 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -63,6 +63,7 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
 return _parseGeneral(lines, efifilepath)
 
 def _parseForXcode(lines, efifilepath):
+valuePattern = 
re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
 status = 0
 pcds = []
 for line in lines:
@@ -72,13 +73,16 @@ def _parseForXcode(lines, efifilepath):
 continue
 if status == 1 and len(line) != 0:
 if '_gPcd_BinaryPatch_' in line:
-m = 
re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))', line)
+m = valuePattern.match(line)
 if m is not None:
 pcds.append((m.groups(0)[3], int(m.groups(0)[0], 16)))
 return pcds
 
 def _parseForGCC(lines, efifilepath):
 """ Parse map file generated by GCC linker """
+valuePattern = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
+dataPattern = re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$')
+pcdPattern = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
 status = 0
 imageBase = -1
 sections = []
@@ -98,15 +102,15 @@ def _parseForGCC(lines, efifilepath):
 
 # status handler
 if status == 3:
-m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
+m = valuePattern.match(line)
 if m is not None:
 sections.append(m.groups(0))
 if status == 3:
-m = re.match('^.data._gPcd_BinaryPatch_([\w_\d]+)$', line)
+m = dataPattern.match(line)
 if m is not None:
 if lines[index + 1]:
 PcdName = m.groups(0)[0]
-m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', 
lines[index + 1].strip())
+m = pcdPattern.match(lines[index + 1].strip())
 if m is not None:
 bpcds.append((PcdName, int(m.groups(0)[0], 16) , 
int(sections[-1][1], 16), sections[-1][0]))
 
@@ -137,17 +141,19 @@ def _parseGeneral(lines, efifilepath):
 status = 0#0 - beginning of file; 1 - PE section definition; 2 - 
symbol table
 secs = []# key = section name
 bPcds = []
-
+startPattern = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
+addressPattern = re.compile("^Address[' ']+Publics by Value[' 
']+Rva\+Base")
+symPattern = re.compile('^[_]+gPcd_BinaryPatch_([\w]+)')
 
 for line in lines:
 line = line.strip()
-if re.match("^Start[' ']+Length[' ']+Name[' ']+Class", line):
+if startPattern.match(line):
 status = 1
 continue
-if re.match("^Address[' ']+Publics by Value[' ']+Rva\+Base", line):
+if addressPattern.match(line):
 status = 2
 continue
-if re.match("^entry point at", line):
+if line.startswith("entry point at"):
 status = 3
 continue
 if status == 1 and len(line) != 0:
@@ -162,7 +168,7 @@ def _parseGeneral(lines, efifilepath):
 sec_no = int(sec_no, 16)
 sym_offset = int(sym_offset, 16)
 vir_addr = int(vir_addr, 16)
-m2 = re.match('^[_]+gPcd_BinaryPatch_([\w]+)', sym_name)
+m2 = symPattern.match(sym_name)
 if m2 is not None:
 # fond a binary pcd entry in map file
 for sec in secs:
-- 
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 07/27] BaseTools: Workspace - refactor GetStructurePcdInfo

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 07/27] BaseTools: Workspace - refactor GetStructurePcdInfo

the function doesn't use self and can be static defaultdict replaces dict and 
removes the dict initialization code

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index be3f7b6881e8..904c52d9576a 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -39,7 +39,7 @@ import Common.GlobalData as GlobalData  import subprocess  
from Common.Misc import SaveFileOnChange  from Workspace.BuildClassObject 
import PlatformBuildClassObject, StructurePcd, PcdClassObject, 
ModuleBuildClassObject -from collections import OrderedDict
+from collections import OrderedDict,defaultdict
 
 variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
 
@@ -1187,11 +1187,10 @@ class DscBuildData(PlatformBuildClassObject):
 options[Key] += ' ' + Option
 return self._ModuleTypeOptions[Edk, ModuleType]
 
-def GetStructurePcdInfo(self, PcdSet):
-structure_pcd_data = {}
+@staticmethod
+def GetStructurePcdInfo(PcdSet):
+structure_pcd_data = defaultdict(list)
 for item in PcdSet:
-if (item[0],item[1]) not in structure_pcd_data:
-structure_pcd_data[(item[0],item[1])] = []
 structure_pcd_data[(item[0],item[1])].append(item)
 
 return structure_pcd_data
@@ -1298,7 +1297,7 @@ class DscBuildData(PlatformBuildClassObject):
 S_PcdSet.append([ 
TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, 
default_store,Dummy5, AnalyzePcdExpression(Setting)[0]])
 
 # handle pcd value override
-StrPcdSet = self.GetStructurePcdInfo(S_PcdSet)
+StrPcdSet = DscBuildData.GetStructurePcdInfo(S_PcdSet)
 S_pcd_set = OrderedDict()
 for str_pcd in StrPcdSet:
 str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None)
--
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 12/27] BaseTools: remove dict from DscBuildData

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 12/27] BaseTools: remove dict from DscBuildData

the dict is not needed as BaseTools can check the set

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 904c52d9576a..eb435cece480 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1953,13 +1953,11 @@ class DscBuildData(PlatformBuildClassObject):
 InitByteValue = ""
 CApp = PcdMainCHeader
 
-Includes = {}
 IncludeFiles = set()
 for PcdName in StructuredPcds:
 Pcd = StructuredPcds[PcdName]
 for IncludeFile in Pcd.StructuredPcdIncludeFile:
-if IncludeFile not in Includes:
-Includes[IncludeFile] = True
+if IncludeFile not in IncludeFiles:
 IncludeFiles.add(IncludeFile)
 CApp = CApp + '#include <%s>\n' % (IncludeFile)
 CApp = CApp + '\n'
-- 
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 08/27] BaseTools: AutoGen - remove dictionary populated, but never accessed

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 08/27] BaseTools: AutoGen - remove dictionary populated, but 
never accessed

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

diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py 
b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index 5937558e7038..4f4a8d856842 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -980,7 +980,6 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
 Changed = SaveFileOnChange(DbFileName, DbFile.getvalue(), True)  def 
CreatePcdDataBase(PcdDBData):
 delta = {}
-basedata = {}
 for skuname,skuid in PcdDBData:
 if len(PcdDBData[(skuname,skuid)][1]) != 
len(PcdDBData[(TAB_DEFAULT,"0")][1]):
 EdkLogger.ERROR("The size of each sku in one pcd are not same") @@ 
-988,7 +987,6 @@ def CreatePcdDataBase(PcdDBData):
 if skuname == TAB_DEFAULT:
 continue
 delta[(skuname,skuid)] = [(index,data,hex(data)) for index,data in 
enumerate(PcdDBData[(skuname,skuid)][1]) if 
PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]
-basedata[(skuname,skuid)] = 
[(index,PcdDBData[(TAB_DEFAULT,"0")][1][index],hex(PcdDBData[(TAB_DEFAULT,"0")][1][index]))
 for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if 
PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]
 databasebuff = PcdDBData[(TAB_DEFAULT,"0")][0]
 
 for skuname,skuid in delta:
--
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 05/27] BaseTools: Autogen - replace string constants with those from DataType

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu 

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 05/27] BaseTools: Autogen - replace string constants with 
those from DataType

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

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 6152225943cf..3a2976181ac1 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -259,7 +259,7 @@ class WorkspaceAutoGen(AutoGen):
 self.BuildDatabase  = MetaFileDb
 self.MetaFile   = ActivePlatform
 self.WorkspaceDir   = WorkspaceDir
-self.Platform   = self.BuildDatabase[self.MetaFile, TAB_COMMON, 
Target, Toolchain]
+self.Platform   = self.BuildDatabase[self.MetaFile, 
TAB_ARCH_COMMON, Target, Toolchain]
 GlobalData.gActivePlatform = self.Platform
 self.BuildTarget= Target
 self.ToolChain  = Toolchain
@@ -405,8 +405,8 @@ class WorkspaceAutoGen(AutoGen):
 Platform = self.BuildDatabase[self.MetaFile, Arch, Target, 
Toolchain]
 PlatformPcds = Platform.Pcds
 self._GuidDict = Platform._GuidDict
-SourcePcdDict = {'DynamicEx':set(), 
'PatchableInModule':set(),'Dynamic':set(),'FixedAtBuild':set()}
-BinaryPcdDict = {'DynamicEx':set(), 'PatchableInModule':set()}
+SourcePcdDict = {TAB_PCDS_DYNAMIC_EX:set(), 
TAB_PCDS_PATCHABLE_IN_MODULE:set(),TAB_PCDS_DYNAMIC:set(),TAB_PCDS_FIXED_AT_BUILD:set()}
+BinaryPcdDict = {TAB_PCDS_DYNAMIC_EX:set(), 
+ TAB_PCDS_PATCHABLE_IN_MODULE:set()}
 SourcePcdDict_Keys = SourcePcdDict.keys()
 BinaryPcdDict_Keys = BinaryPcdDict.keys()
 
@@ -430,23 +430,23 @@ class WorkspaceAutoGen(AutoGen):
 if PcdInPlatform.Type not in [None, '']:
 BuildData.Pcds[key].Type = 
PcdInPlatform.Type
 
-if 'DynamicEx' in BuildData.Pcds[key].Type:
+if TAB_PCDS_DYNAMIC_EX in BuildData.Pcds[key].Type:
 if BuildData.IsBinaryModule:
-
BinaryPcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+
+ BinaryPcdDict[TAB_PCDS_DYNAMIC_EX].add((BuildData.Pcds[key].TokenCName
+ , BuildData.Pcds[key].TokenSpaceGuidCName))
 else:
-
SourcePcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+
+ SourcePcdDict[TAB_PCDS_DYNAMIC_EX].add((BuildData.Pcds[key].TokenCName
+ , BuildData.Pcds[key].TokenSpaceGuidCName))
 
-elif 'PatchableInModule' in BuildData.Pcds[key].Type:
+elif TAB_PCDS_PATCHABLE_IN_MODULE in 
BuildData.Pcds[key].Type:
 if BuildData.MetaFile.Ext == '.inf':
 if BuildData.IsBinaryModule:
-
BinaryPcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+
+ BinaryPcdDict[TAB_PCDS_PATCHABLE_IN_MODULE].add((BuildData.Pcds[key].T
+ okenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
 else:
-
SourcePcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+
+ SourcePcdDict[TAB_PCDS_PATCHABLE_IN_MODULE].add((BuildData.Pcds[key].T
+ okenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
 
-elif 'Dynamic' in BuildData.Pcds[key].Type:
-
SourcePcdDict['Dynamic'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
-elif 'FixedAtBuild' in BuildData.Pcds[key].Type:
-
SourcePcdDict['FixedAtBuild'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+elif TAB_PCDS_DYNAMIC in BuildData.Pcds[key].Type:
+
SourcePcdDict[TAB_PCDS_DYNAMIC].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+elif TAB_PCDS_FIXED_AT_BUILD in 
BuildData.Pcds[key].Type:
+
+ 

Re: [edk2] [PATCH v1 06/27] BaseTools: simplify if call

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 06/27] BaseTools: simplify if call

the variable is a string type since we just used .strip() on it.

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

diff --git a/BaseTools/Source/Python/Common/Expression.py 
b/BaseTools/Source/Python/Common/Expression.py
index 9a3415ccaabe..99929938fb5a 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -815,7 +815,7 @@ class ValueExpressionEx(ValueExpression):
 except BadExpression, Value:
 if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 
'BOOLEAN']:
 PcdValue = PcdValue.strip()
-if type(PcdValue) == type('') and PcdValue.startswith('{') and 
PcdValue.endswith('}'):
+if PcdValue.startswith('{') and PcdValue.endswith('}'):
 PcdValue = SplitPcdValueString(PcdValue[1:-1])
 if type(PcdValue) == type([]):
 TmpValue = 0
-- 
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize multiple compiling

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize 
multiple compiling

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/Workspace/DscBuildData.py   | 4 +++-
 BaseTools/Source/Python/Workspace/MetaFileParser.py | 8 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index d6b8b761d607..be3f7b6881e8 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -41,6 +41,8 @@ from Common.Misc import SaveFileOnChange  from 
Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, 
PcdClassObject, ModuleBuildClassObject  from collections import OrderedDict
 
+variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
+
 #
 # Treat CHAR16 as a synonym for UINT16.  CHAR16 support is required for VFR C 
structs  # @@ -2421,7 +2423,7 @@ class DscBuildData(PlatformBuildClassObject):
 if VariableOffset.isdigit():
 if int(VariableOffset, 10) > 0x:
 ExceedMax = True
-elif re.match(r'[\t\s]*0[xX][a-fA-F0-9]+$', VariableOffset):
+elif variablePattern.match(VariableOffset):
 if int(VariableOffset, 16) > 0x:
 ExceedMax = True
 # For Offset written in "A.B"
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py 
b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 322ed3844966..550359f9abb2 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -35,6 +35,10 @@ from Common.LongFilePathSupport import OpenLongFilePath as 
open  from MetaFileTable import MetaFileStorage  from MetaFileCommentParser 
import CheckInfComment
 
+## RegEx for finding file versions
+hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}')
+decVersionPattern = re.compile(r'\d+\.\d+')
+
 ## A decorator used to parse macro definition  def ParseMacro(Parser):
 def MacroParser(self):
@@ -366,9 +370,9 @@ class MetaFileParser(object):
 EdkLogger.error("Parser", FORMAT_INVALID, "%s not defined" % 
(Macro), ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex 
+ 1)
 # Sometimes, we need to make differences between EDK and EDK2 modules 
 if Name == 'INF_VERSION':
-if re.match(r'0[xX][\da-f-A-F]{5,8}', Value):
+if hexVersionPattern.match(Value):
 self._Version = int(Value, 0)   
-elif re.match(r'\d+\.\d+', Value):
+elif decVersionPattern.match(Value):
 ValueList = Value.split('.')
 Major = '%04o' % int(ValueList[0], 0)
 Minor = '%04o' % int(ValueList[1], 0)
--
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 01/27] BaseTools: Misc - refactor RegEx to minimize multiple compiling

2018-04-25 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 01/27] BaseTools: Misc - refactor RegEx to minimize multiple 
compiling

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

diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index 4f2bfd63cfc3..bc7d0c2d9d00 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -84,6 +84,7 @@ def _parseForXcode(lines, efifilepath, varnames):
 if status == 1 and len(line) != 0:
 for varname in varnames:
 if varname in line:
+# cannot pregenerate this RegEx since it uses varname from 
varnames.
 m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % 
varname, line)
 if m is not None:
 ret.append((varname, m.group(1))) @@ -91,6 +92,8 @@ 
def _parseForXcode(lines, efifilepath, varnames):
 
 def _parseForGCC(lines, efifilepath, varnames):
 """ Parse map file generated by GCC linker """
+valuePattern = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
+pcdPattern = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
 status = 0
 sections = []
 varoffset = []
@@ -109,7 +112,7 @@ def _parseForGCC(lines, efifilepath, varnames):
 
 # status handler
 if status == 3:
-m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
+m = valuePattern.match(line)
 if m is not None:
 sections.append(m.groups(0))
 for varname in varnames:
@@ -122,7 +125,7 @@ def _parseForGCC(lines, efifilepath, varnames):
 else:
 Str = line[len(".data.%s" % varname):]
 if Str:
-m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', 
Str.strip())
+m = pcdPattern.match(Str.strip())
 if m is not None:
 varoffset.append((varname, int(m.groups(0)[0], 16) 
, int(sections[-1][1], 16), sections[-1][0]))
 
@@ -152,16 +155,18 @@ def _parseGeneral(lines, efifilepath, varnames):
 varoffset = []
 secRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? 
+([.\w\$]+) +(\w+)', re.UNICODE)
 symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\w\?@\$]+) 
+([\da-fA-F]+)', re.UNICODE)
+startRe = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
+addressRe = re.compile("^Address[' ']+Publics by Value[' 
+ ']+Rva\+Base")
 
 for line in lines:
 line = line.strip()
-if re.match("^Start[' ']+Length[' ']+Name[' ']+Class", line):
+if startRe.match(line):
 status = 1
 continue
-if re.match("^Address[' ']+Publics by Value[' ']+Rva\+Base", line):
+if addressRe.match(line):
 status = 2
 continue
-if re.match("^entry point at", line):
+if line.startswith("entry point at"):
 status = 3
 continue
 if status == 1 and len(line) != 0:
@@ -177,6 +182,7 @@ def _parseGeneral(lines, efifilepath, varnames):
 sec_no = int(sec_no, 16)
 sym_offset = int(sym_offset, 16)
 vir_addr   = int(vir_addr,   16)
+# cannot pregenerate this RegEx since it uses varname from 
varnames.
 m2 = re.match('^[_]*(%s)' % varname, sym_name)
 if m2 is not None:
 # fond a binary pcd entry in map file
--
2.16.2.windows.1

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


[edk2] [PATCH] IntelFrameworkModule/LegacyBios: Use reserved memory for legacy data

2018-04-25 Thread Ruiyu Ni
Certain Legacy USB implementation needs to access legacy data (BDA,
etc.) from SMM environment. While currently it's not allowed to
access BS memory from SMM after EndofDxe, change the legacy data
to use reserved memory type.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Star Zeng 
---
 IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c  | 13 +++--
 .../Csm/LegacyBiosDxe/LegacyBiosInterface.h |  4 +++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c 
b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
index fca08a8fa2..a96f9b5610 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
@@ -46,7 +46,8 @@ BOOLEAN   mEndOfDxe= FALSE;
   Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode
   memory.
 
-  @param  AllocateType   Allocated Legacy Memory Type
+  @param  AllocateType   The type of allocation to perform.
+  @param  MemoryType The type of memory to allocate.
   @param  StartPageAddress   Start address of range
   @param  Pages  Number of pages to allocate
   @param  Result Result of allocation
@@ -58,6 +59,7 @@ BOOLEAN   mEndOfDxe= FALSE;
 EFI_STATUS
 AllocateLegacyMemory (
   IN  EFI_ALLOCATE_TYPE AllocateType,
+  IN  EFI_MEMORY_TYPE   MemoryType,
   IN  EFI_PHYSICAL_ADDRESS  StartPageAddress,
   IN  UINTN Pages,
   OUT EFI_PHYSICAL_ADDRESS  *Result
@@ -72,7 +74,7 @@ AllocateLegacyMemory (
   MemPage = (EFI_PHYSICAL_ADDRESS) (UINTN) StartPageAddress;
   Status = gBS->AllocatePages (
   AllocateType,
-  EfiBootServicesCode,
+  MemoryType,
   Pages,
   
   );
@@ -974,6 +976,7 @@ LegacyBiosInstall (
   //
   AllocateLegacyMemory (
 AllocateAddress,
+EfiReservedMemoryType,
 0,
 1,
 
@@ -999,6 +1002,7 @@ LegacyBiosInstall (
 
   Status = AllocateLegacyMemory (
  AllocateAddress,
+ EfiReservedMemoryType,
  CONVENTIONAL_MEMORY_TOP - MemorySize,
  EFI_SIZE_TO_PAGES (MemorySize),
  
@@ -1027,6 +1031,7 @@ LegacyBiosInstall (
   for (MemStart = MemoryAddress; MemStart < MemoryAddress + MemorySize; 
MemStart += 0x1000) {
 Status = AllocateLegacyMemory (
AllocateAddress,
+   EfiBootServicesCode,
MemStart,
1,

@@ -1046,6 +1051,7 @@ LegacyBiosInstall (
   ASSERT ((MemorySize & 0xFFF) == 0);  
   Status = AllocateLegacyMemory (
  AllocateMaxAddress,
+ EfiBootServicesCode,
  CONVENTIONAL_MEMORY_TOP,
  EFI_SIZE_TO_PAGES (MemorySize),
  
@@ -1059,6 +1065,7 @@ LegacyBiosInstall (
   //
   Status = AllocateLegacyMemory (
  AllocateMaxAddress,
+ EfiReservedMemoryType,
  CONVENTIONAL_MEMORY_TOP,
  (sizeof (LOW_MEMORY_THUNK) / EFI_PAGE_SIZE) + 2,
  
@@ -1086,6 +1093,7 @@ LegacyBiosInstall (
   //   
   Status = AllocateLegacyMemory (
  AllocateMaxAddress,
+ EfiBootServicesCode,
  0x100,
  EFI_SIZE_TO_PAGES (MemorySize),
  
@@ -1096,6 +1104,7 @@ LegacyBiosInstall (
 //   
 Status = AllocateLegacyMemory (
AllocateMaxAddress,
+   EfiBootServicesCode,
0x,
EFI_SIZE_TO_PAGES (MemorySize),

diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h 
b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
index cc2fc9fc13..595fe0eade 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
@@ -1264,7 +1264,8 @@ GenerateSoftInit (
   Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode
   memory.
 
-  @param  AllocateType   Allocated Legacy Memory Type
+  @param  AllocateType   The type of allocation to perform.
+  @param  MemoryType The type of memory to allocate.
   @param  StartPageAddress   Start address of range
   @param  Pages  Number of pages to allocate
   @param  Result Result of allocation
@@ -1276,6 +1277,7 @@ GenerateSoftInit (
 EFI_STATUS
 AllocateLegacyMemory (
   IN  EFI_ALLOCATE_TYPE AllocateType,
+  IN  EFI_MEMORY_TYPE   MemoryType,
   IN  EFI_PHYSICAL_ADDRESS  StartPageAddress,
   IN  UINTN Pages,
   OUT EFI_PHYSICAL_ADDRESS  *Result
-- 
2.16.1.windows.1


[edk2] [PATCH] MdePkg/DevicePathToText: Fix iSCSI.Lun byte order issue

2018-04-25 Thread Ruiyu Ni
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Liming Gao 
---
 MdePkg/Library/UefiDevicePathLib/DevicePathToText.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index 63542dba96..df1f218776 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -2,7 +2,7 @@
   DevicePathToText protocol as defined in the UEFI 2.0 specification.
 
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
-Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -1539,18 +1539,20 @@ DevPathToTextiSCSI (
 {
   ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
   UINT16  Options;
+  UINTN   Index;
 
   ISCSIDevPath = DevPath;
   UefiDevicePathLibCatPrint (
 Str,
-L"iSCSI(%a,0x%x,0x%lx,",
+L"iSCSI(%a,0x%x,0x",
 ISCSIDevPath->TargetName,
-ISCSIDevPath->TargetPortalGroupTag,
-ISCSIDevPath->Lun
+ISCSIDevPath->TargetPortalGroupTag
 );
-
+  for (Index = 0; Index < ARRAY_SIZE (ISCSIDevPath->Lun); Index++) {
+UefiDevicePathLibCatPrint (Str, L"%02x", ISCSIDevPath->Lun[Index]);
+  }
   Options = ISCSIDevPath->LoginOption;
-  UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? 
L"CRC32C" : L"None");
+  UefiDevicePathLibCatPrint (Str, L",%s,", (((Options >> 1) & 0x0001) != 0) ? 
L"CRC32C" : L"None");
   UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? 
L"CRC32C" : L"None");
   if (((Options >> 11) & 0x0001) != 0) {
 UefiDevicePathLibCatPrint (Str, L"%s,", L"None");
-- 
2.16.1.windows.1

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


Re: [edk2] [PATCH v1 21/27] BaseTools: replace string with predefined constant

2018-04-25 Thread Zhu, Yonghong
Should use DT.PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS, because current in the 
file header it use "import Common.DataType as DT".

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 21/27] BaseTools: replace string with predefined constant

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/Ecc/Check.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Ecc/Check.py 
b/BaseTools/Source/Python/Ecc/Check.py
index c0e8006dcc51..6490670b0ddb 100644
--- a/BaseTools/Source/Python/Ecc/Check.py
+++ b/BaseTools/Source/Python/Ecc/Check.py
@@ -787,7 +787,7 @@ class Check(object):
 continue
 SqlCommand = """select Value3 from Inf where BelongsToFile 
=
 (select ID from File where lower(FullPath) 
= lower('%s'))
-and Value2 = '%s'""" % (LibraryIns, 
'LIBRARY_CLASS')
+and Value2 = '%s'""" % (LibraryIns, 
PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS)
 RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
 IsFound = False
 for Record in RecordSet:
-- 
2.16.2.windows.1

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


Re: [edk2] [PATCH v1 18/27] BaseTools: Replace PCD type strings with predefined constant

2018-04-25 Thread Zhu, Yonghong
GenFdsGlobalVariable.py: should use DataType.TAB_PCDS_FIXED_AT_BUILD format, 
because it use import Common.DataType as DataType in file header.

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v1 18/27] BaseTools: Replace PCD type strings with predefined 
constant

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py |  4 +--
 BaseTools/Source/Python/AutoGen/GenC.py|  4 +--
 BaseTools/Source/Python/AutoGen/GenPcdDb.py|  2 +-
 BaseTools/Source/Python/Common/DataType.py |  3 ++
 BaseTools/Source/Python/Common/MigrationUtilities.py   |  2 +-
 BaseTools/Source/Python/GenFds/FfsInfStatement.py  |  2 +-
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  4 +--
 BaseTools/Source/Python/Workspace/DecBuildData.py  | 22 +++---
 BaseTools/Source/Python/Workspace/DscBuildData.py  | 22 +++---
 BaseTools/Source/Python/Workspace/InfBuildData.py  | 26 -
 BaseTools/Source/Python/build/BuildReport.py   | 30 
++--
 11 files changed, 62 insertions(+), 59 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 2f60c17439c0..9b2164ed8216 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -870,8 +870,8 @@ class WorkspaceAutoGen(AutoGen):
 def _CheckPcdDefineAndType(self):
 PcdTypeList = [
 TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, 
TAB_PCDS_FEATURE_FLAG,
-TAB_PCDS_DYNAMIC, #"DynamicHii", "DynamicVpd",
-TAB_PCDS_DYNAMIC_EX, # "DynamicExHii", "DynamicExVpd"
+TAB_PCDS_DYNAMIC, #TAB_PCDS_DYNAMIC_HII, TAB_PCDS_DYNAMIC_VPD,
+TAB_PCDS_DYNAMIC_EX, # TAB_PCDS_DYNAMIC_EX_HII, 
+ TAB_PCDS_DYNAMIC_EX_VPD
 ]
 
 # This dict store PCDs which are not used by any modules with 
specified arches diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index 86b21de31eee..6b2ee87b2211 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -28,8 +28,8 @@ from IdfClassObject import *
 
 ## PCD type string
 gItemTypeStringDatabase  = {
-TAB_PCDS_FEATURE_FLAG   :   'FixedAtBuild',
-TAB_PCDS_FIXED_AT_BUILD :   'FixedAtBuild',
+TAB_PCDS_FEATURE_FLAG   :   TAB_PCDS_FIXED_AT_BUILD,
+TAB_PCDS_FIXED_AT_BUILD :   TAB_PCDS_FIXED_AT_BUILD,
 TAB_PCDS_PATCHABLE_IN_MODULE:   'BinaryPatch',
 TAB_PCDS_DYNAMIC:   '',
 TAB_PCDS_DYNAMIC_DEFAULT:   '',
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py 
b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index afd690bc5b1b..9374ca4820ef 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -1217,7 +1217,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, 
DynamicPcdList, Phase):
 Pcd.InitString = 'UNINIT'
 
 if Pcd.DatumType == 'VOID*':
-if Pcd.Type not in ["DynamicVpd", "DynamicExVpd"]:
+if Pcd.Type not in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:
 Pcd.TokenTypeList = ['PCD_TYPE_STRING']
 else:
 Pcd.TokenTypeList = []
diff --git a/BaseTools/Source/Python/Common/DataType.py 
b/BaseTools/Source/Python/Common/DataType.py
index 13e9c96dd51b..40a162adf33c 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -218,6 +218,9 @@ TAB_PCDS_DYNAMIC_HII = 'DynamicHii'
 PCD_DYNAMIC_TYPE_SET = {TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, 
TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII}  PCD_DYNAMIC_EX_TYPE_SET = 
{TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_VPD, 
TAB_PCDS_DYNAMIC_EX_HII}
 
+# leave as a list for order
+PCD_TYPE_LIST = [TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, 
+TAB_PCDS_FEATURE_FLAG, TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_EX]
+
 TAB_PCDS_FIXED_AT_BUILD_NULL = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD  
TAB_PCDS_FIXED_AT_BUILD_COMMON = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT 
+ TAB_ARCH_COMMON
 TAB_PCDS_FIXED_AT_BUILD_IA32 = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT 
+ TAB_ARCH_IA32 diff --git 
a/BaseTools/Source/Python/Common/MigrationUtilities.py 
b/BaseTools/Source/Python/Common/MigrationUtilities.py
index e9f1cabcb794..0c93c72a60f6 100644
--- a/BaseTools/Source/Python/Common/MigrationUtilities.py
+++ b/BaseTools/Source/Python/Common/MigrationUtilities.py
@@ -34,7 +34,7 @@ def SetCommon(Common, XmlCommon):