]> git.proxmox.com Git - mirror_edk2.git/log
mirror_edk2.git
6 years agoBaseTools: refactor and remove un-needed use of .keys() on dictionaries
Carsey, Jaben [Tue, 17 Apr 2018 14:40:15 +0000 (22:40 +0800)]
BaseTools: refactor and remove un-needed use of .keys() on dictionaries

sometimes just delete it.
sometimes the loop needed .values() instead

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: use predefined constants instead of local strings
Carsey, Jaben [Mon, 16 Apr 2018 13:52:13 +0000 (21:52 +0800)]
BaseTools: use predefined constants instead of local strings

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: refactor and remove more keys() usage
Carsey, Jaben [Tue, 10 Apr 2018 14:20:06 +0000 (22:20 +0800)]
BaseTools: refactor and remove more keys() usage

this is no longer required to make dictionary objects iterable.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: Eot - Remove FvImage file
Carsey, Jaben [Mon, 16 Apr 2018 17:48:22 +0000 (01:48 +0800)]
BaseTools: Eot - Remove FvImage file

move the single used class from FvImage to Eot
delete the FvImage file
remove FvImage from makefile

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: Remove un-needed list comprehension
Carsey, Jaben [Wed, 11 Apr 2018 23:08:07 +0000 (07:08 +0800)]
BaseTools: Remove un-needed list comprehension

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: remove duplicate function name
Carsey, Jaben [Wed, 11 Apr 2018 23:08:05 +0000 (07:08 +0800)]
BaseTools: remove duplicate function name

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoFatPkg/EnhancedFatDxe: Ensure traverse of subtasks is delete-safe
Hao Wu [Sat, 14 Apr 2018 03:06:13 +0000 (11:06 +0800)]
FatPkg/EnhancedFatDxe: Ensure traverse of subtasks is delete-safe

Within function FatQueueTask(), the traverse of FAT subtasks for
executing the disk read/write is not delete-safe.

For the below case:

FatDiskIo(): When non-blocking access, creates subtasks and creates
event (FatOnAccessComplete, NOTIFY level) when subtasks finish.

FatQueueTask(): Traverses the subtasks and submits them one by one at
Tpl lower than NOTIFY.

Disk R/W completes really quick.

FatOnAccessComplete(): Removes the finished subtask, causing the
traverse in FatQueueTask() broken.

This commits will refine the subtask traverse in FatQueueTask() to be
delete-safe.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
6 years agoIntelFrameworkModulePkg IsaSerialDxe: Update algorithm to calculate Divisor
Liming Gao [Thu, 12 Apr 2018 13:38:37 +0000 (21:38 +0800)]
IntelFrameworkModulePkg IsaSerialDxe: Update algorithm to calculate Divisor

To align the way in MdeModulePkg SerialPortLib and PciSioSerialDxe driver,
Divisor is added by one when the reminder is more than half (16 * BaudRate).

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
6 years agoBaseTools: change DscBuildData functions without need for self to staticmethod
Carsey, Jaben [Fri, 13 Apr 2018 20:51:29 +0000 (04:51 +0800)]
BaseTools: change DscBuildData functions without need for self to staticmethod

prepend functiosn with @staticmethod
change calls to use class name, not self

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: remove an unused file
Carsey, Jaben [Fri, 13 Apr 2018 17:10:00 +0000 (01:10 +0800)]
BaseTools: remove an unused file

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: delete an unused file
Carsey, Jaben [Fri, 13 Apr 2018 16:58:33 +0000 (00:58 +0800)]
BaseTools: delete an unused file

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: FfsInfStatement - remove unused function
Carsey, Jaben [Fri, 13 Apr 2018 20:51:36 +0000 (04:51 +0800)]
BaseTools: FfsInfStatement - remove unused function

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: FdfParser - refactor functions to make static
Carsey, Jaben [Fri, 13 Apr 2018 20:51:35 +0000 (04:51 +0800)]
BaseTools: FdfParser - refactor functions to make static

make functions that doesn't use self into @staticmethod

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: FdfParser refactor to remove a dictionary
Carsey, Jaben [Fri, 13 Apr 2018 20:51:34 +0000 (04:51 +0800)]
BaseTools: FdfParser refactor to remove a dictionary

__GetInfStatement() does not use the dict parameter, so remove it
from the API and from all callers.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: refactor DepexSection.GenSection
Carsey, Jaben [Fri, 13 Apr 2018 20:51:33 +0000 (04:51 +0800)]
BaseTools: refactor DepexSection.GenSection

change default parameter value to None since the parameter isn't used.
remove temporary dictionary and just do the reaplce call.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: use dictionary.get() when we have value if not found
Carsey, Jaben [Fri, 13 Apr 2018 20:51:32 +0000 (04:51 +0800)]
BaseTools: use dictionary.get() when we have value if not found

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: move RegEx compile out of loops
Carsey, Jaben [Fri, 13 Apr 2018 20:51:31 +0000 (04:51 +0800)]
BaseTools: move RegEx compile out of loops

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: Remove unused functions from DscBuildData
Carsey, Jaben [Fri, 13 Apr 2018 20:51:30 +0000 (04:51 +0800)]
BaseTools: Remove unused functions from DscBuildData

3 functions were never called:
_dumpPcdInfo
__STRING2OCTList
__UNICODE2OCTList

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: remove unused local variable.
Carsey, Jaben [Fri, 13 Apr 2018 20:51:28 +0000 (04:51 +0800)]
BaseTools: remove unused local variable.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: fix None comparisons
Carsey, Jaben [Fri, 13 Apr 2018 00:02:10 +0000 (08:02 +0800)]
BaseTools: fix None comparisons

when comparing a list/string against None and empty, just compare the object.
when comparing against None, dont use !=, ==, <>

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: reduce list usage when not needed
Carsey, Jaben [Tue, 10 Apr 2018 23:17:24 +0000 (07:17 +0800)]
BaseTools: reduce list usage when not needed

remove not needed lists.  some were just counted and others
should be sets.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: use set instead of list for a variable to be used with in
Carsey, Jaben [Tue, 10 Apr 2018 23:17:23 +0000 (07:17 +0800)]
BaseTools: use set instead of list for a variable to be used with in

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: skip updating temporary variable.
Carsey, Jaben [Tue, 10 Apr 2018 23:17:22 +0000 (07:17 +0800)]
BaseTools: skip updating temporary variable.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: no need to save the data
Carsey, Jaben [Tue, 10 Apr 2018 23:17:21 +0000 (07:17 +0800)]
BaseTools: no need to save the data

It's never accessed.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: use existing shared variable
Carsey, Jaben [Tue, 10 Apr 2018 23:17:20 +0000 (07:17 +0800)]
BaseTools: use existing shared variable

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTool/VfrCompile: make delete[] match with new[]
Dandan Bi [Tue, 10 Apr 2018 07:21:40 +0000 (15:21 +0800)]
BaseTool/VfrCompile: make delete[] match with new[]

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
6 years agoBaseTools/VfrCompile:Fix memory leak issues
Dandan Bi [Tue, 10 Apr 2018 01:35:32 +0000 (09:35 +0800)]
BaseTools/VfrCompile:Fix memory leak issues

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
6 years agoMdePkg/Library/BaseCpuLib: Enable VS2017/ARM64 builds
Pete Batard [Wed, 28 Mar 2018 15:55:21 +0000 (23:55 +0800)]
MdePkg/Library/BaseCpuLib: Enable VS2017/ARM64 builds

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Liming Gao <liming.gao@intel.com>
6 years agoMdePkg/Library/BaseSynchronizationLib: Enable VS2017/ARM64 builds
Pete Batard [Wed, 28 Mar 2018 15:55:20 +0000 (23:55 +0800)]
MdePkg/Library/BaseSynchronizationLib: Enable VS2017/ARM64 builds

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Liming Gao <liming.gao@intel.com>
6 years agoOvmfPkg/PlatformBootManagerLib: add USB keyboard to ConIn
Laszlo Ersek [Sun, 15 Apr 2018 20:34:47 +0000 (22:34 +0200)]
OvmfPkg/PlatformBootManagerLib: add USB keyboard to ConIn

PlatformInitializeConsole() (called by PlatformBootManagerBeforeConsole())
adds elements of "gPlatformConsole" to ConIn / ConOut / ErrOut (as
requested per element) if at boot at least one of ConIn and ConOut doesn't
exist. This typically applies to new VMs, and VMs with freshly recreated
varstores.

Add a USB keyboard wildcard to ConIn via "gPlatformConsole", so that we
not only bind the PS/2 keyboard. (The PS/2 keyboard is added in
PrepareLpcBridgeDevicePath()). Explicitly connecting the USB keyboard is
necessary after commit 245c643cc8b7.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
6 years agoMdeModulePkg/FPDT: Add error message for unsupported case
Dandan Bi [Tue, 10 Apr 2018 05:51:08 +0000 (13:51 +0800)]
MdeModulePkg/FPDT: Add error message for unsupported case

We have updated performance infrastructure in previous commits:
between
https://github.com/tianocore/edk2/commit/73fef64f14d1b97ae9bd4705df3becc022391eba
and
https://github.com/tianocore/edk2/commit/115eae650bfd2be2c2bc37360f4a755065e774c4
Update FPDT drivers to collect the performance data reported by
gEdkiiFpdtExtendedFirmwarePerformanceGuid.
The old implementation which collected performance data through
gEfiFirmwarePerformanceGuid is not supported now.
We should add error message to remind user for this unsupported
case in case anyone use it by mistake.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
6 years agoSignedCapsulePkg SystemFirmwareUpdateDxe: Fix failure caused by d69d922
Star Zeng [Fri, 13 Apr 2018 09:55:14 +0000 (17:55 +0800)]
SignedCapsulePkg SystemFirmwareUpdateDxe: Fix failure caused by d69d922

d69d9227d046211265de1fab5580c50a65944614 caused system firmware update
failure. It is because FindMatchingFmpHandles() is expected to return
handles matched, but the function returns all handles found.

This patch is to fix the issue.
This patch also assigns mSystemFmpPrivate->Handle for "case 1:" path
in case the Handle is needed by other place in future.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
6 years agoCryptoPkg/OpensslLib: Update OpenSSL version to 1.1.0h
Long Qin [Thu, 12 Apr 2018 02:58:45 +0000 (10:58 +0800)]
CryptoPkg/OpensslLib: Update OpenSSL version to 1.1.0h

(https://bugzilla.tianocore.org/show_bug.cgi?id=927)

(V2 Update:
    Removing the wrong "--remote" option from git submodule update
    command in this commit message. Thanks Laszlo's clarification
    to correct this)

Update OpenSSL version to 1.1.0h release (27-Mar-2018) to include the
fix for CVE-2018-0739 issue (Handling of crafted recursive ASN.1
structures can cause a stack overflow and resulting denial of service,
Refer to https://www.openssl.org/news/secadv/20180327.txt for more
information).

Please note "git pull" will not update the submodule repository.
use the following commend to make your existing submodule track this
update:
   $ git submodule update --recursive

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Long Qin <qin.long@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
6 years agoCryptoPkg/OpensslLib: Fix the documentation about submodule update
Long Qin [Thu, 12 Apr 2018 02:50:30 +0000 (10:50 +0800)]
CryptoPkg/OpensslLib: Fix the documentation about submodule update

This patch is to drop "--remote" option from the original suggested
submodule update command ("$ git submodule update --recursive
--remote") in HOWTO document.

"--remote" option will integrate changes from the upstream subproject
with the submodules's "current HEAD", instead of using the edk2
superproject's "recorded SHA-1".

It is important here for the edk2 consumers to updating the working
tree of the submodules to match the commit / release tag that the
superproject expects. So removing "--remote" option to fix this
documentation issue here.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Long Qin <qin.long@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
6 years agoBaseTools: Fix one or more multiply defined symbols found issue
Feng, YunhuaX [Fri, 13 Apr 2018 05:20:31 +0000 (13:20 +0800)]
BaseTools: Fix one or more multiply defined symbols found issue

self.Guids update with package Guids will generate multiply defined
GUID symbols in AutoGen file

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoCryptoPkg/TlsLib: rewrite TlsSetCipherList()
Laszlo Ersek [Sat, 31 Mar 2018 15:33:14 +0000 (17:33 +0200)]
CryptoPkg/TlsLib: rewrite TlsSetCipherList()

Rewrite the TlsSetCipherList() function in order to fix the following
issues:

- Any cipher identifier in CipherId that is not recognized by
  TlsGetCipherMapping() will cause the function to return EFI_UNSUPPORTED.

  This is a problem because CipherId is an ordered preference list, and a
  caller should not get EFI_UNSUPPORTED just because it has an elaborate
  CipherId preference list. Instead, we can filter out cipher identifiers
  that we don't recognize, as long as we keep the relative order intact.

- CipherString is allocated on the stack, with 500 bytes.

  While processing a large CipherId preference list, this room may not be
  enough. Although no buffer overflow is possible, CipherString exhaustion
  can lead to a failed TLS connection, because any cipher names that don't
  fit on CipherString cannot be negotiated.

  Compute CipherStringSize first, and allocate CipherString dynamically.

- Finally, the "@STRENGTH" pseudo cipher name is appended to CipherString.
  (Assuming there is enough room left in CipherString.) This causes
  OpenSSL to sort the cipher list "in order of encryption algorithm key
  length".

  This is a bad idea. The caller specifically passes an ordered preference
  list in CipherId. Therefore TlsSetCipherList() must not ask OpenSSL to
  reorder the list, for any reason. Drop "@STRENGTH".

While at it, fix and unify the documentation of the CipherId parameter.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Qin Long <qin.long@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=915
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
6 years agoCryptoPkg/TlsLib: sanitize lib classes in internal header and INF
Laszlo Ersek [Sat, 31 Mar 2018 20:25:15 +0000 (22:25 +0200)]
CryptoPkg/TlsLib: sanitize lib classes in internal header and INF

"InternalTlsLib.h" includes "BaseCryptLib.h", but the lib class is not
listed in the INF file.

The INF file lists a good number of lib classes, but none of the lib class
headers are included by "InternalTlsLib.h".

Synchronize & sort both lists, while removing those library classes that
aren't actually needed. (IntrinsicLib and OpensslLib have no edk2 class
headers.)

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Qin Long <qin.long@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=915
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
6 years agoCryptoPkg/TlsLib: pre-compute OpensslCipherLength in TlsCipherMappingTable
Laszlo Ersek [Sun, 1 Apr 2018 09:51:46 +0000 (11:51 +0200)]
CryptoPkg/TlsLib: pre-compute OpensslCipherLength in TlsCipherMappingTable

In the next patches, we'll need the lengths of the
TLS_CIPHER_MAPPING.OpensslCipher string fields. These lengths can be
computed at build time; add the new field "OpensslCipherLength", and
introduce the MAP() macro for populating it.

While at it, add some horizontal whitespace to "TlsCipherMappingTable",
and add a comma after the last element. This will come handy in a later
patch.

(The patch does not change the first two columns of
"TlsCipherMappingTable", which can be easily verified with "git show
--word-diff".)

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Qin Long <qin.long@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=915
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
6 years agoCryptoPkg/TlsLib: use binary search in the TlsGetCipherMapping() function
Laszlo Ersek [Sat, 31 Mar 2018 15:06:39 +0000 (17:06 +0200)]
CryptoPkg/TlsLib: use binary search in the TlsGetCipherMapping() function

Improve the performance of the TlsGetCipherMapping() function by adopting
the binary search from DhcpFindOptionFormat()
[MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c].

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Qin Long <qin.long@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=915
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
6 years agoCryptoPkg/TlsLib: replace TlsGetCipherString() with TlsGetCipherMapping()
Laszlo Ersek [Sun, 1 Apr 2018 10:53:23 +0000 (12:53 +0200)]
CryptoPkg/TlsLib: replace TlsGetCipherString() with TlsGetCipherMapping()

In the following patches it will be useful if the IANA CipherId lookup
returns a pointer to the whole matching IANA-to-OpenSSL mapping structure,
not just the OpenSSL cipher suite name. Rename TLS_CIPHER_PAIR and
TlsGetCipherString() to TLS_CIPHER_MAPPING and TlsGetCipherMapping()
respectively, and make the function return a pointer to
TLS_CIPHER_MAPPING.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Qin Long <qin.long@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=915
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
6 years agoNetworkPkg/TlsDxe: clean up byte order conversion for EfiTlsCipherList
Laszlo Ersek [Sat, 31 Mar 2018 14:36:39 +0000 (16:36 +0200)]
NetworkPkg/TlsDxe: clean up byte order conversion for EfiTlsCipherList

Fix the following style issues:

- "Data" is accessed through a pointer to UINT16 rather than to a pointer
  to EFI_TLS_CIPHER. While technically correct, UINT16 is harder to
  interpret against the UEFI spec.

- Array subscripting is written with weird *(Pointer + Offset)
  expressions, rather than with Pointer[Offset].

- The byte order is converted with HTONS(), while it should be NTOHS().
  Either way, use the Data1 and Data2 fields of EFI_TLS_CIPHER instead.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=915
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
6 years agoNetworkPkg/TlsDxe: verify DataSize for EfiTlsCipherList
Laszlo Ersek [Sat, 31 Mar 2018 14:04:10 +0000 (16:04 +0200)]
NetworkPkg/TlsDxe: verify DataSize for EfiTlsCipherList

TlsSetSessionData() shouldn't just ignore an incomplete EFI_TLS_CIPHER
element at the end of "Data":

- Generally speaking, malformed input for a security API is best rejected
  explicitly.

- Specifically speaking, the size of EFI_TLS_CIPHER is 2 bytes. If
  DataSize is 1 on input, then the initial check for (DataSize == 0) will
  fail, but then TlsSetCipherList() will be called with CipherNum=0.

Return EFI_INVALID_PARAMETER from TlsSetSessionData() if "Data" doesn't
contain a whole number of EFI_TLS_CIPHER elements. While at it, introduce
the dedicated variable CipherCount.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=915
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
6 years agoMdePkg/Include/Protocol/Tls.h: pack structures from the TLS RFC
Laszlo Ersek [Sat, 31 Mar 2018 14:20:37 +0000 (16:20 +0200)]
MdePkg/Include/Protocol/Tls.h: pack structures from the TLS RFC

The structures defined in RFC 5246 are not to have any padding between
fields or at the end; use the "pack" pragma as necessary.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=915
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
6 years agoOvmfPkg/TlsAuthConfigLib: configure trusted cipher suites for HTTPS boot
Laszlo Ersek [Sat, 31 Mar 2018 23:27:43 +0000 (01:27 +0200)]
OvmfPkg/TlsAuthConfigLib: configure trusted cipher suites for HTTPS boot

Read the list of trusted cipher suites from fw_cfg and to store it to
EDKII_HTTP_TLS_CIPHER_LIST_VARIABLE.

The fw_cfg file will be formatted by the "update-crypto-policies" utility
on the host side, so that the host settings take effect in guest HTTPS
boot as well. QEMU forwards the file intact to the firmware. The contents
are forwarded by NetworkPkg/HttpDxe (in TlsConfigCipherList()) to
NetworkPkg/TlsDxe (TlsSetSessionData()) and TlsLib (TlsSetCipherList()).

Note: the development of the "update-crypto-policies" feature is underway
at this time. Meanwhile the following script can be used to generate the
binary file for fw_cfg:

  export LC_ALL=C
  openssl ciphers -V \
  | sed -r -n \
      -e 's/^ *0x([0-9A-F]{2}),0x([0-9A-F]{2}) - .*$/\\\\x\1 \\\\x\2/p' \
  | xargs -r -- printf -- '%b' > ciphers.bin

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Gary Ching-Pang Lin <glin@suse.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Gary Lin <glin@suse.com>
Tested-by: Gary Lin <glin@suse.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
[lersek@redhat.com: update commit msg and add script as requested by Gary]
[lersek@redhat.com: update commit msg as requested by Jiaxin]

6 years agoMdeModulePkg/PiSmmIpl: fix non-executable SMM RAM
Jian J Wang [Wed, 11 Apr 2018 06:12:12 +0000 (14:12 +0800)]
MdeModulePkg/PiSmmIpl: fix non-executable SMM RAM

This patch fixes an issue introduced by commit

  5b91bf82c67b586b9588cbe4bbffa1588f6b5926

and

  0c9f2cb10b7ddec56a3440e77219fd3ab1725e5c

This issue will only happen if PcdDxeNxMemoryProtectionPolicy is
enabled for reserved memory, which will mark SMM RAM as NX (non-
executable) during DXE core initialization. SMM IPL driver will
unset the NX attribute for SMM RAM to allow loading and running
SMM core/drivers.

But above commit will fail the unset operation of the NX attribute
due to a fact that SMM RAM has zero cache attribute (MRC code always
sets 0 attribute to reserved memory), which will cause GCD internal
method ConverToCpuArchAttributes() to return 0 attribute, which is
taken as invalid CPU paging attribute and skip the calling of
gCpu->SetMemoryAttributes().

The solution is to make use of existing functionality in PiSmmIpl
to make sure one cache attribute is set for SMM RAM. For performance
consideration, PiSmmIpl will always try to set SMM RAM to write-back.
But there's a hole in the code which will fail the setting write-back
attribute because of no corresponding cache capabilities. This patch
will add necessary cache capabilities before setting corresponding
attributes.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
6 years agoMdeModulePkg/SmmCore: add sanity check for SetMemoryAttributes
Jian J Wang [Wed, 11 Apr 2018 08:35:32 +0000 (16:35 +0800)]
MdeModulePkg/SmmCore: add sanity check for SetMemoryAttributes

Heap Guard feature needs enough memory and paging to work. Otherwise
calling SetMemoryAttributes to change page attribute will fail. This
patch add necessary check of result of calling SetMemoryAttributes.
This can help users to debug their problem in enabling this feature.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
6 years agoMdeModulePkg/DxeCore: add sanity check for SetMemoryAttributes
Jian J Wang [Wed, 11 Apr 2018 08:35:05 +0000 (16:35 +0800)]
MdeModulePkg/DxeCore: add sanity check for SetMemoryAttributes

Heap Guard feature needs enough memory and paging to work. Otherwise
calling SetMemoryAttributes to change page attribute will fail. This
patch add necessary check of result of calling SetMemoryAttributes.
This can help users to debug their problem in enabling this feature.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
6 years agoSignedCapsulePkg SystemCapsuleLib: Change some dbg level to DEBUG_INFO
Star Zeng [Wed, 28 Mar 2018 08:50:00 +0000 (16:50 +0800)]
SignedCapsulePkg SystemCapsuleLib: Change some dbg level to DEBUG_INFO

This debug message should be info instead of error. This patch is to
change the debug level to DEBUG_INFO.
DEBUG((DEBUG_ERROR, "checking FV....0x%08x - 0x%x\n",
       FvHeader, FvHeader->FvLength));    // "Mark"

This comment is inaccurate. This patch is to remove it.
//
// Check section
//

This debug message should be removed as FvHeader may have been out of
range FdStart and FdSize, and the loop will go to "Mark" above again if
FvHeader is not out of range FdStart and FdSize, and then that debug
message will be shown. This patch is to remove this debug message.
DEBUG((DEBUG_ERROR, "Next FV....0x%08x - 0x%x\n",
       FvHeader, FvHeader->FvLength));

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Amy Chan <amy.chan@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
6 years agoMdePkg DxeHstiLib: Fix ErrorString pointer incorrectly calculated
Star Zeng [Wed, 11 Apr 2018 06:18:38 +0000 (14:18 +0800)]
MdePkg DxeHstiLib: Fix ErrorString pointer incorrectly calculated

Fix ErrorString pointer is incorrectly calculated in
InternalHstiIsValidTable().

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
6 years agoArmVirtPkg/ArmVirtQemu: hook NvVarStoreFormattedLib into VariableRuntimeDxe
Laszlo Ersek [Wed, 11 Apr 2018 21:07:59 +0000 (23:07 +0200)]
ArmVirtPkg/ArmVirtQemu: hook NvVarStoreFormattedLib into VariableRuntimeDxe

In spite of both ArmVirtQemu and ArmVirtQemuKernel formatting the variable
store template at build time, link NvVarStoreFormattedLib into
VariableRuntimeDxe via NULL class resolution on both platforms. This lets
us test the depexes implemented in the previous patches.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
6 years agoArmVirtPkg/PlatformHasAcpiDtDxe: depend on gEfiVariableArchProtocolGuid
Laszlo Ersek [Wed, 11 Apr 2018 23:37:21 +0000 (01:37 +0200)]
ArmVirtPkg/PlatformHasAcpiDtDxe: depend on gEfiVariableArchProtocolGuid

PlatformHasAcpiDtDxe consumes the DynamicHii PCD called
"gArmVirtTokenSpaceGuid.PcdForceNoAcpi". The PcdGetBool() library call
terminates in gRT->GetVariable(), in the MdeModulePkg/Universal/PCD/Dxe
driver. Put "gEfiVariableArchProtocolGuid" on PlatformHasAcpiDtDxe's DEPEX
so that we not attempt the call before the PCD driver can successfully
read non-volatile variables.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6 years agoArmPlatformPkg/PL031RealTimeClockLib: depend on gEfiCpuArchProtocolGuid
Laszlo Ersek [Thu, 12 Apr 2018 00:00:13 +0000 (02:00 +0200)]
ArmPlatformPkg/PL031RealTimeClockLib: depend on gEfiCpuArchProtocolGuid

The RealTimeClockLib class is declared under EmbeddedPkg, so that
platforms can provide the internals for the
EmbeddedPkg/RealTimeClockRuntimeDxe driver. In turn the driver produces
the Real Time Clock Arch Protocol, without which UEFI drivers cannot be
dispatched.

The PL031RealTimeClockLib instance calls gDS->SetMemorySpaceAttributes()
in the LibRtcInitialize() public function. This DXE service depends on the
CPU Arch Protocol. Add it to the depex.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Steve Capper <steve.capper@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6 years agoArmPlatformPkg/NorFlashDxe: depend on gEfiCpuArchProtocolGuid
Laszlo Ersek [Wed, 11 Apr 2018 20:59:13 +0000 (22:59 +0200)]
ArmPlatformPkg/NorFlashDxe: depend on gEfiCpuArchProtocolGuid

NorFlashFvbInitialize() calls gDS->SetMemorySpaceAttributes() to mark the
varstore flash region as uncached. This DXE service depends on the CPU
Architectural protocol, and the DXE core is allowed to return
EFI_NOT_AVAILABLE_YET if it hasn't dispatched ArmPkg/Drivers/CpuDxe
earlier. Make the dependency explicit.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Steve Capper <steve.capper@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6 years agoArmPlatformPkg/NorFlashDxe: cue the variable driver with NvVarStoreFormatted
Laszlo Ersek [Wed, 11 Apr 2018 20:50:18 +0000 (22:50 +0200)]
ArmPlatformPkg/NorFlashDxe: cue the variable driver with NvVarStoreFormatted

The BEFORE depex opcode that we currently use to force ourselves in front
of the variable driver cannot be combined with other depex opcodes.
Replace the depex with TRUE, and signal NvVarStoreFormattedLib through the
installation of "gEdkiiNvVarStoreFormattedGuid".

Platforms that rely on NorFlashDxe to format the variable store (as
opposed to formatting a variable store template through an FDF file, as
part of the build) should hook NvVarStoreFormattedLib into the variable
drivers they use, so that the latter await our cue.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Steve Capper <steve.capper@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6 years agoArmPlatformPkg/NorFlashDxe: initialize varstore headers eagerly
Laszlo Ersek [Wed, 11 Apr 2018 20:18:24 +0000 (22:18 +0200)]
ArmPlatformPkg/NorFlashDxe: initialize varstore headers eagerly

The lazy initialization of the varstore FVB makes no longer sense at this
point:

- "mNorFlashInstanceTemplate.Initialize" is NULL;

- in NorFlashCreateInstance(), we only set Instance->Initialize to
  non-NULL -- namely NorFlashFvbInitialize() -- if the FVB stands for the
  variable store (see "ContainVariableStorage" / "SupportFvb");

- we call Instance->Initialize() from three places:

  - from NorFlashWriteSingleBlock(), which is too late for the variable
    read service ("variable write" depends on "variable read");

  - from InitializeFvAndVariableStoreHeaders(), but that is only reachable
    from NorFlashFvbInitialize(), i.e. recursively from
    Instance->Initialize() itself;

  - and from FvbRead(), which is never called by the variable driver, only
    by the FTW driver. However, the variable driver may read (not write)
    the memory-mapped varstore flash chip before the FTW driver is
    dispatched.

Therefore the lazy initialization is both superfluous and insufficient.
Initialize the varstore headers eagerly, before we install the FVB
protocol interface.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Steve Capper <steve.capper@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6 years agoEmbeddedPkg: introduce NvVarStoreFormattedLib
Laszlo Ersek [Wed, 11 Apr 2018 18:58:58 +0000 (20:58 +0200)]
EmbeddedPkg: introduce NvVarStoreFormattedLib

Some platforms don't format a variable store template at build time;
instead they format the non-volatile varstore flash chip during boot,
dynamically. Introduce NvVarStoreFormattedLib to enable such platforms to
delay the "variable read" service drivers until the platform specific
module(s) report that the variable store has been formatted.

The platform-specific module that performs the formatting during startup
is usually an FVB or MM FVB driver. Under the proposed scheme, it becomes
responsible for installing gEdkiiNvVarStoreFormattedGuid with a NULL
interface in the protocol database. In turn, the platform DSC will hook
NvVarStoreFormattedLib into the variable service driver, to make the
latter wait for the FVB driver. Platforms that need not delay the variable
service driver like this may still use the same FVB driver;
gEdkiiNvVarStoreFormattedGuid will simply be ignored.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Steve Capper <steve.capper@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6 years agoArmPkg/CpuDxe: order CpuDxe after ArmGicDxe via protocol depex
Laszlo Ersek [Wed, 11 Apr 2018 16:52:25 +0000 (18:52 +0200)]
ArmPkg/CpuDxe: order CpuDxe after ArmGicDxe via protocol depex

Commit 61a7b0ec634f ("ArmPkg/Gic: force GIC driver to run before CPU arch
protocol driver", 2018-02-06) explains why CpuDxe should be dispatched
after ArmGicDxe.

To implement the ordering, we should use a regular protocol depex rather
than the less flexible AFTER opcode. ArmGicDxe installs
gHardwareInterruptProtocolGuid and gHardwareInterrupt2ProtocolGuid as one
of the last actions on its entry point stack; either of those is OK for
CpuDxe to wait for.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Steve Capper <steve.capper@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6 years agoArmPkg/ArmGicDxe: annotate protocol usage in "ArmGicDxe.inf"
Laszlo Ersek [Wed, 11 Apr 2018 16:40:49 +0000 (18:40 +0200)]
ArmPkg/ArmGicDxe: annotate protocol usage in "ArmGicDxe.inf"

"ArmGicDxe.inf" currently does not document how the protocols in the
[Protocols] section are used. Such comments help us analyze behavior, so
let's add them now.

- gHardwareInterruptProtocolGuid and gHardwareInterrupt2ProtocolGuid are
  always produced on the InterruptDxeInitialize() -> (GicV2DxeInitialize()
  | GicV3DxeInitialize()) -> InstallAndRegisterInterruptService() call
  path.

- gEfiCpuArchProtocolGuid is consumed in the CpuArchEventProtocolNotify()
  protocol notify callback. (Technically this is "conditional"; however
  the firmware cannot work without architectural protocols, so we can call
  it unconditional.)

While at it, drop the gArmGicDxeFileGuid comment from FILE_GUID; we're
going to make that GUID uninteresting soon.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Steve Capper <steve.capper@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6 years agoOmap35xxPkg/InterruptDxe: replace CPU Arch Protocol depex with notify
Laszlo Ersek [Wed, 11 Apr 2018 22:03:45 +0000 (00:03 +0200)]
Omap35xxPkg/InterruptDxe: replace CPU Arch Protocol depex with notify

In a later patch, we'll modify the depex of
"ArmPkg/Drivers/CpuDxe/CpuDxe.inf" (currently "AFTER gArmGicDxeFileGuid")
to "gHardwareInterruptProtocolGuid OR gHardwareInterrupt2ProtocolGuid".

Considering platforms that include "ArmPkg/Drivers/CpuDxe/CpuDxe.inf",
there are two classes:

(1) The platform gets its gHardwareInterruptProtocolGuid or
    gHardwareInterrupt2ProtocolGuid instance from
    "ArmPkg/Drivers/ArmGic/ArmGicDxe.inf". For such platforms, the
    upcoming CpuDxe change is not a problem, because commit 61a7b0ec634f
    made ArmGicDxe wait for the CPU Arch Protocol with a protocol notify.

(2) The platform gets its hardware interrupt protocol(s) from a different
    driver that has a hard depex on the CPU Arch Protocol. The upcoming
    CpuDxe change would lead to a loop in the DXE dispatch order.

In the edk2 tree, only "BeagleBoardPkg/BeagleBoardPkg.dsc" falls in class
(2), and the driver in question is "Omap35xxPkg/InterruptDxe". Port (most
of) commit 61a7b0ec634f to it.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6 years agoSignedCapsulePkg/SystemFirmwareReportDxe: Pass thru on same handle
Kinney, Michael D [Mon, 9 Apr 2018 22:47:19 +0000 (15:47 -0700)]
SignedCapsulePkg/SystemFirmwareReportDxe: Pass thru on same handle

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

Use HandleProtocol() to pass thru a SetImage() call to the
System FMP Protocol that must be on the same handle as the
FMP Protocol.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
6 years agoSignedCapsulePkg/SystemFirmwareUpdateDxe: Single FMP
Kinney, Michael D [Sat, 31 Mar 2018 17:17:29 +0000 (10:17 -0700)]
SignedCapsulePkg/SystemFirmwareUpdateDxe: Single FMP

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

Uninstall all System FMP Protocols for the current FW device.

If an FMP Protocol for the current FW device is already present,
then install the new System FMP protocol onto the same handle as
the FMP Protocol.  Otherwise, install the FMP protocol onto a
new handle.

This supports use cases where multiple capsules for the
same system firmware device are processed on the same
boot of the platform.  It guarantees there is at most one
FMP protocol for each system firmware device.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
6 years agoBaseTools: fix --genfds-multi-thread generate makefile issue
Feng, YunhuaX [Tue, 10 Apr 2018 01:12:49 +0000 (09:12 +0800)]
BaseTools: fix --genfds-multi-thread generate makefile issue

1. when inf file is binary module, not generate makefile,
  so need generate ffs with previous method.
2. generate Ui section maybe override and the string is not
  $(MODULE_NAME)
  like as:
  INF  RuleOverride = UI MdeModulePkg/Application/UiApp/UiApp.inf
3. Trim generate incorrect Offset.raw when some vfr not generate .lst
   file in Debug directory, Trim get the VFR name with the .c files
   replacement.
4. fix some depex file not generate issue

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: argument genfds-multi-thread create GenSec command issue
Feng, YunhuaX [Tue, 10 Apr 2018 01:10:41 +0000 (09:10 +0800)]
BaseTools: argument genfds-multi-thread create GenSec command issue

Issue:
  genfds-multi-thread create makefile before section file generation,
  so it get alignment is zero from empty file. It is incorrect.
solution:
  GenSec get section alignment from input file when the input alignment
  is zero.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: Correct GenSec argument dummy free memory issue
Feng, YunhuaX [Tue, 10 Apr 2018 01:09:45 +0000 (09:09 +0800)]
BaseTools: Correct GenSec argument dummy free memory issue

Free DummyFileBuffer and set DummyFileBuffer to NULL.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: Fix the build error caused by eca980c0c899
Yonghong Zhu [Tue, 10 Apr 2018 13:26:32 +0000 (21:26 +0800)]
BaseTools: Fix the build error caused by eca980c0c899

Roll back the fixed at build pcd collection to include the pcd in
Module and Library.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
6 years agoOvmfPkg: remove BLOCK_MMIO_PROTOCOL and BlockMmioToBlockIoDxe
Laszlo Ersek [Tue, 10 Apr 2018 17:34:50 +0000 (19:34 +0200)]
OvmfPkg: remove BLOCK_MMIO_PROTOCOL and BlockMmioToBlockIoDxe

BLOCK_MMIO_PROTOCOL and BlockMmioToBlockIoDxe were introduced to OvmfPkg
in March 2010, in adjacent commits b0f5144676fa and efd82c5794ec. In the
past eight years, no driver or application seems to have materialized that
produced BLOCK_MMIO_PROTOCOL instances. Meanwhile the UEFI spec has
developed the EFI_RAM_DISK_PROTOCOL, which edk2 implements (and OVMF
includes) as RamDiskDxe.

Rather than fixing issues in the unused BlockMmioToBlockIoDxe driver,
remove the driver, together with the BLOCK_MMIO_PROTOCOL definition that
now becomes unused too.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=926
Reported-by: Steven Shi <steven.shi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
6 years agoBaseTools: Remove unneeded files
Carsey, Jaben [Wed, 4 Apr 2018 15:01:45 +0000 (23:01 +0800)]
BaseTools: Remove unneeded files

These files are not used by any tool:
BaseTools/Source/Python/Common/DecClassObject.py
BaseTools/Source/Python/Common/DscClassObject.py
BaseTools/Source/Python/Common/FdfClassObject.py
BaseTools/Source/Python/Common/InfClassObject.py

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: Remove EdkIIWorkspaceBuild.py from source code
Feng, YunhuaX [Wed, 4 Apr 2018 05:53:13 +0000 (13:53 +0800)]
BaseTools: Remove EdkIIWorkspaceBuild.py from source code

Remove EdkIIWorkspaceBuild.py from source code

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: copy a dictionary from InfClassObject to BuildReport
Carsey, Jaben [Wed, 4 Apr 2018 15:01:44 +0000 (23:01 +0800)]
BaseTools: copy a dictionary from InfClassObject to BuildReport

InfClassObject will be deleted.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: Fix two cases that use GUID CName as PCD Value
Yonghong Zhu [Fri, 23 Mar 2018 03:39:39 +0000 (11:39 +0800)]
BaseTools: Fix two cases that use GUID CName as PCD Value

1. use CName format in components section:
  [Components]
   TestPkg/TestDriver.inf {
     <PcdsFixedAtBuild>
      PcdToken.PcdName |{GUID(TestGuid)}|VOID*|16
  }

2. Use Guid CName format in INF and the Guid is defined in the DEC
file but not write in driver's [Guids] section.
    PcdToken.PcdName  | {GUID(TestGuid)}

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
6 years agoBaseTools: Fix the bug for VOID* pcd max size from component section
Yonghong Zhu [Sat, 17 Mar 2018 07:25:32 +0000 (15:25 +0800)]
BaseTools: Fix the bug for VOID* pcd max size from component section

When the Pcd defined in components section, its value's size is larger
than the value's size in [pcd] section, it cause build error, because
original code use the size get in [pcd] section as max size.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
6 years agoBaseTools: Fix size override issue for Void* Patchable pcd
Yonghong Zhu [Wed, 14 Mar 2018 12:20:23 +0000 (20:20 +0800)]
BaseTools: Fix size override issue for Void* Patchable pcd

when multiple driver link same library, and the drivers override the pcd
to different value in the DSC component section, it cause the pcd size
incorrect.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
6 years agoBaseTools: Fix a bug for Size incorrect of Void* Fixatbuild Pcd
Yonghong Zhu [Wed, 14 Mar 2018 08:51:04 +0000 (16:51 +0800)]
BaseTools: Fix a bug for Size incorrect of Void* Fixatbuild Pcd

when driver link library and there have pcd override in DSC component
section, in the library autogen file, the pcd's size is incorrect, the
size value is from DSC [pcd] section, but not from the override pcd
value that in the [component] section.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
6 years agoBaseTools: Fix a bug for VOID* type Fixatbuild Pcd in Library
Yonghong Zhu [Tue, 13 Mar 2018 14:44:01 +0000 (22:44 +0800)]
BaseTools: Fix a bug for VOID* type Fixatbuild Pcd in Library

The case is a FixedAtBuild VOID* PCD is used from a lib, but is set to a
different sized value in a module INF scope <PcdsFixedAtBuild> section.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
6 years agoBaseTools: Parse PCD GUID name in FILE statement issue
Yunhua Feng [Mon, 9 Apr 2018 01:07:09 +0000 (09:07 +0800)]
BaseTools: Parse PCD GUID name in FILE statement issue

FDF format as below:
FILE APPLICATION = PCD(PcdToken.PcdCName) {

}
when parse PCD, need get all PCDs from Platform and Packages,
use self.BuildObject[self.Platform, Arch] get some modules is wrong.
so use self.BuildObject[self.Platform, Arch, TargetName, ToolChainTag]
get all modules.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: refactor and remove out of date use of .keys()
Carsey, Jaben [Thu, 5 Apr 2018 23:14:02 +0000 (07:14 +0800)]
BaseTools: refactor and remove out of date use of .keys()

this is no longer required to make dictionary objects iterable.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: GenC - move content from both parts of if/else
Carsey, Jaben [Thu, 5 Apr 2018 23:14:01 +0000 (07:14 +0800)]
BaseTools: GenC - move content from both parts of if/else

move identical lines out of both if and else and move 1 level up.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: change more list to set
Carsey, Jaben [Thu, 5 Apr 2018 23:14:00 +0000 (07:14 +0800)]
BaseTools: change more list to set

potentially accelerate "in" testing
remove uncalled function

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: remove unneeded function call
Carsey, Jaben [Thu, 5 Apr 2018 23:13:59 +0000 (07:13 +0800)]
BaseTools: remove unneeded function call

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: change another list to set
Carsey, Jaben [Thu, 5 Apr 2018 23:13:58 +0000 (07:13 +0800)]
BaseTools: change another list to set

potentially accelerate "in" testing which is the use for this variable

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: optimize buildoptions loop
Carsey, Jaben [Thu, 5 Apr 2018 23:13:57 +0000 (07:13 +0800)]
BaseTools: optimize buildoptions loop

change a dict to a double defaultdict to prevent needing to seed innter values.
move "Value" determination under a conditional continue statement

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: simplify testing for existance and containing data
Carsey, Jaben [Thu, 5 Apr 2018 23:13:56 +0000 (07:13 +0800)]
BaseTools: simplify testing for existance and containing data

and remove a duplicate "if" block from 6 lines up.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: change list to set
Carsey, Jaben [Thu, 5 Apr 2018 23:13:55 +0000 (07:13 +0800)]
BaseTools: change list to set

Order is irelevant
duplication is auto-prevented

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: remove unused variables
Carsey, Jaben [Thu, 5 Apr 2018 23:13:54 +0000 (07:13 +0800)]
BaseTools: remove unused variables

some were populated, but never used after.
some were never used.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: replace a dict with a set
Carsey, Jaben [Thu, 5 Apr 2018 23:13:53 +0000 (07:13 +0800)]
BaseTools: replace a dict with a set

As we never use the values, just keep the keys in a set.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: sets are faster to check via "in" due to hashing
Carsey, Jaben [Thu, 5 Apr 2018 23:13:52 +0000 (07:13 +0800)]
BaseTools: sets are faster to check via "in" due to hashing

switch list to set:
1)we dont care about order
2)we only check for membership.

then remove ".keys()" from dict looping:
allow generators opportunity to optimize

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: defaultdict(set) allows us to just add to the set
Carsey, Jaben [Thu, 5 Apr 2018 23:13:51 +0000 (07:13 +0800)]
BaseTools: defaultdict(set) allows us to just add to the set

New sets will get created automatically when needed

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: remove uncalled functions
Carsey, Jaben [Thu, 5 Apr 2018 23:13:50 +0000 (07:13 +0800)]
BaseTools: remove uncalled functions

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: remove unused file
Carsey, Jaben [Thu, 5 Apr 2018 23:13:49 +0000 (07:13 +0800)]
BaseTools: remove unused file

ToolsDefClassObject didnt need Dictionary, it needed an import from there.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: Pcds in [Components] are not display correct in the report
Yonghong Zhu [Mon, 2 Apr 2018 03:18:40 +0000 (11:18 +0800)]
BaseTools: Pcds in [Components] are not display correct in the report

The Pcd used in [Components] section, the PCD value is displayed
incorrect in the build report because the PCD default value was not
override.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
6 years agoBaseTools: Pcd not used info should not in Module PCD section
Yonghong Zhu [Mon, 2 Apr 2018 03:15:27 +0000 (11:15 +0800)]
BaseTools: Pcd not used info should not in Module PCD section

Pcds in Conditional Directives and Pcds not used are Platform Level
info, it should not display in Module PCD Section.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
6 years agoBaseTools: dont make temporary dict
Carsey, Jaben [Thu, 5 Apr 2018 14:00:24 +0000 (22:00 +0800)]
BaseTools: dont make temporary dict

just make the key list directly

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: Remove FdfParserLite.py from source since it is not used
Feng, YunhuaX [Wed, 4 Apr 2018 05:53:13 +0000 (13:53 +0800)]
BaseTools: Remove FdfParserLite.py from source since it is not used

Remove FdfParserLite.py from source code since it is not used.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoMdeModulePkg/Gcd: Suppress incorrect compiler/analyzer warnings
Star Zeng [Sun, 8 Apr 2018 01:27:35 +0000 (09:27 +0800)]
MdeModulePkg/Gcd: Suppress incorrect compiler/analyzer warnings

It is caused by 0c9f2cb10b7ddec56a3440e77219fd3ab1725e5c
and false positive.
Initialize CpuArchAttributes to suppress incorrect
compiler/analyzer warnings.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
6 years agoBaseTools: small cleanup
Carsey, Jaben [Wed, 4 Apr 2018 20:56:57 +0000 (04:56 +0800)]
BaseTools: small cleanup

just deleting else: then pass as they have no effect.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: Autogen - change from list to set
Carsey, Jaben [Wed, 4 Apr 2018 20:56:56 +0000 (04:56 +0800)]
BaseTools: Autogen - change from list to set

by changing from list to set(), we can skip all the preprocessing
to prevent duplication and we dont need to convert to a set() later
on for each use

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: move RegEx to root of file and share it
Carsey, Jaben [Wed, 4 Apr 2018 20:56:55 +0000 (04:56 +0800)]
BaseTools: move RegEx to root of file and share it

make it easy to import and use by others

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: remove redundant check
Carsey, Jaben [Tue, 3 Apr 2018 22:34:06 +0000 (06:34 +0800)]
BaseTools: remove redundant check

The RegEx matches begining and end of the string, dont then check length.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: AutoGen - use the new shared RegEx
Carsey, Jaben [Tue, 3 Apr 2018 22:34:05 +0000 (06:34 +0800)]
BaseTools: AutoGen - use the new shared RegEx

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
6 years agoBaseTools: Add new RegEx pattern to GlobalData
Carsey, Jaben [Tue, 3 Apr 2018 22:34:04 +0000 (06:34 +0800)]
BaseTools: Add new RegEx pattern to GlobalData

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>