Compare commits

...

447 Commits

Author SHA1 Message Date
3e72ffe8af BaseTools: Update Rsa2048Sha256Sign to use openssl dgst option
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Qin Long <qin.long@intel.com>
Reviewed-by: Qin Long <qin.long@intel.com>
(cherry picked from commit d1b777440b)
2018-03-28 14:39:17 +08:00
89b2d05780 BaseTools: Update Rsa2048Sha256Sign to use openssl standard options
sha256 is not the standard option. It should be replaced by sha -sha256.
Otherwise, it doesn't work in MAC OS.

In V2, update the option to sha1 -sha256.
In late openssl version >= 1.1, there is no sha option, but has sha1,sha256.
In previous openssl version < 1.1, there is no sha256, but has sha,sha1.
To work with all openssl version, use sha1 -sha256 for it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liao Jui-peng <jui-pengx.liao@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 1d574dfc15)
2018-03-28 14:39:16 +08:00
bc9cea5c29 MdeModulePkg/UsbKb: fix shell edit cannot read '!@#$%^&*' characters
Commit 5563281fa2
* ShellPkg/[hex]edit: use SimpleTextInEx to read console
changes shell edit and hexedit to read input through SimpleTextInEx.

It exposes a issue in UsbKeyboard driver:
Per UEFI Spec,
When interpreting the data from this function (ReadKeyStrokeEx), it
should be noted that if a class of printable characters that are
normally adjusted by shift modifiers (e.g. Shift Key + "f" key) would
be presented solely as a KeyData.Key.UnicodeChar without the
associated shift state. So in the previous example of a Shift Key +
"f" key being pressed, the only pertinent data returned would be
KeyData.Key.UnicodeChar with the value of "F".

UsbKeyboard driver does convert Shift Key + "f" to "F" without the
shift state. But it doesn't do the conversion for all printable
characters, e.g.: Shift Key + "1" --> "!".

The root cause is today's logic to check whether a character is
printable or not is as below:
  if ((KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_CAPS_LOCK)
      != 0) {

So it only converts Shift + "a"-"z", but doesn't for Shift + "0"-"9",
and Shift + "["...

The patch updates the check logic as below to fix the issue:
  if ((KeyDescriptor->Unicode != CHAR_NULL) &&
      (KeyDescriptor->ShiftedUnicode != CHAR_NULL) &&
      (KeyDescriptor->Unicode != KeyDescriptor->ShiftedUnicode)) {

The above check is TRUE when the character is printable and
it's *really* affected by Shift key.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit dd190645eb)
2018-03-26 09:32:04 +08:00
d5bc5f1368 BaseTool: Fixed the issue of empty PcdDB.
If there is no dynamic pcds, there should be DB header
in the Pcd DataBase.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 0a4f2d4869)
2018-03-23 11:31:55 +08:00
c91229c9b9 BaseTools: Add the missing package include directory in PcdValueInit Makefile
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Feng Bob C <bob.c.feng@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit b005802a1c)
2018-03-23 11:31:53 +08:00
0a93e457f7 MdeModulePkg/CapsuleApp: Fix logic bug in CleanGatherList()
https://bugzilla.tianocore.org/show_bug.cgi?id=905

Fix pointer math when more than one capsule is passed
to the CapsuleApp.  Use the ContinuationPointer from
the last array entry instead of the first array entry.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@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>
(cherry picked from commit 845f7cfef2)
2018-03-22 12:44:08 +08:00
2e8ea3f20b SecurityPkg Tpm12CommandLib: Fix TPM12 GetCapability response error
TPM12 command lib doesn't convert Response Size before using. Add logic
to fix the issue.

Cc: Long Qin <qin.long@intel.com>
Cc: Yao Jiewen <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
(cherry picked from commit 28892d768b)
2018-03-21 16:46:25 +08:00
cf54069a36 SecurityPkg Tpm2CommandLib: Fix TPM2.0 response memory overflow
TPM2.0 command lib always assumes TPM device and transmission channel can
respond correctly. But it is not true when communication channel is exploited
and wrong data is spoofed. Add more logic to prohibit memory overflow attack.

Cc: Long Qin <qin.long@intel.com>
Cc: Yao Jiewen <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
(cherry picked from commit dd577319e8)
2018-03-21 16:46:24 +08:00
7970391e70 BaseTools: Override Max size by build Option Pcd for HII type
Current code will generate maxsize for HII type PCD when parser DSC
file, while this HII type PCD value maybe override in build command
per --pcd option, so the max size need re-calculate.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit c8ae65ac52)
2018-03-21 11:49:32 +08:00
f67d8a58cd BaseTools: Fix bug for --pcd VOID* type when no max size is specified
when VOID* type non-structure pcd used in --pcd, and its max size is not
specified in DSC or its value is hex value, build break due to the code
int(Pcd.MaxDatumSize,10).
Now this patch remove this code, because tool will calculate the size
info in later phase.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 29d521b9fa)
2018-03-21 11:49:31 +08:00
dfdb3625ef BaseTools: Add Feature Flag Pcd Type into Override list
when only define the PCD in the DEC file, and use --pcd feature,
we also need cover this case for Feature Flag Type.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit b7bfcd1a7e)
2018-03-21 11:49:31 +08:00
fa8dba9f2f SourceLevelDebugPkg DebugCommUsb3: Return error when debug cap is reset
When source level debug is enabled, but debug cable is not connected,
XhcResetHC() in XhciReg.c will reset the host controller, the debug
capability registers will be also reset. After the code in
InitializeUsbDebugHardware() sets DCE bit and LSE bit to "1" in DCCTRL,
there will be DMA on 0 (the value of some debug capability registers
for data transfer is 0) address buffer, fault info like below will
appear when IOMMU based on VTd is enabled.

  VER_REG     - 0x00000010
  CAP_REG     - 0x00D2008C40660462
  ECAP_REG    - 0x0000000000F050DA
  GSTS_REG    - 0xC0000000
  RTADDR_REG  - 0x0000000086512000
  CCMD_REG    - 0x2800000000000000
  FSTS_REG    - 0x00000002
  FECTL_REG   - 0xC0000000
  FEDATA_REG  - 0x00000000
  FEADDR_REG  - 0x00000000
  FEUADDR_REG - 0x00000000
  FRCD_REG[0] - 0xC0000006000000A0 0000000000000000
    Fault Info - 0x0000000000000000
    Source - B00 D14 F00
    Type - 1 (read)
    Reason - 6
  IVA_REG     - 0x0000000000000000
  IOTLB_REG   - 0x1200000000000000

This patch is to return error for the case.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit df67a480eb)
2018-03-21 10:27:46 +08:00
c01ec8dc8f MdeModulePkg/DxeMain: Fix BSP interrupts reenabled in ExitBootServices
Within function CoreExitBootServices(), this commit will move the call
of:

MemoryProtectionExitBootServicesCallback();

before:

SaveAndSetDebugTimerInterrupt (FALSE);
and
gCpu->DisableInterrupt (gCpu);

The reason is that, within MemoryProtectionExitBootServicesCallback(),
APIs like RaiseTpl and RestoreTpl maybe called. An example will be:

DebugLib (using PeiDxeDebugLibReportStatusCode instance)
 |
 v
ReportStatusCodeLib (using DxeReportStatusCodeLib instance)
 |
 v
Raise/RestoreTpl

The call of Raise/RestoreTpl APIs will re-enable BSP interrupts. Hence,
this commit refine the calling sequence to ensure BSP interrupts before
leaving CoreExitBootServices().

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit bce776a5b6)
2018-03-20 16:12:55 +08:00
bd1c83ca51 UefiCpuPkg/MpInitLib: Disable interrupt at ExitBootServices AP Mwait
Within function ApWakeupFunction():

When source level debugger is enabled, AP interrupts will be enabled by
EnableDebugAgent(). Then the AP function will be executed by:

Procedure (Parameter);

After the AP function returns, AP interrupts will be disabled when the
APs are placed in loop mode (both HltLoop and MwaiLoop).

However, at ExitBootServices, ApWakeupFunction() is called with
'Procedure' equals to RelocateApLoop().

(ExitBootServices callback registered within InitMpGlobalData())

RelocateApLoop() never returns, so it has to disable the AP interrupts by
itself. However, we find that interrupts are only disabled for the
HltLoop case, but not for the MwaitLoop case (within file MpFuncs.nasm).

This commit adds the missing disabling of AP interrupts for MwaitLoop.

Also, for X64, this commit will disable the interrupts before switching to
32-bit mode.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
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>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jeff Fan <vanjeff_919@hotmail.com>
(cherry picked from commit a7bbe9d20b)
2018-03-20 16:12:54 +08:00
f8237affd2 IntelSiliconPkg/Vtd: Add more debug info.
Add more debug info for reason code.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-20 08:54:29 +08:00
8cc5e08479 IntelSiliconPkg/Vtd: Add missing dump in ExtContext.
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-20 08:54:28 +08:00
4e9d0da3ca IntelSiliconPkg/Vtd: Add DMA_CTRL_PLATFORM_OPT_IN_FLAG dump
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-20 08:54:26 +08:00
a8fcbd0016 Edk2: Retire Edk2Setup.bat
Edk2Setup.bat is out of maintain. It is a draft version batch file, and not
implement all features listed in its header file. To avoid the confuse,
drop it from edk2 project, and keep edksetup.bat only.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit c8e36b75b5)
2018-03-19 14:56:36 +08:00
d051df63df ShellBinPkg: Update ReadMe.txt
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 909762d078)
2018-03-19 14:39:58 +08:00
8aa528c82a ShellBinPkg: Ia32/X64 Shell binary update.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 3f903173fa)
2018-03-19 14:39:57 +08:00
0e1be48bdd MdeModulePkg/PciHostBridgeLib.h: add address Translation
Add Translation field to PCI_ROOT_BRIDGE_APERTURE. Translation is used
to represent the difference between device address and host address,
if they are not the same on some platforms.

In UEFI 2.7, "Address Translation Offset" is "Offset to apply to the
Starting address to convert it to a PCI address".  This means:

  Translation = device address - host address

So we also use the above calculation for this Translation field to
keep consistent.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Signed-off-by: Yi Li <phoenix.liyi@huawei.com>
Reviewed-by: Ni Ruiyu <ruiyu.ni@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
(cherry picked from commit 5bb1866e53)
2018-03-19 10:33:32 +08:00
3570083129 BaseTools: Add PackageDocumentTools into Scripts folder
This tool is used to generate the document for edk2 packages. The
generated document will be in UDK release. For example, UDK2017
document can be found in:
https://github.com/tianocore/tianocore.github.io/wiki/UDK2017#documentation

Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 7ccc9c954c)
2018-03-19 10:05:40 +08:00
f68206261d BaseTools: Fix bug for VOID* DynamicDefault Pcd use Flexible format
define a flexible pcd format in Dyanmic/DynamicExDefault section,
it cause build error.
[PcdsDynamicExDefault.common.DEFAULT]
  pcdToken.Name|{GUID("11111111-2222-42eb-b5eb-fef31d207cb4")}

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 316b43dee5)
2018-03-19 10:05:39 +08:00
376e4ec9ac BaseTools: Detect structure pcd header file change.
Detect structure pcd header file change

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 34d808add3)
2018-03-19 10:05:39 +08:00
61c0fb297d BaseTools: --hash --binary-destination generate wrong binary path
Option --hash --binary-destination generate Binaries section in
the inf file, but the path of ASL file is begin with
Output directory,  so need replace Output directory with '',
will get the file name RamDisk.aml

Incorrect AML file path in inf file on linux:
[Binaries.X64]
  PE32|RamDiskDxe.efi

ASL|home/tiano/Desktop/hash/edk2/Build/OvmfX64/RELEASE_GCC5/X64
/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe/OUTPUT/RamDisk.aml
  DXE_DEPEX|RamDiskDxe.depex
  BIN|RamDiskDxeOffset.bin

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: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 90456c3c06)
2018-03-19 10:05:38 +08:00
ca0b3a0ef2 SecurityPkg OpalPasswordDxe:Fix wrong BufferSize input to UnicodeSPrint
Current code uses string length as BufferSize input to UnicodeSPrint,
it is wrong and makes the pop up string trimmed. The BufferSize input
to UnicodeSPrint should be the size, in bytes, of the output buffer.

This is to use sizeof (mPopUpString) as the BufferSize input to
UnicodeSPrint, it also updates array size of mPopUpString from 256 to
100 that is enough, otherwise the pop up string may be too long.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@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>
(cherry picked from commit aa0857304e)
2018-03-17 15:51:21 +08:00
5af1943160 SecurityPkg OpalPasswordPei: Go next when AhciModeInitialize is failed
Go to next loop instead of going to unlock OPAL password when
AhciModeInitialize is failed.

It is just error handling.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@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>
(cherry picked from commit e3df050e51)
2018-03-17 15:51:20 +08:00
f4d825eb43 SecurityPkg OpalPasswordDxe: Move OPAL request variable definition
Move OPAL request variable definition from OpalHiiFormValues.h to
OpalHii.h.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@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>
(cherry picked from commit 849c684b86)
2018-03-17 15:51:20 +08:00
8f75e458a0 SecurityPkg OpalPasswordDxe: Return directly if no any device
Return directly if no any device in EndOfDxe notification.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@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>
(cherry picked from commit fbe1328a51)
2018-03-17 15:51:19 +08:00
61384921e0 MdeModulePkg/DxeCapsuleLibFmp: Add more check for the UX capsule
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit d0976b9acc)
2018-03-16 17:37:27 +08:00
a508ac4b01 UefiCpuPkg CpuExceptionHandlerLib: use FixedPcdGetSize() as the macro value
FixedPcdGetSize() is used as the macro value, PcdGetSize() is used as global
variable or function. Here usage is to access macro value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Wang Jian J <jian.j.wang@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
(cherry picked from commit a24de121cf)
2018-03-16 15:52:45 +08:00
7e3639367e MdeModulePkg BrotliLib: Rename function with the specific lib name
This change is to avoid the function conflict.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 792ace0ac3)
2018-03-16 15:52:44 +08:00
db82ec1d2f MdeModulePkg/PiSmmCore: fix #PF caused by freeing read-only memory
SMM core will add a HEADER before each allocated pool memory and clean
up this header once it's freed. If a block of allocated pool is marked
as read-only after allocation (EfiRuntimeServicesCode type of pool in
SMM will always be marked as read-only), #PF exception will be triggered
during memory pool freeing.

Normally EfiRuntimeServicesCode type of pool should not be freed in the
real world. But some test suites will actually do memory free for all
types of memory for the purpose of functionality and conformance test.
So this issue should be fixed anyway.

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: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit a2f32ef6ff)
2018-03-16 15:14:32 +08:00
6a46ff8910 MdeModulePkg/Core: fix bits operation error on a boundary condition
If given address is on 64K boundary and the requested bit number is 64,
all SetBits(), ClearBits() and GetBits() will encounter ASSERT problem
in trying to do a 64 bits of shift, which is not allowed by LShift() and
RShift(). This patch tries to fix this issue by turning bits operation
into whole integer operation in such situation.

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: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 36f2f049a8)
2018-03-16 15:14:32 +08:00
c5108f74f8 MdeModulePkg/PiSmmCore: fix bits operation error on a boundary condition
If given address is on 64K boundary and the requested bit number is 64,
all SetBits(), ClearBits() and GetBits() will encounter ASSERT problem
in trying to do a 64 bits of shift, which is not allowed by LShift() and
RShift(). This patch tries to fix this issue by turning bits operation
into whole integer operation in such situation.

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: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 883787a2c6)
2018-03-16 15:14:31 +08:00
7edd705c04 MdeModulePkg/Core: allow HeapGuard even before CpuArchProtocol installed
Due to the fact that HeapGuard needs CpuArchProtocol to update page
attributes, the feature is normally enabled after CpuArchProtocol is
installed. Since there're some drivers are loaded before CpuArchProtocl,
they cannot make use HeapGuard feature to detect potential issues.

This patch fixes above situation by updating the DXE core to skip the
NULL check against global gCpu in the IsMemoryTypeToGuard(), and adding
NULL check against gCpu in SetGuardPage() and UnsetGuardPage() to make
sure that they can be called but do nothing. This will allow HeapGuard to
record all guarded memory without setting the related Guard pages to not-
present.

Once the CpuArchProtocol is installed, a protocol notify will be called
to complete the work of setting Guard pages to not-present.

Please note that above changes will cause a #PF in GCD code during cleanup
of map entries, which is initiated by CpuDxe driver to update real mtrr
and paging attributes back to GCD. During that time, CpuDxe doesn't allow
GCD to update memory attributes and then any Guard page cannot be unset.
As a result, this will prevent Guarded memory from freeing during memory
map cleanup.

The solution is to avoid allocating guarded memory as memory map entries
in GCD code. It's done by setting global mOnGuarding to TRUE before memory
allocation and setting it back to FALSE afterwards in GCD function
CoreAllocateGcdMapEntry().

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 7fef06af4e)
2018-03-16 15:14:30 +08:00
81725e2278 SecurityPkg/dec: remove TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
(cherry picked from commit 89b1612fcf)
2018-03-16 14:38:28 +08:00
c54db16f84 SecurityPkg/include: remove TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
(cherry picked from commit f5a343f5ef)
2018-03-16 14:38:26 +08:00
c20577b42c SecurityPkg/TrEEVendorLib: remove TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
(cherry picked from commit 8afbd22eea)
2018-03-16 14:38:24 +08:00
428d9f2825 SecurityPkg/TrEEPhysicalPresenceLib: remove TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
(cherry picked from commit a35ecb70b1)
2018-03-16 14:38:22 +08:00
25d984be12 SecurityPkg/Tpm2DeviceLibTrEE: remove TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
(cherry picked from commit 64047cb68c)
2018-03-16 14:38:20 +08:00
2dbb81890c SecurityPkg/TrEEConfig: remove TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
(cherry picked from commit a5baa7b914)
2018-03-16 14:38:18 +08:00
50274a868f SecurityPkg/TrEEPei: remove TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
(cherry picked from commit e1b3759079)
2018-03-16 14:38:16 +08:00
70fab05654 SecurityPkg/TrEEDxe: remove TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
(cherry picked from commit 9aeebd913e)
2018-03-16 14:38:14 +08:00
bd8a50bac5 SecurityPkg/TrEESmm: remove TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
(cherry picked from commit 53a6b65604)
2018-03-16 14:38:12 +08:00
3d7738a3fd SecurityPkg/dsc: remove TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
(cherry picked from commit ff469eae2c)
2018-03-16 14:38:10 +08:00
d223f9e697 Vlv2TbltDevicePkg/dsc/fdf: use Tcg2 instead of TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: David Wei <david.wei@intel.com>
Cc: Mang Guo <mang.guo@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
Reviewed-by: Mang Guo <mang.guo@intel.com>
(cherry picked from commit 2e886a2e03)
2018-03-16 14:38:08 +08:00
f03a5c11bc Vlv2TbltDevicePkg/Bds: use Tcg2 instead of TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: David Wei <david.wei@intel.com>
Cc: Mang Guo <mang.guo@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
Reviewed-by: Mang Guo <mang.guo@intel.com>
(cherry picked from commit 33aaf8d71f)
2018-03-16 14:38:06 +08:00
5a4224fded Vlv2TbltDevicePkg/Tcg2PhysicalPresenceLib: use Tcg2 instead of TrEE.
TrEE is deprecated. We need use Tcg2.

Cc: David Wei <david.wei@intel.com>
Cc: Mang Guo <mang.guo@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
Reviewed-by: Mang Guo <mang.guo@intel.com>
(cherry picked from commit 9461604e14)
2018-03-16 14:38:04 +08:00
4bf91b3056 QuarkPlatformPkg: remove TrEE reference.
TrEE is deprecated. We need use Tcg2.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Kelly Steele <kelly.steele@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
Reviewed-by: Kelly Steele <kelly.steele@intel.com>
(cherry picked from commit b1d95b19e5)
2018-03-16 14:38:02 +08:00
3f8cd2a2b3 ShellPkg/UefiHandleParsingLib: remove TrEE reference.
TrEE is deprecated. We need use Tcg2.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 5902cfa945)
2018-03-16 14:37:59 +08:00
78a8545b8b MdeModulePkg PCD: Remove PCD_TYPE_SKU_ENABLED in PCD_TYPE_ALL_SET
Remove PCD_TYPE_SKU_ENABLED in PCD_TYPE_ALL_SET.
This change was missing at e8d2a98052.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Thomas Lamprecht <t.lamprecht@proxmox.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Tested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit d154a4dfae)
2018-03-15 14:57:12 +08:00
f4e90c31d2 MdeModulePkg PCD: Remove unused PCD attribute PCD_TYPE_SKU_ENABLED
PcdDb optimization has handled PCD DB for each SKU, not for single PCD.
So, this PCD attribute is not used any more.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit e8d2a98052)
2018-03-15 14:57:10 +08:00
a2aa1d9d77 SourceLevelDebugPkg DebugUsb3: Re-Support IOMMU
de8373fa07 could not handle two cases.
1. For the case that the USB3 debug port instance and DMA buffers are
from PEI HOB with IOMMU enabled, it was to reallocate the DMA buffers
by AllocateAddress with the memory type accessible by SMM environment.
But reallocating the DMA buffers by AllocateAddress may fail.

2. At S3 resume, after the code is transferred to PiSmmCpuDxeSmm from
S3Resume2Pei, HOB is still needed to be used for DMA operation, but
PiSmmCpuDxeSmm has no way to get the HOB at S3 resume.

The patch is to re-support IOMMU.
For PEI, allocate granted DMA buffer from IOMMU PPI, register IOMMU PPI
notification to reinitialize hardware with granted DMA buffer if IOMMU
PPI is not present yet.
For DXE, map DMA buffer by PciIo in PciIo notification for early DXE,
and register DxeSmmReadyToLock notification to reinitialize hardware
with granted DXE DMA buffer accessible by SMM environment for late DXE.

DebugAgentLib has been managing the instance as Handle in
HOB/SystemTable. The Handle(instance) from DebugAgentLib can be used
directly in DebugCommunicationLibUsb3. Then DebugCommunicationLibUsb3
could get consistent Handle(instance) from DebugAgentLib.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 75787f6580)
2018-03-15 14:20:28 +08:00
cfcb6002d8 SourceLevelDebugPkg DebugCommUsb3: Refine some formats/comments
Refine some formats/comments and remove some unused prototypes.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit f0c562761f)
2018-03-15 14:20:27 +08:00
7f3898286c SourceLevelDebugPkg DebugUsb3: Re-Fix GCC build failures
Fix GCC build failures below.
variable 'EvtTrb' set but not used [-Werror=unused-but-set-variable]
variable 'Index' set but not used [-Werror=unused-but-set-variable]

The build failure could only be caught with -D SOURCE_DEBUG_USE_USB3
build flag.

ad6040ec9b needs to be also reverted
when reverting IOMMU support patches, otherwise there will be conflict.
This patch is to re-do ad6040ec9b.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 3ecca00330)
2018-03-15 14:20:27 +08:00
524d708130 Revert "DebugUsb3: Support IOMMU"
This reverts commit de8373fa07.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 1f279e7a53)
2018-03-15 14:20:26 +08:00
cdca0dc4a1 Revert "DebugUsb3: Fix GCC build failures"
This reverts commit ad6040ec9b.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 373b1d0ee3)
2018-03-15 14:20:25 +08:00
5ecb58bafc Revert "DebugUsb3: Check mUsb3Instance before dereferencing it"
This reverts commit 6ef394ffe2.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit abea3bca82)
2018-03-15 14:20:24 +08:00
49e58b59c5 MdeModulePkg/PiSmmCore: fix mem alloc issues in heap guard
This patch fixes the same issues in Heap Guard in DXE core, which is fixed
in another patch.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 12957e56d2)
2018-03-14 16:17:17 +08:00
d7508770f9 MdeModulePkg/Core: fix mem alloc issues in heap guard
There're two ASSERT issues which will be triggered by boot loader of
Windows 10.

The first is caused by allocating memory in heap guard during another
memory allocation, which is not allowed in DXE core. Avoiding reentry
of memory allocation has been considered in heap guard feature. But
there's a hole in the code of function FindGuardedMemoryMap(). The fix
is adding AllocMapUnit parameter in the condition of while(), which
will prevent memory allocation from happenning during Guard page
check operation.

The second is caused by the core trying to allocate page 0 with Guard
page, which will cause the start address rolling back to the end of
supported system address. According to the requirement of heap guard,
the fix is just simply skipping the free memory at page 0 and let
the core continue searching free memory after it.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit dd12683e1f)
2018-03-14 16:17:16 +08:00
edead44510 OvmfPkg/Gop: clear the screen to black in SetMode()
Today's implementation forgot to clear the screen to black in
SetMode(). It causes SCT SetMode() test fails.

The patch adds the clear screen operation in SetMode() to fix
the SCT failure.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
(cherry picked from commit 81feb6d305)
2018-03-14 11:40:01 +08:00
c2ce97ad3e ShellPkg/[hex]edit: Fix mouse freeze issue
In edit or hexedit, the mouse cursor doesn't move when moving
the mouse.
The root cause is 5563281fa2
* ShellPkg/[hex]edit: use SimpleTextInEx to read console
wrongly uses WaitForEvent() to listen keyboard input.
It blocks the code execution when there is no keyboard input.
While the same function also polls the mouse move status,
the mouse movement cannot be reflected to the screen when
there is no keyboard input.

The patch fixes the issue by use CheckEvent() instead of
WaitForEvent().

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 58793b8838)
2018-03-14 11:33:47 +08:00
02a7774295 NetworkPkg/IScsiDxe: Fix the ISCSI connection failure in certain case.
The ISCSI connection will fail for the first time if the target info is
retrieved from DHCP and expressed as URI format. The issue is caused by
the missing DNS protocol dependency check during the driver support
function.

This patch is to fix the above issue.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 841d8698dd)
2018-03-14 08:39:21 +08:00
ee528d4356 MdeModulePkg/Mtftp4Dxe: Fix the incorrect return status.
The incorrect return status was caused by the commit of 39b0867d, which
was to resolve the token status error that does not compliance with spec
definition, but it results the protocol status not compliance with spec
definition.

This patch is to resolve above issue.

Cc: Wang Fan <fan.wang@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wang, Fan <fan.wang@intel.com>
(cherry picked from commit c8e342e00b)
2018-03-14 08:39:18 +08:00
4ad2e33198 BaseTools: Get Pcd DatumType from DEC file for --pcd
It is regression bug that missing the Pcd DatumType info from DEC file
for --pcd .

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 87a1f65e80)
2018-03-12 16:39:29 +08:00
3986490ce0 BaseTools: Fix parse OFFSET_OF get wrong offset
Fix parse OFFSET_OF get wrong offset

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>
(cherry picked from commit b31501c90a)
2018-03-12 10:00:36 +08:00
be80d16679 BaseTools: Fix a bug for --pcd used in ConditionalStatement calculate
Move the GlobalData.BuildOptionPcd before FdfParser() function and add
type check for Pcd item.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 705ed563de)
2018-03-10 10:41:37 +08:00
048174c51e BaseTools: Update --pcd parser to support flexible pcd format
This patch update --pcd parser to support flexible pcd format.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 8565b5829c)
2018-03-10 10:41:36 +08:00
4a5c1b917b BaseTools: Fixed Pcd from command line issue.
Save the pcd command line value in Pcd object

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 0f228f19fb)
2018-03-10 10:41:35 +08:00
0dc76480ad IntelSiliconPkg/Vtd: Add MapHandleInfo in VtdDxe.
This information is to record which device requested which DMA buffer.
It can be used for DMA buffer analysis.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
2018-03-09 16:21:03 +08:00
89df7dcc82 SecurityPkg OpalPasswordExtraInfoVariable.h: Remove it
Remove OpalPasswordExtraInfoVariable.h as it is not been used
anymore.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@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>
(cherry picked from commit a998027ba8)
2018-03-09 14:37:06 +08:00
766ee32201 SecurityPkg OpalPasswordSupportLib: Remove it
Remove OpalPasswordSupportLib as it is not been used
anymore.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@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>
(cherry picked from commit 1101ffbf84)
2018-03-09 14:37:05 +08:00
921c3d11f3 SecurityPkg OpalPassword: Remove old solution
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@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>
(cherry picked from commit 957024c1bc)
2018-03-09 14:37:05 +08:00
5f215c812b SecurityPkg OpalPassword: Add solution without SMM device code
After IOMMU is enabled in S3, original solution with SMM device
code (OpalPasswordSmm) to unlock OPAL device for S3 will not work
as the DMA operation will be aborted without granted DMA buffer.
Instead, this solution is to add OpalPasswordPei to eliminate
SMM device code, and OPAL setup UI produced by OpalPasswordDxe
will be updated to send requests (set password, update password,
and etc), and then the requests will be processed in next boot
before SmmReadyToLock, password and device info will be saved to
lock box used by OpalPasswordPei to unlock OPAL device for S3.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@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>
(cherry picked from commit 112e584ba0)
2018-03-09 14:37:04 +08:00
902e44cf26 SecurityPkg TcgStorageCoreLib: Make it be base type really
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@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>
(cherry picked from commit d62cb7bb0c)
2018-03-09 14:37:03 +08:00
49e3ed1416 SecurityPkg TcgStorageOpalLib: Make it be base type really
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@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>
(cherry picked from commit 6accc5fad4)
2018-03-09 14:37:02 +08:00
320449821c MdeModulePkg LockBoxLib: Support LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY
With this flag, the LockBox can be restored in S3 resume only.
The LockBox can not be restored after SmmReadyToLock in normal boot
and after EndOfS3Resume in S3 resume.
It can not be set together with LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE.

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>
(cherry picked from commit 6bd4af305d)
2018-03-09 14:37:02 +08:00
aa512b0eb4 IntelSiliconPkg VTdPmrPei: Add PcdVTdPeiDmaBufferSize(S3)
Add PcdVTdPeiDmaBufferSize(S3) to replace the hard coded value
TOTAL_DMA_BUFFER_SIZE and TOTAL_DMA_BUFFER_SIZE_S3 in IntelVTdPmrPei.

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>
(cherry picked from commit 339cb0af96)
2018-03-09 10:01:54 +08:00
41ba79ea1e IntelSiliconPkg VTdPmrPei: Return SUCCESS when Mapping == NULL in Unmap
NULL is returned to Mapping when Operation is BusMasterCommonBuffer or
BusMasterCommonBuffer64 in PeiIoMmuMap().
So Mapping == NULL is valid when calling PeiIoMmuUnmap().

940dbd071e wrongly changed EFI_SUCCESS
to EFI_INVALID_PARAMETER when Mapping == NULL in PeiIoMmuUnmap().
This patch is to correct it.

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>
(cherry picked from commit abe63fa7dc)
2018-03-09 10:01:53 +08:00
d42b261973 SecurityPkg: also clear HashInterfaceHob.SupportedHashMask
Commit 4cc2b63bd8 fixed an out of bounds
ZeroMem() call. However, as Laszlo Ersek pointed out, the intent was
to clear all but the Identifier (to revert the effect of
RegisterHashInterfaceLib()). For that, it should clear the
SupportedHashMask too.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marc-Andr? Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
(cherry picked from commit 73ee3abab1)
2018-03-08 22:43:44 +08:00
74b58de20f UefiCpuPkg/MpInitLib: put mReservedApLoopFunc in executable memory
if PcdDxeNxMemoryProtectionPolicy is enabled for EfiReservedMemoryType
of memory, #PF will be triggered for each APs after ExitBootServices
in SCRT test. The root cause is that AP wakeup code executed at that
time is stored in memory of type EfiReservedMemoryType (referenced by
global mReservedApLoopFunc), which is marked as non-executable.

This patch fixes this issue by setting memory of mReservedApLoopFunc to
be executable immediately after allocation.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit bc2288f59b)
2018-03-08 17:13:40 +08:00
b5fdf331cc BaseTools: update DNS_DEVICE_PATH/URI_DEVICE_PATH definition
Update this two definition to align with MdePkg.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 20203d3f98)
2018-03-08 15:31:48 +08:00
e6deaf9dbe MdeModulePkg/Core: fix too many available pages between BS_Data
The root cause is an unnecessary check to Size parameter in function
AdjustMemoryS(). It will cause one standalone free page (happen to have
Guard page around) in the free memory list cannot be allocated, even if
the requested memory size is less than a page.

  //
  // At least one more page needed for Guard page.
  //
  if (Size < (SizeRequested + EFI_PAGES_TO_SIZE (1))) {
    return 0;
  }

The following code in the same function actually covers above check
implicitly. So the fix is simply removing above check.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 8b13bca9b8)
2018-03-08 12:41:15 +08:00
bb63309662 SecurityPkg/SmmTcg2PhysicalPresenceLib: Fix coding style issue
Boolean values do not need to use explicit comparisons
to TRUE or FALSE.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by:Chao Zhang <chao.b.zhang@intel.com>
(cherry picked from commit 3d1872b780)
2018-03-08 09:01:35 +08:00
ad291ed384 UefiCpuPkg/CpuCommonFeaturesLib: Fix coding style issue
Boolean values do not need to use explicit comparisons
to TRUE or FALSE.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit e01d92d43f)
2018-03-08 09:01:32 +08:00
58b72e10c0 MdeModulePkg/DriverSampleDxe: Refine the sample case for UNION type
The example of UNION storage is not good, now update it.

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: Liming Gao <liming.gao@intel.com>
(cherry picked from commit f7d05bddd7)
2018-03-08 09:01:30 +08:00
63abed3519 MdeModulePkg/Core: Fix feature conflict between NX and Stack guard
If enabled, NX memory protection feature will mark some types of active
memory as NX (non-executable), which includes the first page of the stack.
This will overwrite the attributes of the first page of the stack if the
stack guard feature is also enabled.

The solution is to override the attributes setting to the first page of
the stack by adding back the 'EFI_MEMORY_RP' attribute when the stack
guard feature is enabled.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 7db1458f75)
2018-03-07 20:59:10 +08:00
e03c9515e1 MdeModulePkg/Core: Refine handling NULL detection in NX setting
The commit rewrites the logic in function
InitializeDxeNxMemoryProtectionPolicy() for handling the first page
(page 0) when NULL pointer detection feature is enabled.

Instead of skip setting the page 0, the codes will now override the
attribute setting of page 0 by adding the 'EFI_MEMORY_RP' attribute.

The purpose is to make it easy for other special handling of pages
(e.g. the first page of the stack when stack guard feature is enabled).

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit a10acf0e20)
2018-03-07 20:59:09 +08:00
bf042da6a0 ShellBinPkg: Ia32/X64 Shell binary update.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 133451f344)
2018-03-07 16:32:53 +08:00
dbc2b7698c SecurityPkg: only clear HashInterface information
The ZeroMem() call goes beyond the HashInterfaceHob structure, causing
HOB list corruption. Instead, just clear the HashInterface fields, as
I suppose was originally intended.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marc-Andr? Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 92995a3bb93893ba645df2198dd55dd99a941f6f)
2018-03-07 12:39:35 +08:00
8212084061 MdeModulePkg/NullMemoryTest: Fix bug in CompatibleRangeTest
CompatibleRangeTest() contains two bugs:
1. It doesn't reject the memory above 16MB
2. it cannot handle the case when the partial or whole range of
   requested memory is already tested.

The patch fixes the two bugs.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 61c1742ba1)
2018-03-07 12:37:25 +08:00
38cde47ec5 MdeModulePkg/NullMemoryTest: Change prototype of ConvertToTestedMemory
The patch should not impact the functionality.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit ee37e96479)
2018-03-07 12:37:24 +08:00
86445d72de MdeModulePkg/Terminal: ReadKeyStrokeEx always return key state
Because terminal doesn't support shift and toggle key state,
ReadKeyStrokeEx just sets the two states to 0.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 66f2329446)
2018-03-06 12:18:32 +08:00
7fee1fab40 ShellPkg/ConsoleLogger: Fix a typo in UpdateDisplayFromHistory()
Within function UpdateDisplayFromHistory():

When getting a character with different attribute with the current one,
the statement to compare the character with a 'NULL' char should be:

*StringSegmentEnd != CHAR_NULL

rather than:

StringSegmentEnd != CHAR_NULL

This commit resolves this typo.

Cc: Jaben Carsey <jaben.carsey@intel.com>
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>
(cherry picked from commit 10dfa028f0)
2018-03-04 12:08:19 +08:00
c3ac218240 BaseTools: Fix byte orders when handling 8-byte array
Per UEFI spec, FibreEx.WWN, FibreEx.Lun, SasEx.Address, SasEx.Lun
and iSCSI.Lun are all 8-byte array with byte #0 in the left.
It means "0102030405060708" should be converted to:
    UINT8[8] = {01, 02, 03, 04, 05, 06, 07, 08}
or  UINT64 = {0807060504030201}

Today's implementation wrongly uses the reversed order.
The patch fixes this issue by using StrHexToBytes().
Copy this solution from MdePkg Hash version d0196be.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 27db236ac2)
2018-03-04 09:25:26 +08:00
97cf199254 BaseTools: Fix bug when converting iSCSI node
If protocol string is not specified, default TCP(0) should be used.
Today's implementation wrongly sets to 1 for this case.
Copy the fix solution from MdePkg Hash version e6c80aea.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit c1d6749b0e)
2018-03-04 09:25:24 +08:00
cabcd57dfe BaseTools: Fix the bug to search Fv.txt file relative to workspace
when the SECTION FV_IMAGE = $(XX)/XX.Fv, the Fv file should relative to
WORKSPACE, so when we search the XX.Fv.txt file, we should search the
path relative to workspace first.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit aebe5a36b6)
2018-03-04 09:25:22 +08:00
adac28f4d7 BaseTools: Correct Structure Pcd value in the report
The patch "Fixed build failed issue" changed structure Pcd Object, so
we need update build report to correct structure Pcd Value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 24326f381f)
2018-03-04 09:25:20 +08:00
608d86b447 BaseTools: Pcd Value override issue.
For the case that the structure PCD has no value assignment in DSC,
but has value assignment in command line.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 1667eec699)
2018-03-04 09:25:19 +08:00
6be81412b3 BaseTools: Fixed build failed issue.
Case 1. A Pcd has no default sku setting in DSC.
Case 2. Build as Single SKU.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit f832bb3466)
2018-03-04 09:25:17 +08:00
87bc6f9bd7 BaseTools: Fixed Pcd value override issue.
1. Handle the Pcd maxsize issue for the case
that the length of Pcd value from CommandLine
bigger that its maxsize

2. The Pcd value override in commandline.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit b854e2bf75)
2018-03-04 09:25:16 +08:00
a82eb50d8c BaseTools: DSC Components section support flexible PCD
DSC Components section support flexible PCD, and for binary driver, we
need patch this value. Update the split char ',' not ', ' because some
value may have space, while others may not have this space.

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>
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 0537f332c9)
2018-03-04 09:25:14 +08:00
e9cae1ca15 BaseTools: Dsc/Fdf conditional statement parse issue
Set PCD value with --pcd argument not replace DSC/Fdf PCD value.

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>
(cherry picked from commit 1fa7fdf6ea)
2018-03-04 09:25:13 +08:00
78664a7301 BaseTools: report error if flag in LABEL() invalid
Flag in LABEL() is not valid C variable name, will report error.

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>
(cherry picked from commit 5ac0a5450b)
2018-03-04 09:25:11 +08:00
31c73450f7 BaseTools: Fix the bug for display incorrect *M flag in report
The root cause is the byte array value in the driver Pcd, some bytes
have additional space character, while the value in DSC file doesn't
have this space, it cause the string compare return false, so we remove
the extra space.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 6ee9c68912)
2018-03-04 09:25:10 +08:00
43473e3dcd BaseTools: Fix eval parse string issue
eval argument start with " or ', but it is unicode string,
will encounter error:
    List = list(eval(Value)) # translate escape character
  File "<string>", line 1
    'j??=????????F??
             ^
SyntaxError: EOL while scanning string literal

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>
(cherry picked from commit 4faf13222e)
2018-03-04 09:25:08 +08:00
194ae4278a BaseTools: GlobalData.gConfDirectory is None when run GenFds
When run GenFds,  GlobalData.gConfDirectory is None, On Linux
self._ToolChainFamily default Value is "MSFT", and then
generate the wrong PcdValueInit 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: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 541a3f5882)
2018-03-04 09:25:06 +08:00
60a79a8871 BaseTools: Fix the bug for single module build with GenC/GenMake
copy the same logic from _BuildPa() function.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit cd49821608)
2018-03-04 09:25:05 +08:00
5ee2485fc5 MdeModulePkg/UefiBootManagerLib: remove superfluous TimerLib dependency
In commit 3a039a567a ("MdeModulePkg/UefiBootManagerLib: Remove the
useless perf codes", 2018-02-12), the BmWriteBootToOsPerformanceData()
function was removed. No TimerLib API calls are left, thus remove the
TimerLib class dependency from "InternalBm.h" and "UefiBootManagerLib.inf"
as well.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit bad0b5e871)
2018-03-03 21:20:41 +08:00
74ed3adde1 MdeModulePkg/PciBus: Change switch-case to if-else to fix EBC build
EBC compiler doesn't treat EFI_xxx as constant due to these macros
are UINT64 type in 64bit env and UINT32 type in 32bit env.
So it reports error when "case EFI_xxx" is used.
The patch changes to use if-else to fix EBC build failure.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit ada385843b)
2018-03-03 21:17:59 +08:00
a48b8bd259 MdeModulePkg/PciBusDxe: cope with HPCs that request no bus nr padding
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 2e94e41297)
2018-03-03 21:10:27 +08:00
b7f22b334c MdeModulePkg/PciBus: Reserve Bus number for non-root and root HPBs
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=656

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit cbbccf3cf3)
2018-03-03 21:09:04 +08:00
48daa7fa24 ShellPkg/UefiShellDebug1CommandsLib: remove I/O address limit from 'mm'
Neither the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL nor the EFI_CPU_IO2_PROTOCOL
impose any restrictions when it comes to the range of valid I/O
addresses. Even so, the 'mm' command in -IO mode refuses to perform
accesses to addresses >= 0xffff.

It is not up to 'mm' to impose this restriction, so remove it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 23b53ede35)
2018-03-03 21:06:02 +08:00
3fca88b2b9 ShellPkg/Ping: fix loss of first packet
Issue:
Reply for first ping packet was getting dropped.

Cause:
Sometimes reply message comes even before trasmit
function returns, hence missing 1st reply

Fix:
Prepare the TxList before calling Transmit function.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit d624deb7ab)
2018-03-03 21:06:02 +08:00
a763560aa6 ShellPkg: remove superfluous TimerLib resolution
TimerLib had to be resolved in commit 5ab97a64b5 ("ShellPkg/bcfg: Add
Shell Spec 2.2 modification functionality", 2017-03-01) because:

- the BCFG command started making calls to UefiBootManagerLib
  (EfiBootManagerVariableToLoadOption(),
  EfiBootManagerLoadOptionToVariable(), EfiBootManagerFreeLoadOption()),

- and "MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf"
  depended on TimerLib.

Because TimerLib is platform-specific, but "ShellPkg/ShellPkg.dsc" is
meant to produce a UEFI shell binary that is platform-independent (see
"ShellBinPkg/ReadMe.txt"), we resolved TimerLib to
"BaseTimerLibNullTemplate.inf". (TimerLib functionality was never actually
needed on UefiBootManagerLib code paths that were exercised by the shell /
BCFG.)

Thanks to the last patch, UefiBootManagerLib no longer depends on
TimerLib, thus we can drop the TimerLib resolution entirely.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 7a141b1306)
2018-03-03 21:06:01 +08:00
d307a8284c MdeModulePkg/UsbMass: Retry CMD for MediaChanged sense key
When a USB device reports failure for a CMD and REQUEST SENSE returns
Media Changed key, UsbBootExecCmdWithRetry() stops to retry CMD and
returns EFI_MEDIA_CHANGED to caller.

For this case, the CMD should be retried until success, getting
NoMedia sense key or timeout.
The patch updates UsbBootExecCmdWithRetry() to follow the above
rule so EFI_MEDIA_CHANGED is no longer returned.

UsbBootDetectMedia() is updated accordingly.

Because UsbBootGetParams() is called for new plugged USB storage,
and some USB storage devices may report Media Changed key,
UsbBootGetParams() is updated to treat it as a Success.
This change could fix the issue that some USB storage devices
cannot be detected.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 06e2409667)
2018-03-03 15:51:02 +08:00
b75fe39d53 MdeModulePkg/UsbMass: remove unnecessary RestoreTPL() call
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit cd626ef0fb)
2018-03-03 15:51:01 +08:00
71da3c9f12 MdeModulePkg/UsbMass: Add more debug message
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit e149055310)
2018-03-03 15:51:01 +08:00
15912adc0f MdeModulePkg/UsbMass: Revert "map -r" media change detection fix
This reverts commit a662afb5b0.
* MdeModulePkg/UsbStorage: Fix "map -r" cannot detect media change

The above commit fixed the following issue:
When system boots to Shell without CDROM inside USB CDROM drive,
and then user inserts the CDROM with Eltorito file system,
"map -r" cannot show the new ELtorito file system.
The commit caused EFI_MEDIA_CHANGED status returned from
UsbBootDetectMedia().

But that fix exposes another issue:
When issuing ReadCapacity command to certain USB key
(Kingston DataTraveler G3 8GB) after it's hot-plugged, USB device
returns STALL error and RequestSense command returns media changed
sense data. (Most of the USB keys return SUCCESS for ReadCapacity
command after hot-plug.)

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 19d76ae608)
2018-03-03 15:51:00 +08:00
6c524c3a70 MdeModulePkg/UsbMass: Revert POWER_ON(29h) ASC handling logic
This reverts commit 6461344c31.
* MdeModulePkg/UsbMass: Fix hot-plug USB CDROM can't be recognized

UsbBootExecCmd() only calls UsbBootRequestSense() to get sense key
when CMD fails.
When POWER ON (29h) ASC returns from REQUEST SENSE, implementation
should retry the CMD, instead of treating this as a SUCCESS.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 1bc5d2b3c7)
2018-03-03 15:50:59 +08:00
270bc06e99 MdePkg/DevicePathFromText: Fix byte orders of iSCSI.Lun
Per UEFI spec, iSCSI.Lun is a 8-byte array with byte #0 in the left.
It means "0102030405060708" should be converted to:
    UINT8[8] = {01, 02, 03, 04, 05, 06, 07, 08}
or  UINT64 = {0807060504030201}

Today's implementation wrongly uses the reversed order.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jie Lin <jie.lin@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit d0196be1e3)
2018-03-03 15:50:20 +08:00
c5b32c02a4 MdePkg/DevicePathFromText: Fix bug when converting iSCSI node
If protocol string is not specified, default TCP(0) should be used.
Today's implementation wrongly sets to 1 for this case.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit e6c80aea71)
2018-03-03 15:50:19 +08:00
bce451d5f3 UefiCpuPkg S3ResumePei: Signal S3SmmInitDone
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.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>
Acked-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 5b29e438eb)
2018-03-03 14:41:28 +08:00
3124cd3a36 MdeModulePkg PiSmmCore: Register SMI handler to install S3SmmInitDone
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>
(cherry picked from commit 1bae3e0ed1)
2018-03-03 14:41:28 +08:00
cc476eb7ef MdeModulePkg: Add S3SmmInitDone definition
Add gEdkiiS3SmmInitDoneGuid, after S3 SMM initialization is done and
before S3 boot script is executed, this GUID is installed as PPI in
PEI and protocol in SMM environment. It allows for PEIMs or SMM
drivers to hook this point and do the required tasks.

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>
(cherry picked from commit 8f558d8aca)
2018-03-03 14:41:27 +08:00
65208a68ce MdeModulePkg/Mtftp4Dxe: Separate the timer ticking to calculate the packet live time.
TPL deadlock issue was enrolled by the commit of 39b0867d. To resolve the issue,
this patch separated the timer ticking for all the MTFTP clients to calculate the
packet live time in TPL_NOTIFY level.

Cc: Wang Fan <fan.wang@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 0e2a5749d8)
2018-03-03 09:37:39 +08:00
dded7cddfc BaseTools: Align WIN_CERTIFICATE_UEFI_GUID definition to MdePkg one.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit a16f7f4794)
2018-03-02 19:01:37 +08:00
0fab234b80 MdeModulePkg: Fix incorrect commit introduced by commit SHA-1:052c98
The default value of PcdExtFpdtBootRecordPadSize is 0x20000
But the following commit in master update it to 0 by mistake.
SHA-1: 052c98ce24
Subject: MdeModulePkg: Add ResetSystemPei PEIM

This patch is to restore the value.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@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>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 52b68f7d45)
2018-03-02 16:18:05 +08:00
413b649783 MdeModulePkg/DxeCorePerfLib: Add status check instead of ASSERT
Currently DxeCorePerformanceLib will get SMM performance data based
on SMM communication handler. If SMM communication handler returns error,
the library will ASSERT. In fact, if SMM perf data is not found.
DXE perf data can still be dumped. So using status check instead of
ASSERT is better.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@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>
(cherry picked from commit c9f02a96d8)
2018-03-02 16:18:04 +08:00
82caf21987 MdeModulePkg/DebugLibReportStatusCode: Fix hang if format is too long
The previous commit 137ed15511
* MdeModulePkg/DebugLib: Print partial when format string is too long
copies partial format string to DEBUG_INFO buffer but when parsing
the format modifier, the original format string is still used.

The patch fixes this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit a7119c8152)
2018-03-02 13:46:01 +08:00
36cec4c2ba NetworkPkg/Udp6Dxe: Fix the failure to leave one multicast group address.
The issue was enrolled by the commit of ceec3638. One of the change in the commit
was to return the status from NetMapIterate in Udp6Groups function. But it should
not return EFI_ABORTED directly in case McastIp is not NULL, which means to terminate
the iteration and leave the McastIp successfully.

Cc: Wang Fan <fan.wang@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit db79f8019d)
2018-03-02 11:23:40 +08:00
d6711a2751 NetworkPkg/HttpBootDxe: Fix the incorrect error message output.
For IPv6 case, if one invalid URL returned from DHCP server, HttpBootDxe
driver could not retrieve the URL host address from DNS server. In such a
case, the error message should be printed as:
  Error: Could not retrieve the host address from DNS server.
Instead of:
  Error: Could not discover the boot information for DHCP server.
Then, we can still output as following:
  Error: Could not retrieve NBP file size from HTTP server.

Besides, currently implementation in HttpBootLoadFile will always output
error message even the HTTP process is correct.

This patch is to fix above issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit f33d39949b)
2018-03-02 11:23:39 +08:00
8be643d1f0 NetworkPkg/HttpBootDxe: Correct the parameter check for the usage of HttpBootGetFileFromCache.
The patch is to fix the incorrect parameter check for the HttpBootGetFileFromCache().

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit 951c6e63f8)
2018-03-02 11:23:37 +08:00
ef2f5a4cb0 UefiCpuPkg/CpuExceptionHandlerLib: fix incorrect init of exception stack
This issue is introduced at following commit, which tried to add stack
switch support on behalf of Stack Guard feature.

    0ff5aa9cae

The field KnownGoodStackTop in CPU_EXCEPTION_INIT_DATA is initialized to
the start address of array mNewStack. This is wrong. It must be the end
of mNewStack. This patch fixes this mistake.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit d429d00f97)
2018-03-02 08:54:17 +08:00
342865cd61 MdeModulePkg/PlatformLogo.h: Correct function header comments
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit de707b0866)
2018-03-02 08:54:16 +08:00
50c1780c3b MdeModulePkg/Logo.idf: Remove incorrect comments.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 25184ec33c)
2018-03-02 08:54:14 +08:00
91de220b8d BaseTools: Enhance FV info report file path to support absolute path
When generate build report, Tool will get the info like size, Fv Name,
etc from the xx.Fv.txt file and add these info into the build report.
This patch support the xx.Fv.txt to use absolute file path format since
user may provide specified FV path.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 2157bc9c8b)
2018-03-01 19:28:55 +08:00
cdfc829893 BaseTools: Improve build performance of structure PCD value generation
Optimized the PcdValueInit.c size by abstract the common logic in the funciton.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit f3b314331c)
2018-03-01 10:12:22 +08:00
5d5add96c8 BaseTool: GUID format PCD value assignment fail in Structure PCD field
If Structure PCD field is assigned as GUID format, its data type should be
the fixed GUID structure. No flexible check is required.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 79820e32ec)
2018-03-01 10:12:20 +08:00
7ed77269fb BaseTools: Improve build performance of structure PCD value generation
Add cache for building PcdValueInit.c. If PcdValueInit.c is not changed,
it will not be regenerated.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 0a57a9782b)
2018-03-01 10:12:18 +08:00
fe7c413c90 BaseTools: Fixed the pcd value override issue.
1. the issue in the overriding value from command line.
2. dec fully value < dec field assign value <
   dsc fully value < dsc field assign value

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 06140766c1)
2018-03-01 10:12:16 +08:00
9f2696e487 BaseTools/tools_def: use separate PP definition for DTC
Clang's preprocessor behaves differently from GCC's, and produces
intermediate device tree source that still contains #pragma pack()
and other directives that the device tree compiler chokes on.

For assembling device tree sources, it matters very little which
preprocessor is being used, so let's just use GNU CPP explicitly.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit a68749f39a)
2018-03-01 10:12:14 +08:00
bae94d0a6b MdeModulePkg PCD: Fix the issue to set the big SkuId
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit f0c69b614c)
2018-02-28 14:50:06 +08:00
4d5b86ca83 MdeModulePkg PCD: Add more debug message to show SkuId update
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit f71503c37c)
2018-02-28 14:50:05 +08:00
369e0bc4a1 EmulatorPkg: Undefine CR3 macro in Host.h
CR3 has been used as structure field name in BaseLib IA32_TASK_STATE_SEGMENT.
Undefine CR3 to make sure there is no conflict to it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
(cherry picked from commit 78647b9228)
2018-02-28 14:50:04 +08:00
8ed0f5f188 BaseTools: Fix a bug override Pcd by DSC Components section
The case is: define a VOID* pcd in DEC file, eg: Value is {0x1}.
then override this PCD on DSC component section, eg: Value is
{0x1, 0x2, 0x3}, the max size of this PCD is calculate wrong
which cause build error.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit cdbf45ad85)
2018-02-28 13:42:57 +08:00
1a7e6a252e BaseTools: Fix report not used --pcd value incorrectly
Argument --pcd gUefiOvmfPkgTokenSpaceGuid.test10=H"{1}",
If the PCD is not used, report value {0x01, 0x00}, is incorrect.

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>
(cherry picked from commit 97e1ff1b91)
2018-02-28 13:42:56 +08:00
9a47d8a3d4 BaseTools: Fix flexible PCD single quote and double quote bugs
1.The " and ' inside the string, must use escape character format
  (\", \')
2.'string' and L'string' format in --pcd, it must be double quoted
  first.

  Some examples that to match --pcd format and DSC format
  --pcd                             DSC format
  L"ABC"                            L"ABC"
  "AB\\\"C"                         "AB\"C"
  "AB\\\'C"                         "AB\'C"
  L"\'AB\\\"C\'"                    L'AB\"C'
  "\'AB\\\'C\'"                     'AB\'C'
  H"{0, L\"AB\\\"B\", \'ab\\\"c\'}" {0, L"AB\"B", 'ab\"c'}

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>
(cherry picked from commit ea927d2f3f)
2018-02-28 13:42:56 +08:00
4347b17b96 BaseTools: Update GenFw to correct DebugEntry Offset when convert XIP image
DebugEntry FileOffset is required to be updated to the virtual address if
the input image is converted to XIP image.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 29c5075787)
2018-02-28 13:42:55 +08:00
529973681c BaseTools: Add more error message when PcdValue is wrong
For structure PCD, its field name is wrong and cause build failure. Its
build error message will output to let user aware what's wrong.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Feng Bob C <bob.c.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 0939fda93c)
2018-02-28 13:42:55 +08:00
6754622171 BaseTools: Resolve BaseTools C tool build failure
New GUID definition is conflicted with GUID in Windows Kits guiddef.h.
GUID definition will be defined when it is undefined.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 006c2647dc)
2018-02-28 13:42:54 +08:00
d0cd330069 BaseTools:Override the MAKE_FLAGS by BuildOptions in DSC
The issue that *_*_*_MAKE_FLAGS doesn't work in DSC [BuildOptions]
section. It means MAKE flags can't be set in platform DSC file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 02a908fc6d)
2018-02-28 13:42:54 +08:00
675e75c591 BaseTools GenFv: Update error message to describe PE image alignment
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 3c3277f21e)
2018-02-28 13:42:53 +08:00
85767a590c BaseTools: Add the missing basic definition in C BaseType.h
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 3e44e9f534)
2018-02-28 13:42:52 +08:00
7a718a2537 MdeModulePkg/NullMemoryTest: Handle more reliable memory
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=650

Today's implementation converts the untested more reliable memory
from reserved GCD type to system memory GCD type.
Though it doesn't impact the return result of gBS->GetMemoryMap().
But it impacts the return result of gDS->GetMemorySpaceDescriptor().
The patch fixes the bug to convert the untested more reliable memory
from reserved GCD type to more reliable memory GCD type.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 1c06bd485e)
2018-02-27 13:58:12 +08:00
9aea281020 MdeModulePkg/GenericMemoryTest: Handle more reliable memory
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=650
Today's implementation converts the untested more reliable memory
from reserved GCD type to system memory GCD type.
Though it doesn't impact the return result of gBS->GetMemoryMap().
But it impacts the return result of gDS->GetMemorySpaceDescriptor().
The patch fixes the bug to convert the untested more reliable memory
from reserved GCD type to more reliable memory GCD type.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 2e5fb984ed)
2018-02-27 13:58:11 +08:00
04da8cbd1f MdeModulePkg SmmLockBox: Return updated Length for EFI_BUFFER_TOO_SMALL
The updated Length value should be returned
for EFI_BUFFER_TOO_SMALL case.

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>
(cherry picked from commit f068aa038d)
2018-02-26 14:12:33 +08:00
cf7481e2f6 BaseTools: Add *B Flag for the field that from command line
For structure PCD, the field value may override in the command line,
so in the report when we print the field info we add *B Flag for those
field.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit f440f7e3ca)
2018-02-26 08:59:06 +08:00
a694289ba9 BaseTools: Update ValueExpressionEx for flexible PCD
1. Byte  array number should less than 0xFF.
2. Add SplitPcdValueString for PCD split

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>
(cherry picked from commit 3be421e987)
2018-02-26 08:59:05 +08:00
6cc21aa625 BaseTools/Expression: Use 2nd passes on PCD values
Use 2 passes when evaluating PCD values to discover
all the LABEL() operators and compute the byte offset
of each LABEL().  The 2nd pass then has the information
to replace the OFFSET_OF() operator with the computed
byte offset.  The 2 passes allows OFFSET_OF() to be used
before a LABEL() is declared.

fixes:https://bugzilla.tianocore.org/show_bug.cgi?id=880
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 8bd72d7c05)
2018-02-26 08:59:05 +08:00
a46b556690 MdeModulePkg/RamDiskDxe: Perform MediaId check first in BlkIo services
The commit places the check for MediaId at the beginning of Block IO
services:
RamDiskBlkIoReadBlocks and
RamDiskBlkIoWriteBlocks

This aligns with the Block IO protocol implementations for other
devices.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
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>
(cherry picked from commit 0feca62c7a)
2018-02-26 08:47:41 +08:00
ece2cc8ed7 MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with FMP
https://bugzilla.tianocore.org/show_bug.cgi?id=873

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

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
(cherry picked from commit 7f0301e39a)
2018-02-24 11:20:44 +08:00
40c6dc594e PcAtChipsetPkg PeiAcpiTimerLib: Add the missing DebugLib header file
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 8ee7ad9095)
2018-02-24 11:00:28 +08:00
b59d1dabd3 PcAtChipsetPkg: Add PeiAcpiTimerLib to save Frequency in HOB
In V2:
1) Update PeiAcpiTimerLib base name to PeiAcpiTimerLib
2) Update PeiAcpiTimerLib to add the missing constructor to enable ACPI IO space
3) Update DxeAcpiTimerLib to cache frequency in constructor.

PeiAcpiTimerLib caches PerformanceCounterFrequency in HOB, then Pei and Dxe
AcpiTimerLib can share the same PerformanceCounterFrequency.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit fd501a7984)
2018-02-24 11:00:27 +08:00
4eb8a350c6 BaseTools: Fix the bug to display the single SKUID info
when defined SKUID_IDENTIFIER = DEFAULT|TEST in DSC [Defines] section,
per spec it means current SKUID is single, the bug is build report print
both DEFAULT and TEST info, it should only print TEST.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 8aaa8f7bc0)
2018-02-24 09:20:29 +08:00
eca073d92f BaseTools: Add check for INF statement must be a .inf file
Per FDF spec, INF statement must use a .inf file, we add this error
check.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit a87e79d9d6)
2018-02-24 09:20:28 +08:00
602d05c5ee BaseTools: Add WindowsLike path in front of PATH Env
Original BaseTools source build append WindowsLike path to PATH Env,
while WINDDK installation has a "build.exe", if user place WINDDK
folder to PATH either during WINDDK installation or manually, it will
block the BaseTools' build.bat.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit ffcec664ca)
2018-02-24 09:20:28 +08:00
315184d135 MdeModulePkg/RecoveryDevice.h: Remove semicolon after GUID definitions
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=877

Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 8bdb022115)
2018-02-24 08:28:22 +08:00
2408ef3317 BaseTools/Conf: Add VS2017/ARM support
We duplicate the Assembly-Code-File section from build_rule.template
because --convert-hex cannot be used with the MSFT ARM assembler.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 0a4c903c5a)
2018-02-23 11:11:44 +08:00
b73df32873 BaseTools/Conf: disable DTC legacy phandle format
By default, the device tree compiler emits phandle properties twice:
once called 'phandle' and again called 'linux,phandle'. Given that
Linux was updated in early 2010 [0] to accept the former (which is
what is specified in the ePAPR and device tree specifications), there
is no point in emitting both when compiling device trees for UEFI
platforms.

[0] 04b954a673dd02f585a2769c4945a43880faa989
"of/flattree: Make the kernel accept ePAPR style phandle information"

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 34a4ddda4d)
2018-02-23 11:11:43 +08:00
166be39c8d MdeModulePkg/UsbMass: Fix hot-plug USB CDROM can't be recognized
In below calling stack:
UsbBootIsUnitReady()
 UsbBootExecCmdWithRetry()
  UsbBootExecCmd()
    UsbBootRequestSense()
When USB CDROM is hot-plugged, UsbBootRequestSense() retrieves sense
key (6 = UnitAttention), additional sense code (29h = Power ON).
But it wrongly maps such sense data to Device Error status.
It causes UsbBootExecCmd() executed again.
In the second time call to UsbBootExecCmd(), UsbBootRequestSense()
retrieves sense key (6 = UnitAttention), additional sense code
(28h = media changed).

The above analysis explains why hot-plug USB CDROM cannot be
recognized after below commit:
SHA1 a662afb5b0
* MdeModulePkg/UsbStorage: Fix "map -r" cannot detect media change,
which removes the media changed status check in UsbBootDetectMedia().

The proper fix to this problem is to map the ASC (additional sense
code 29h) properly to success status so that no second call to
UsbBootExecCmd() is made.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
(cherry picked from commit 6461344c31)
2018-02-15 14:18:55 +08:00
99239d7098 ShellPkg/ShellLib: Fix a bug in InternalShellIsHexOrDecimalNumber
InternalShellIsHexOrDecimalNumber() wrongly treats "-" as a number.
The patch fixes this issue.

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

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit ee33344c59)
2018-02-15 14:14:08 +08:00
87b7caf67c ShellPkg/[hex]edit: Fix CTRL+<Alpha> doesn't work from hyper terminal
After commit 20ddbc133f
* MdeModulePkg/ConSplitter: ReadKeyStrokeEx always return key state

When one physical console supports to report the shift key state,
the key data returned from ConSplitter driver at least carries
the shift key valid bit.
The patch fixes the edit/hexedit to accept Unicode (1) when
the no shift key is pressed or reported.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 7cb0313359)
2018-02-15 14:14:07 +08:00
2d1a8a008f MdeModulePkg/ResetUtilityLib: Fix GCC build failure
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
(cherry picked from commit 5eecb45af0)
2018-02-14 09:19:48 +08:00
ada0c62e24 ShellPkg/UefiShellDebug1CommandsLib: sync Compress() definition with decl.
"Compress.h" declares the Compress() function as EFIAPI, but the
definition in "Compress.c" lacks EFIAPI.

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

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

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

(Gary meant to address that omission in Oct 2017:

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

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

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

So do the sync and drop EFIAPI now.

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

Cc: Gary Lin <glin@suse.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Fixes: c4e74e9b81
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Gary Lin <glin@suse.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 3dbf922901)
2018-02-13 11:05:34 +08:00
6740ed2219 ShellPkg/[hex]edit: Fix wrongly use gST->ConIn as the console handle
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit f110b7734b)
2018-02-13 10:56:27 +08:00
e88e191cde ShellPkg/[hex]edit: use SimpleTextInEx to read console
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=682

Edit and HexEdit commands assume that SimpleTxtIn translates
Ctrl+<Alpha-Key> key combinations into Unicode control characters
(0x1-0x1A).

Such translation does not seem to be required by the UEFI spec.
Shell should not rely on implementation specific behavior.
It should instead use SimpleTextInEx to read Ctrl+<Alpha-Key> key
combinations.

The patch changes edit and hexedit to only consumes SimpleTextInEx
so that the implementation specific behavior dependency is removed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reported-by: Felix <felixp@mail.ru>
Cc: Felix <felixp@mail.ru>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 5563281fa2)
2018-02-13 10:56:26 +08:00
e7e98746b1 ShellPkg/help: Fix "-?" may not show manual sometimes
Shell core was enhanced to find the manual string in PE resource
section. But the finding algorithm is too strict: If the manual is
written beginning with:
.TH command 0 "descripton of command"

but user types "COMMAND.efi -?". The finding algorithm uses
case-sensitive compare between "command" and "COMMAND" resulting
in the manual cannot be found.

The patch fixes this issue by using existing ManFileFindTitleSection
and ManFileFindSections which compare command case-insensitive.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 0a54cd4431)
2018-02-13 10:56:26 +08:00
49a776c9ad MdeModulePkg/Performance.h: Remove the useless definition
Remove the definitions related to old perf codes.

Cc: Star Zeng <star.zeng@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: Star Zeng <star.zeng@intel.com>
(cherry picked from commit ae957a59f7)
2018-02-12 11:37:41 +08:00
71d920beec Vlv2TbltDevicePkg/Override/GenericBdsLib:Remove useless Perf code
Our new performance infrastructure (edk2 trunk commit hash value:
SHA-1: 73fef64f14 ~
SHA-1: 115eae650b) can support to
dump performance date form ACPI table in OS. So we can remove
the old perf code to write performance data to OS.

Cc: David Wei <david.wei@intel.com>
Cc: Mang Guo <mang.guo@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: zwei4  <david.wei@intel.com>
(cherry picked from commit ca3817dc17)
2018-02-12 11:37:40 +08:00
db8cd726bc IntelFrameworkModulePkg/GenericBdsLib: Remove the useless Perf codes
Our new performance infrastructure (edk2 trunk commit hash value:
SHA-1: 73fef64f14 ~
SHA-1: 115eae650b) can support to
dump performance date form ACPI table in OS. So we can remove
the old perf code to write performance data to OS.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit b8d06293ca)
2018-02-12 11:37:40 +08:00
3192b349c9 IntelFrameworkModulePkg/BdsDxe: Remove the useless Perf codes
Our new performance infrastructure (edk2 trunk commit hash value:
SHA-1: 73fef64f14 ~
SHA-1: 115eae650b) can support to
dump performance date form ACPI table in OS. So we can remove
the old perf code to write performance data to OS.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 46433d44a9)
2018-02-12 11:37:39 +08:00
3827af5e5c MdeModulePkg/UefiBootManagerLib: Remove the useless perf codes
V2: Just update the commit message to reference the hash value of
new performance infrastructure.

Our new performance infrastructure (edk2 trunk commit hash value:
SHA-1: 73fef64f14 ~
SHA-1: 115eae650b) can support to
dump performance date form ACPI table in OS. So we can remove
the old perf code to write performance data to OS.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 3a039a567a)
2018-02-12 11:37:38 +08:00
6c5ffada1f MdeModulePkg/BdsDxe: Remove useless perf Code
V2: Just update the commit message to reference the hash value of
new performance infrastructure.

Our new performance infrastructure (edk2 trunk commit hash value:
SHA-1: 73fef64f14 ~
SHA-1: 115eae650b) can support to
dump performance date form ACPI table in OS. So we can remove
the old perf code to write performance data to OS.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 9f0d7651b3)
2018-02-12 11:37:38 +08:00
d1e9cbacb8 UefiCpuPkg/S3Resume: Remove useless perf code
V2: Just update the commit message to reference the hash value of
new performance infrastructure.

Our new performance infrastructure (edk2 trunk commit hash value:
SHA-1: 73fef64f14 ~
SHA-1: 115eae650b)can support to
dump performance date form ACPI table in OS. So we can remove
the old perf code to write performance data to OS.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.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: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 93fe14c2f7)
2018-02-12 11:37:37 +08:00
8b501e7138 BaseTools: Fix VOID* type bug
Code miss UINT32 and UINT64 value type setting in
VOID*, like as {UINT32({TRUE})}

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>
(cherry picked from commit a35918caae)
2018-02-11 21:08:58 +08:00
472f866bac BaseTool: correct the generate compress section process
First generate a dummy file with section alignment,
then compress the dummy file to generate the compress 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: Liming Gao <liming.gao@intel.com>
(cherry picked from commit ce2818e418)
2018-02-11 21:08:57 +08:00
8ed7b6d57d BaseTools: Update Expression.py for string comparison and MACRO replace issue
1. Fix string comparison incorrect issue, we expected "ABC" is greater than
"AAD" since the second char 'B' is greater than 'A'.
2. fix MACRO not replace 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>
(cherry picked from commit 9efe8d6040)
2018-02-11 21:08:57 +08:00
a1011d6445 BaseTools: not specified value of MAX_CONCURRENT_THREAD_NUMBER
when MAX_CONCURRENT_THREAD_NUMBER is not specified, tool will
automatically detect number of processor threads.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 2052cb675f)
2018-02-11 21:08:56 +08:00
635bf4f0a3 BaseTools: Enhance error handling for unsupported toolchain Flags/Path
Case1: Cover the Tool PATH is not exist, eg: build MdeModule under GCC5
toolchain and IPF arch.
Case2: Cover the Tool FLAGS is not exist, eg: build OvmfPkg under
CLANG35 toolchain and X64 arch.

fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=595
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 70d0a7549e)
2018-02-11 21:08:56 +08:00
c0ed99b306 BaseTools: Fixed incorrect Structure Pcd Value.
When structurePCD only has overall value assigned
in Dsc under different SKU, the value under default sku is used.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 77204d608b)
2018-02-11 21:08:55 +08:00
dccb8d991d BaseTools: Fixed Build failed issue.
If the PCD is not used in DSC file and user set
that PCD value from Command line, build will fail.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit e1511113de)
2018-02-11 21:08:54 +08:00
a59c401089 BaseTool: Fixed Pcd issues.
1. Check variable offset when merging Hii Pcds
2. Fixed the issue of Hii value inherit with default store.
3. Error handling for incorrect structure pcd declare.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 8aa4db4b80)
2018-02-11 21:08:54 +08:00
acd7a8a637 BaseTools: Fix COMPRESS alignment incorrect issue
Doesn't generate the correct alignment for the leaf section
in the compression section.
Below FFS rule doesn't work as the expectation.

[Rule.Common.PEIM.PE32]
  FILE PEIM = $(NAMED_GUID) {
    PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
    COMPRESS {
      PE32   PE32  Align=Auto    $(INF_OUTPUT)/$(MODULE_NAME).efi
      UI     STRING="$(MODULE_NAME)" Optional
      VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
    }
  }

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>
(cherry picked from commit 4f735fc8cd)
2018-02-11 21:08:53 +08:00
471a089bd3 BaseTools: Report error when GUID format is incorrect
Flexible GUID format of PCD value support following format, so tool should report
error when it is not correct.
1. { GUID("11E13869-1896-4A07-8B21-D8B23DD2A2B4") }
2. { GUID({ 0x11e13869, 0x1896, 0x4a07,{
    0x8b, 0x21, 0xd8, 0xb2, 0x3d, 0xd2, 0xa2, 0xb4 } }) }
3. { GUID(gEfiBlockIoProtocolGuid) }

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>
(cherry picked from commit 4344a788c4)
2018-02-11 21:08:53 +08:00
f3b9b98827 BaseTools: Fix flexible PCD DEVICE_PATH parse issue
When the format of DEVICE_PATH have string, like as:
{DEVICE_PATH("BBS(1,"AB",0)")} have string "AB", will
get the wrong value.

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>
(cherry picked from commit 8ad5f10a2b)
2018-02-11 21:08:52 +08:00
27a8608eaa BaseTools: Fix build argument --pcd for flexible format bugs
Build argument --pcd flexible format, like as:
1. VOID* type
gTokenSpaceGuid.Test=H"{flexible format}"
gTokenSpaceGuid.Test=L"string"
gTokenSpaceGuid.Test="string"
gTokenSpaceGuid.Test=L'string'
gTokenSpaceGuid.Test='string'
2. UINT8/UINT16/UINT32/UINT64 type
gTokenSpaceGuid.Test=H"{flexible format}"
gTokenSpaceGuid.Test=L"string"
gTokenSpaceGuid.Test="string"
gTokenSpaceGuid.Test=L'string'
gTokenSpaceGuid.Test='string'

In linux, single quotes need escape
gTokenSpaceGuid.Test=L\'string\'
gTokenSpaceGuid.Test=\'string\'

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>
(cherry picked from commit f9bba77495)
2018-02-11 21:08:52 +08:00
b39c572e70 SourceLevelDebugPkg DebugUsb3: Check mUsb3Instance before dereferencing it
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 6ef394ffe2)
2018-02-11 10:33:35 +08:00
7d675727fa MdeModulePkg/PerfLib: Add NULL pointer check for "Token"
"Token" is passed through the perf entry, it's may be NULL.
So we need to add NULL pointer check before reference it.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@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>
(cherry picked from commit c9faac275b)
2018-02-11 09:57:19 +08:00
b7bb3bcbdf UefiCpuPkg/S3Resume: Add more perf entry for S3 phase
V2: Just update the commit message.

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

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

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.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: Liming Gao <liming.gao@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 582e4e449d)
2018-02-09 17:10:29 +08:00
9b2fbbeed5 ShellPkg/DP: Update the error message info
Make the error message clearer if fail to get ACPI/FPDT table.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@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>
(cherry picked from commit 4109d0d754)
2018-02-09 17:10:29 +08:00
d0abf8cace ShellPkg/Dp: Add null pointer check
Cc: Liming Gao <liming.gao@intel.com>
Cc: Hao Wu <hao.a.wu@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>
(cherry picked from commit 2d70c90d2e)
2018-02-09 17:10:28 +08:00
51dc9dc1b0 MdeModulePkg/DriverSampleDxe: Make bit fields aligned in C structure
For a structure with a series of bit fields and used as a storage
in vfr file, and if the bit fields do not add up to the size of
the defined type.In the C code use sizeof() to get size of the
structure, the results may vary form the compiler(VS,GCC...).
But the size of the storage calculated by VfrCompiler is fixed
(calculate with alignment).To avoid the issue cased by above case,
we need to make the total width of the bit fields in the structure
aligned with the size of the defined type for these bit fields.

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: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 6b86f6f336)
2018-02-09 17:10:27 +08:00
134f708957 MdeModulePkg/ResetSystemPei: Add reset notifications in PEI
The Reset Notification protocol is added in UEFI spec to support
reset notification mechanism in the DXE phase.
This patch adds similar EDKII specific Reset Notification PPI to PEI
phase to provide the same support.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit ce2697abeb)
2018-02-09 15:42:43 +08:00
f727cdad8d MdeModulePkg: Add ResetSystemPei PEIM
This driver implements Reset2, ResetFilter and ResetHandler PPIs.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 052c98ce24)
2018-02-09 15:42:43 +08:00
2879864592 MdePkg/UefiRuntimeLib: Support more module types.
Because DxeResetSystemLib links to this library to provide
reset system services, change UefiRuntimeLib to support
the same set of module types as what DxeResetSystemLib does.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 97511979b4)
2018-02-09 15:42:42 +08:00
43cfd6a831 MdeModulePkg: Add ResetUtility library class and BASE instance
The library class that provides services to generate a GUID specific
reset, parse the GUID from a GUID specific reset, and build the
ResetData buffer for any type of reset that requires extra data.

Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit e12ceb40ce)
2018-02-09 15:42:41 +08:00
fe71cd7948 MdeModulePkg: Add ResetSystemLib instances that call core services
Add a PEI instance of ResetSystemLib that calls the ResetSystem2()
service in the PEI Services Table.

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

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

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

Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
(cherry picked from commit ce3cd892c8)
2018-02-09 15:42:41 +08:00
917cb49e14 MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message
The patch adds more debug message in ResetSystem().
It also removes unnecessary check of mResetNotifyDepth.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 4bf95a9f36)
2018-02-09 15:42:40 +08:00
e21ccea66d MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler
Add support for platform specific reset filters and platform
specific reset handlers to ResetSystem().  A filter may modify
the reset type and reset data and call ResetSystem() with the
modified parameters.  A handler performs the reset action.

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

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

In the PEI Phase, filters and handlers are registered through
the following 2 PPIs that are based on
EFI_RESET_NOTIFICATION_PROTOCOL.
* gEdkiiPlatformSpecificResetFilterPpiGuid
* gEdkiiPlatformSpecificResetHandlerPpiGuid

In the DXE Phase, filters and handlers are registered through
the following 2 Protocols that are based on
EFI_RESET_NOTIFICATION_PROTOCOL.
* gEdkiiPlatformSpecificResetFilterProtocolGuid
* gEdkiiPlatformSpecificResetHandlerProtocolGuid

Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
(cherry picked from commit 99a6529e1e)

# Conflicts:
#	MdeModulePkg/MdeModulePkg.dec
2018-02-09 15:42:39 +08:00
19140b37c3 MdeModulePkg/PeiMain: Cleanup whitespace in Reset.c
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 8f86d67d46)
2018-02-09 15:42:00 +08:00
9d02c4b101 MdeModulePkg/PeiMain: Always attempt to use Reset2 PPI first
Update PEI Service ResetSystem() to always attempt to use
the Reset2 PPI before looking for the Reset PPI.

Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 7072a185d0)
2018-02-09 15:42:00 +08:00
22af60ef0c MdePkg/PeiServicesLib: Add PeiServicesResetSystem2()
Add the PeiServicesResetSytstem2() function to the PeiServiesLib
to call the ResetSystem2() services in the PEI Services Table.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit dacf87e885)
2018-02-09 15:41:59 +08:00
5d10c5a3a1 ShellPkg/Dp: Updated to dump perf log based on FPDT table
Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@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>
(cherry picked from commit 115eae650b)
2018-02-09 15:37:21 +08:00
165e857d99 MdeModulePkg/FirmwarePerfSmm:Enhance for new pref infrastructure
V3:
a. Remove unused definitions
b. Get records size form the records buffer when getting size action
is triggered.

V2:
Update FirmwarePerformanceSmm to receive the address
of performance records instead of records content.

Receive buffer address of Boot performance records
which are reported by SmmCorePerformanceLib.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@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>
(cherry picked from commit 718a937ed9)
2018-02-09 15:37:20 +08:00
b638171f67 MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure
V4:
Update the GUID for status code in DxeCorePerformanceLib and
FirmwarePerformanceDxe.

V3:Add handling for the case when performance feature is not enabled.

V2:
Update FirmwarePerformanceDxe to receive the address
of performance records instead of records content.

1. Remove the macro EXTENSION_RECORD_SIZE, since the extension
size can be got through PcdExtFpdtBootRecordPadSize.

2. Hook EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT to install ACPI table

3. Copy SMM record accord to the allocated size

4. Receive Boot performance table address instead of
 contents which are reported DxeCorePerformanceLib.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@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>
(cherry picked from commit 9e62c23017)
2018-02-09 15:37:19 +08:00
d8fd99b903 MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase
Add FPDT records into boot performance table for S3 phase

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@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>
(cherry picked from commit 2040e6c556)
2018-02-09 15:37:19 +08:00
20f8e6aad6 MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase
V3:
a. Handle the case when string is empty in String Record.
b. Use gEdkiiFpdtExtendedFirmwarePerformanceGuid to report status
code.
c. Refine the code logic.

V2:
Update SmmCorePerformanceLib to report the buffer address of
boot performance records instead of records contents.

Updated to convert Pref entry to FPDT record in SMM phase and then
export records to FPDT table.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@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>
(cherry picked from commit 2001f84e8c)
2018-02-09 15:37:18 +08:00
ecb4b8a61d MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase
V4:
a.Update the GUID for status code in DxeCorePerformanceLib and
FirmwarePerformanceDxe.
b. Add check for Insert FPDT record in DxeCorePerformanceLib
to avoid re-entry case.

V3:
a. Handle the case when string is empty in String Record.
b. refine the code logic.

V2:
Update DxecorePerformanceLib to report the boot performance table
address instead of records contents.

Updated to convert Pref entry to FPDT record in DXE phase and then
allocate boot performance table to save the record and report
the address of boot performance table to FirmwarePerformanceDxe.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@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>
(cherry picked from commit 9609d24b19)
2018-02-09 15:37:17 +08:00
6a6e61d427 MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase
V3:Handle the case when string is empty in String Record.

Updated to convert Pref entry to FPDT record in PEI phase and then
report the records to DxeCorePerfLib through GUID hob.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@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>
(cherry picked from commit 9169f67690)
2018-02-09 15:37:17 +08:00
e8e1dc3cbc MdeModulePkg:Add definitions for new Performance infrastructure
V3:
Add "FPDT_" prefix for related definitions.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 73fef64f14)
2018-02-09 15:37:16 +08:00
019c7b79a6 UefiCpuPkg/FeaturesLib: don't init MCi_CTL/STATUS when MCA's disabled
Today's McaInitialize() doesn't check State value before initialize
MCi_CTL and MCi_STATUS.
The patch fixes this issue by only initializing the two kinds of
MSRs when State is enabled.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit dc7363f848)
2018-02-09 12:35:00 +08:00
b61e257fe8 ShellPkg/rm: fix hang when deleting an absolutely-empty directory
An ordinary empty directory should contain "." and ".." entries.
When an empty directory even doesn't contain "." or ".." entry,
FileHandleFindFirstFile() may return error status and a NULL
FileInfo.
IsDirectoryEmpty() implementation in Rm.c doesn't consider this
case and the deference of FileInfo->FileName causes page fault
exception because FileInfo is NULL.
The patch checks the return status of FileHandleFindFirstFile()
to fix this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 7506fe43a1)
2018-02-09 12:26:14 +08:00
54d960ebf9 ShellPkg/hexedit: Fix a read-after-free bug
HDiskImageSetDiskNameOffsetSize() and HFileImageSetFileName()
may be called using the current disk name or file name.
When this happens, today's implementation firstly frees the memory
and then accesses the just-freed memory.
The patch fixes this issue by doing nothing when the disk or file
name is the current one.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 1efda6414f)
2018-02-09 12:26:13 +08:00
9bec5aed4f SourceLevelDebugPkg DebugUsb3: Fix GCC build failures
Fix GCC build failures below.
variable 'EvtTrb' set but not used [-Werror=unused-but-set-variable]
variable 'Index' set but not used [-Werror=unused-but-set-variable]

The build failure could only be caught with -D SOURCE_DEBUG_USE_USB3
build flag.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit ad6040ec9b)
2018-02-09 10:51:44 +08:00
768e193eb4 MdeModulePkg: Don't build VarCheckUefiLib and DxeCore for EBC arch
EBC build failure is caused by d7a09cb86a.
It changes MAX_UINTN and MAX_ADDRESS definition as below. VarCheckUefiLib
and DxeCore uses MAX_UINTN and MAX_ADDRESS in the global data initialization.
New style has >> operator, and not supported by EBC compiler.
The fix is not to build VarCheckUefiLib and DxeCore for EBC arch.

#define MAX_UINTN  ((UINTN) ~0)
==>
#define MAX_UINTN  ((UINTN)(~0ULL >> (64 - sizeof (INTN) * 8)))

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit f1f8ce6de7)
2018-02-08 19:19:54 +08:00
c376e657c2 SecurityPkg: Don't build AuthVariableLib for EBC arch
EBC build failure is caused by d7a09cb86a.
It changes MAX_UINTN definition as below. AuthVariableLib uses MAX_UINTN
in the global data initialization. New style has >> operator, and not
supported by EBC compiler. The fix is not to build AuthVariableLib for EBC.

#define MAX_UINTN  ((UINTN) ~0)
==>
#define MAX_UINTN  ((UINTN)(~0ULL >> (64 - sizeof (INTN) * 8)))

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
(cherry picked from commit 1662676d58)
2018-02-08 19:19:53 +08:00
7423a64227 SourceLevelDebugPkg DebugUsb3: Support IOMMU
For PEI, allocate granted DMA buffer from IOMMU PPI.
For DXE, map DMA buffer by PciIo.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit de8373fa07)
2018-02-08 16:46:53 +08:00
44fa08ab7c SourceLevelDebugPkg DebugUsb3: Fix some typos
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit f4043414da)
2018-02-08 16:46:53 +08:00
c1ec9d0194 SourceLevelDebugPkg DebugAgentLib: Rename IsBsp to DebugAgentIsBsp
For avoiding function name confliction,
rename IsBsp to DebugAgentIsBsp.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit a2acb04ca6)
2018-02-08 16:46:52 +08:00
1c65ddbf24 SecurityPkg: Tcg2Smm: Refine type cast in pointer abstraction
Pointer subtraction is not performed by pointers to elements of the same
array object. Such behavior is undefined by C11 standard and might lead to
potential issues, Refine pointer subtraction by first casting each pointer
to UINTN.

Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 28fd7b090d)
2018-02-08 16:11:40 +08:00
3885ffd841 UefiCpuPkg/FeaturesLib: Fix Haswell CPU hang with 50% throttling
Today's implementation only assumes SandyBridge CPU supports
Extended On-Demand Clock Modulation Duty Cycle.
Actually it is supported when CPUID.06h.EAX[5] == 1.

When platform requests 50% throttling, it causes value 1000b
set to the low-4 bits of IA32_CLOCK_MODULATION.
But the wrong code sets 1000b to bits[1-3] which causes assertion.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jeff Fan <vanjeff_919@hotmail.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 0c8b880223)
2018-02-08 13:49:44 +08:00
068b00d7da UefiCpuPkg/PiSmmCpuDxeSmm: fix infinite loop issue in SMM profile
> v2:
>   Reduce the number of page to update/restore from 3 to 2 because DF
>   has no effect in this issue.

The infinite loop is caused by the memory instruction, such as
"rep mov", operating on memory block crossing boundary of NON-PRESENT
pages. Because the address triggering page fault set in CR2 will be in
the first page, SmmProfilePFHandler() will only change the first page
into PRESENT. The page following will be still in NON-PRESENT status.

Since SmmProfilePFHandler() will setup single-step trap for the
instruction causing #PF, when the handler returns back to the
instruction and re-execute it, both #DB and #PF will be triggered
because the instruction wants to access both first and second page
but only first page is PRESENT.

Normally #DB exception will be handled first and its handler will
change first page back to NON-PRESENT status. Then #PF is handled
and its handler will change first page to PRESENT status again and
setup another single-step for the instruction triggering #PF. Then
the whole system falls into an infinite loop and the memory operation
will never move on.

This patch fix above situation by always changing 2 pages to PRESENT
status instead of just 1 page. Those 2 pages include the page causing
#PF and the page after it.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 890d9ee554)
2018-02-08 12:48:14 +08:00
dfea53f000 MdeModulePkg/PiSmmCore: add API parameter check
The Heap Guard feature wrapped SmmInternalFreePagesEx with
SmmInternalFreePagesExWithGuard but didn't add necessary
parameter check. This patch fixes this situation.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@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>
(cherry picked from commit 7823611cda)
2018-02-08 12:48:13 +08:00
aa2c146bb2 MdeModulePkg/PciBusDxe: Fix VS2012 build failure
Initialize local variable to suppress warning C4703:
potentially uninitialized local pointer variable.

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

Cc: Star Zeng <star.zeng@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit a012bf6e3e)
2018-02-08 12:48:13 +08:00
5508504e23 Nt32Pkg/Nt32Pkg.fdf: Increase the size of FLASH Device.
Currently, the FV image size is not enough for the modules after
we enable some flags defined in Nt32Pkg.dsc, e.g:
 DEFINE SECURE_BOOT_ENABLE      = TRUE
 DEFINE TLS_ENABLE              = TRUE
 DEFINE NETWORK_IP6_ENABLE      = TRUE

This patch is to increase the size of FLASH Device to meet the requirement.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit c60d751b73)
2018-02-08 08:27:19 +08:00
82a4f0cf4e IntelSiliconPkg IntelVTdPmrPei: Install IOMMU PPI for pre-memory phase
Install IOMMU PPI for pre-memory phase and return
EFI_NOT_AVAILABLE_YET to indicate that DMA protection has been enabled,
but DMA buffer are not available to be allocated yet.

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>
(cherry picked from commit 940dbd071e)
2018-02-07 18:31:29 +08:00
3b5e8efa46 MdeModulePkg Ppi/IoMmu.h: Add EFI_NOT_AVAILABLE_YET return status code
Install IOMMU PPI for pre-memory phase and return
EFI_NOT_AVAILABLE_YET to indicate that DMA protection has been enabled,
but DMA buffer are not available to be allocated yet.

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>
(cherry picked from commit 20b58eb850)
2018-02-07 18:31:28 +08:00
cd59051481 IntelSiliconPkg IntelVTdPmrPei: Install IoMmu PPI before enabling PMR
Then the consumer of IoMmu PPI has opportunity to get granted DMA
buffer (by callback) to replace old buffer before it is forbidden
by enabling PMR.

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>
(cherry picked from commit ed0e52fc9a)
2018-02-07 18:31:28 +08:00
6908dd1655 IntelSiliconPkg PlatformVTdSampleDxe: State it is only for dev/debug
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael Kinney <michael.d.kinney@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>
(cherry picked from commit 17ac6b23dc)
2018-02-07 10:52:18 +08:00
f4aaa6f2ae MdePkg ACPI: Add some macros for PPTT
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang <huangming23@huawei.com>
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit c4e75574a0)
2018-02-07 10:50:51 +08:00
abb0427276 SecurityPkg:Tcg2Smm: Fix compile issue
Update Tcg2Smm _PRS patching logic to fix compile issue

Cc: Liming Gao <liming.gao@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 449083a3f8)
2018-02-07 09:06:48 +08:00
2504544636 ShellPkg/map: Fix out-of-bound read when "map fsn"
The below code reads additional one CHAR16 when copying
content from Specific to NewSpecific.
NewSpecific = AllocateCopyPool(
                StrSize(Specific) + sizeof(CHAR16), Specific
                );

The patch fixes this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
(cherry picked from commit 4887443e4f)
2018-02-06 17:32:21 +08:00
7fa431ea7f MdePkg/SafeString: Fix potential out-of-bound memory access
Today's implementation of [Ascii]StrnCpyS/[Ascii]StrnCatS calls
StrnLenS () to get the length of source string but supplies the
destination buffer size as max size.
It's a bug that may cause out-of-bound memory access.
For example:
  StrnCpyS (Dest[10], 10, "hello", 6)
  -> StrnLenS ("hello", 10) //< cause out-of bound memory access

In a pool guard enabled environment, when using shell to edit an
existing file which contains empty line, the page fault is met.

The patch fixes the four library functions to avoid such
out-of-bound memory access.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
(cherry picked from commit 56658c22a6)
2018-02-06 17:32:19 +08:00
c46ac8ca03 ShellPkg/for: Fix potential null pointer deference
When "FOR %a %a IN A B C" is executed,
CurrentScriptFile->CurrentCommand->Data is NULL.
But the code assumes it's not NULL and tries to
deference it.

The patch fixes this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 7162fdb037)
2018-02-06 17:32:19 +08:00
810bf8c328 UefiCpuPkg/MtrrLib: Fix an assertion bug
0                     40          f0         100
+---WT--+--UC--+--WT--+-----WB----+----UC----+

When calculating the shortest path from 0 to 100, the
MtrrLibCalculateLeastMtrrs() is called to update the
Vertices.Previous.
When calculating the shortest path from 0 to 40,
MtrrLibCalculateLeastMtrrs() is called recursively to update the
Vertices.Previous.
The second call corrupt the Previous value that will be used
later.
The patch removes the code that corrupts Previous.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 0e8a782922)
2018-02-06 16:04:13 +08:00
ffa1916276 UefiCpuPkg/MtrrLib: Fix a MTRR calculation bug
80                   A8   B0   B8   C0
+----------WB--------+-UC-+-WT-+-WB-+

For above memory settings, current code caused the final MTRR
settings miss [A8, B0, UC] when default memory type is UC.

The root cause is the code only checks the mandatory weight
between A8 to B0, but skips to check the optional weight.
The patch fixes this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 579510336e)
2018-02-06 16:04:13 +08:00
12204aa47f UefiCpuPkg/MtrrLib: Correct typo to change vector to vertex
The patch only change the comments and variable name so
doesn't impact the functionality.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 3143144ba5)
2018-02-06 16:04:12 +08:00
deaaaa9364 UefiCpuPkg/MtrrLib: Handle one setting request covering all memory
*SetMemoryAttribute*() API cannot handle the setting request that
looks like <0, MAX_ADDRESS, Type>. The buggy parameter checking
logic returns Unsupported for this case.
The patch fixes the checking logic to handle such case.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit cee85c48e9)
2018-02-06 16:04:11 +08:00
9730ca2d50 UefiCpuPkg/MtrrLib: Fix bug that may calculate wrong MTRR result
Code forgot to initialize the optional weight between adjacent
vertices. It caused wrong MTRR result was calculated for some
memory settings.

The logic was incorrectly removed when converting from POC
code. The patch adds back the initialization.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit ffb4c72d7b)
2018-02-06 16:04:10 +08:00
393908e084 UefiCpuPkg/MtrrLib: Refine the debug messages
MtrrSetMemoryAttributesInMtrrSettings() missed the debug messages
of memory attribute request and status. The patch moves all debug
messages from MtrrSetMemoryAttributeInMtrrSettings() to
MtrrSetMemoryAttributesInMtrrSettings() and refines the debug message
to carry more information.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 5a6c5af64a)
2018-02-06 16:04:10 +08:00
9fd71feb30 SecurityPkg: Support PP version lower than 1.3
TCG PP 1.2 & PP 1.3 spec defined different Opcodes.
Update code to support both.

Cc: Long Qin <qin.long@intel.com>
Cc: Yao Jiewen <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
2018-02-06 15:02:24 +08:00
ce58945513 SecurityPkg: Add UNI string for 2 PCDs
Add prompt & help string for PcdTpm2CurrentIrqNum, PcdTpm2PossibleIrqNumBuf

Cc: Dandan Bi <dandan.bi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
2018-02-06 15:02:22 +08:00
a8809711ba BaseTools: enhance error check for DatumType format
Add a check for DatumType format, eg: VOID *, original Tool will crash
but no detail error message which cause confusion to user.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit e0db09cd1c)
2018-02-06 13:52:53 +08:00
24c4086758 BaseTools GNUmakefile: Remove HOST_ARCH in every tool Makefile
HOST_ARCH has been moved into the common header.makefile

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit d16e777ac5)
2018-02-06 13:52:53 +08:00
b6eef092f6 BaseTools GNUmakefile: Move HOST_ARCH detection into common makefile
With this change, enter single tool directory, make can pass.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 1eac82c878)
2018-02-06 13:52:52 +08:00
ed536b27f1 BaseTools: Update Expression.py for VOID* to support L'a' and 'a'
Original VOID* type support L"string" and "string" format, now we also
add support for single quote string that without null terminator.
Type VOID* support L'a' and 'a', the value transfer to c style value.
L'a' --> {0x61, 0x00}
L'ab' --> {0x61, 0x00, 0x62, 0x00}
'a'  --> {0x61}
'ab' --> {0x61, 0x62}

when the value is L'' or '' that not include any character, tool will
report error.

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>
(cherry picked from commit 0e6b86731e)
2018-02-06 13:52:52 +08:00
b38d570423 BaseTools: StructurePcd array Value support flexible format
if StructurePcd set item value is array, support flexible format
like as:
gEfiStructuredPcdPkgTokenSpaceGuid.Test.Array | {flexible format}
{flexible format} = {L"ABC"} | {L'ABC'} | {"ABC"} | {UINT8(0x10)}
                  | {UINT16(0x10)} | {UINT32(0x10)} | {UINT64(0x10)}
                  | {DEVICE_PATH("PciRoot(0)/Pci(0,0)")}
                  | {GUID(gPcdPkgTokenSpaceGuid)}
                  | {L"ABC", L'ABC', UINT8(0x10)....}

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>
(cherry picked from commit bee0f2f167)
2018-02-06 13:52:51 +08:00
c5c0f5e23c BaseTools: Fix make PcdValueCommon.c failure on GCC
error message:
PcdValueCommon.c: In function '__PcdGetPtr':
PcdValueCommon.c:315:11: error: variable 'Byte'
set but not used [-Werror=unused-but-set-variable]
   UINT8   Byte;
           ^
cc1: all warnings being treated as errors

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>
(cherry picked from commit 693877f8e5)
2018-02-06 13:52:51 +08:00
a55e485723 BaseTools CommonLib: Remove the unnecessary print message in PcdValueCommon
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 83ba30c5a3)
2018-02-06 13:52:50 +08:00
e4de673b54 MdeModulePkg/PXE: Add warning message for PXE if failed to read system GUID from SMBIOS.
Current PXE driver uses zero GUID if failed to get the system GUID from smbios
table, and some OS PXE boot may fail in such case. This patch is to add a warning
message to inform user that smbios table is missed on the platform.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
2018-02-05 13:40:49 +08:00
bfb539c101 NetworkPkg: Add warning message for PXE if failed to read system GUID from SMBIOS.
Current PXE driver uses zero GUID if failed to get the system GUID from smbios
table, and some OS PXE boot may fail in such case. This patch is to add a warning
message to inform user that smbios table is missed on the platform.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
2018-02-05 13:40:47 +08:00
5e69443e82 MdeModulePkg/SmmCore: Fix hang due to already-freed memory deference
SmiHandlerUnRegister() validates the DispatchHandle by checking
whether the first 32bit matches to a certain signature
(SMI_HANDLER_SIGNATURE).
But if a caller calls *UnRegister() twice and the memory freed by
first call still contains the signature, the second call may hang.

The patch fixes this issue by locating the DispatchHandle
in all SMI handlers, instead of checking the signature.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 8a641d2b73)
2018-02-03 14:51:27 +08:00
1de7f6464a BaseTools: Structure Pcd in CommandLine.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 6f49996ced)
2018-02-02 11:50:07 +08:00
fde92af67d BaseTools: Support multiple .h file
for structure Pcd declaration in DEC file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 81add864f4)
2018-02-02 11:50:07 +08:00
cb3a39107e BaseTool: Enhance error handling.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 5db9414cc1)
2018-02-02 11:50:06 +08:00
4dfaf65c8c BaseTool: Add comments in PcdValueInit.c.
Add Comments for __FLEXIBLE_SIZE () statement.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 75771aebd3)
2018-02-02 11:50:06 +08:00
c71d8cc19a BaseTools: Update BPDG to support L'' and '' format as VPD Pcd Value
Current Pcd value support flexible format, this patch add support for
BPDG Tool to support L'' and '' format.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit d5988a8ac9)
2018-02-02 11:50:05 +08:00
1285ca0a27 BaseTools: Fix the bug to align VPD PCD based on value type
Spec required for VOID* VPD Pcd, Ascii string use byte alignment, byte
array use 8-byte alignment, unicode string use 2-byte alignment.
while when the VPD pcd offset use *, the offset generated in the .map
file not follow this rule.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 86737681af)
2018-02-02 11:50:05 +08:00
ec37c40e5f IntelSiliconPkg/MicrocodeUpdateDxe: Refine debug messages
Refine the debug messages during the verification of microcode to make
them more clear.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 2ad34f65af)
2018-02-02 11:38:12 +08:00
4fa13b6957 MdeModulePkg/Core: fix feature conflict between NX and heap guard
Considering following scenario (both NX memory protection and heap guard
are enabled):

   1. Allocate 3 pages. The attributes of adjacent memory pages will be

      |NOT-PRESENT|  present  |  present  |  present  |NOT-PRESENT|

   2. Free the middle page. The attributes of adjacent memory pages should be

      |NOT-PRESENT|  present  |NOT-PRESENT|  present  |NOT-PRESENT|

      But the NX feature will overwrite the attributes of middle page. So it
      looks still like below, which is wrong.

      |NOT-PRESENT|  present  |  PRESENT  |  present  |NOT-PRESENT|

The solution is checking the first and/or last page of a memory block to be
marked as NX, and skipping them if they are Guard pages.

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: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit a6a0a59756)
2018-02-02 10:03:16 +08:00
3f251a864a MdeModulePkg/Core: fix feature conflict between NX and NULL detection
If enabled, NX memory protection feature will mark all free memory as
NX (non-executable), including page 0. This will overwrite the attributes
of page 0 if NULL pointer detection feature is also enabled and then
compromise the functionality of it. The solution is skipping the NX
attributes setting to page 0 if NULL pointer detection feature is enabled.

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: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 9b17c6511d)
2018-02-02 10:03:15 +08:00
1a8a1978ea MdeModulePkg/Core: fix guard page missing issue
This issue is a regression one caused by a patch at

    425d25699b

That fix didn't take the 0 page to free into account, which still
needs to call UnsetGuardPage() even no memory needs to free.

The fix is just moving the calling of UnsetGuardPage() to the place
right after calling AdjustMemoryF().

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 1263ecf2ff)
2018-02-02 10:03:14 +08:00
e8bfb85874 IntelFrameworkModule/ThunkKb: ReadKeyStrokeEx always return key state
Today's implementation only return key state when there is a key.
But when user doesn't press any key, the key state cannot be
returned.

The patch changes the ReadKeyStrokeEx() to always return the
key state even there is no key pressed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
(cherry picked from commit 821807bcef)
2018-02-01 14:06:17 +08:00
910e904d9c IntelFrameworkModule/Ps2Kb: ReadKeyStrokeEx always return key state
Today's implementation only return key state when there is a key.
But when user doesn't press any key, the key state cannot be
returned.

The patch changes the ReadKeyStrokeEx() to always return the
key state even there is no key pressed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
(cherry picked from commit 896ae6fc24)
2018-02-01 14:06:17 +08:00
b2b7bff4db MdeModulePkg/Ps2Kb: ReadKeyStrokeEx always return key state
Today's implementation only return key state when there is key.
But when user doesn't press any key, the key state cannot be
returned.

The patch changes the ReadKeyStrokeEx() to always return the
key state even there is no key pressed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
(cherry picked from commit c9e6803cf4)
2018-02-01 14:06:16 +08:00
217f8c5912 MdeModulePkg/UsbKb: ReadKeyStrokeEx always return key state
Today's implementation only return key state when there is key.
But when user doesn't press any key, the key state cannot be
returned.

The patch changes the ReadKeyStrokeEx() to always return the
key state even there is no key pressed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
(cherry picked from commit c095341cc4)
2018-02-01 14:06:15 +08:00
48aa7b264e MdeModulePkg/ConSplitter: ReadKeyStrokeEx always return key state
Today's implementation only return key state when there is key.
But when user doesn't press any key, the key state cannot be
returned.

The patch changes the ReadKeyStrokeEx() to always return the
key state even there is no key pressed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
(cherry picked from commit 20ddbc133f)
2018-02-01 14:06:15 +08:00
a919bfcd28 MdePkg/SimpleTextInEx.h: Fix comments alignment
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 2de87e461d)
2018-02-01 14:06:14 +08:00
f9697b7634 UefiCpuPkg/PiSmmCpuDxeSmm: eliminate conditional jump in IA32 SmmStartup()
SMM emulation under both KVM and QEMU (TCG) crashes the guest when the
"jz" branch, added in commit d4d87596c1 ("UefiCpuPkg/PiSmmCpuDxeSmm:
Enable NXE if it's supported", 2018-01-18), is taken.

Rework the propagation of CPUID.80000001H:EDX.NX [bit 20] to IA32_EFER.NXE
[bit 11] so that no code is executed conditionally.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Ref: http://mid.mail-archive.com/d6fff558-6c4f-9ca6-74a7-e7cd9d007276@redhat.com
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
[lersek@redhat.com: XD -> NX code comment updates from Ray]
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
[lersek@redhat.com: mark QEMU/TCG as well in the commit message]
(cherry picked from commit 8d4d55b15b)
2018-02-01 11:02:46 +08:00
e21f0bddef UefiCpuPkg/PiSmmCpuDxeSmm: remove unneeded DBs from IA32 SmmStartup()
The SmmStartup() executes in SMM, which is very similar to real mode. Add
"BITS 16" before it and "BITS 32" after it (just before the @32bit label).

Remove the manual 0x66 operand-size override prefixes, for selecting
32-bit operands -- the sizes of our operands trigger NASM to insert the
prefixes automatically in almost every spot. The one place where we have
to add it back manually is the LGDT instruction. (The 0x67 address-size
override prefix is also auto-generated.)

This patch causes NASM to generate byte-identical object code (determined
by disassembling both the pre-patch and post-patch versions, and comparing
the listings), except:

> @@ -158,7 +158,7 @@
>  00000142  6689D3            mov ebx,edx
>  00000145  66B800000000      mov eax,0x0
>  0000014B  0F22D8            mov cr3,eax
> -0000014E  67662E0F0155F6    o32 lgdt [cs:ebp-0xa]
> +0000014E  2E66670F0155F6    o32 lgdt [cs:ebp-0xa]
>  00000155  66B800000000      mov eax,0x0
>  0000015B  0F22E0            mov cr4,eax
>  0000015E  66B9800000C0      mov ecx,0xc0000080

The only difference is the prefix list order, it changes from:

- 0x67, 0x66, 0x2E

to

- 0x2E, 0x66, 0x67

(0x2E is "CS segment override").

Cc: Eric Dong <eric.dong@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=866
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit e75ee97224)
2018-02-01 11:02:45 +08:00
96fc62864e UefiCpuPkg/PiSmmCpuDxeSmm: update comments in IA32 SmmStartup()
The gSmmCr3, gSmmCr4, gSmmCr0 and gSmmJmpAddr global variables are used
for patching assembly instructions, thus we can't yet remove the DB
encodings for those instructions. At least we should add the intended
meanings in comments.

This patch only changes comments.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
[lersek@redhat.com: adapt commit msg to ongoing PatchAssembly discussion]
(cherry picked from commit 994df20926)
2018-02-01 11:02:44 +08:00
cac4da695e MdeModulePkg PiSmmCore: Set ForwardLink to NULL in RemoveOldEntry()
"Entry->Link.ForwardLink = NULL;" is present in RemoveMemoryMapEntry()
for DxeCore, that is correct.
"Entry->Link.ForwardLink = NULL;" is absent in RemoveOldEntry()
for PiSmmCore, that is incorrect.

Without this fix, when FromStack in Entry is TRUE,
the "InsertTailList (&mMapStack[mMapDepth].Link, &Entry->Link);" in
following calling to CoreFreeMemoryMapStack() will fail as the entry
at mMapStack[mMapDepth] actually has been removed from the list.

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>
(cherry picked from commit e434be3c9c)
2018-01-31 17:24:50 +08:00
22efda70bb BaseTools: Enhance parse performance by optimize ValueExpressionEx
Optimize ValueExpressionEx function to enhance meta-data file parse
performance.

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>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 35f613d96c)
2018-01-31 10:03:54 +08:00
fc15259c5e MdePkg ACPI: Correct processor struct of PPTT
The Type field of EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR should
be UINT8 as ACPI version 6.2 specification.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang <huangming23@huawei.com>
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 19ef86eec6)
2018-01-31 09:59:51 +08:00
1a908b736a BaseTools: Fix indentation in CParser.py file
Mixing usage of spaces and tabs may confuse the python
compiler/interpreter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Gary Lin <glin@suse.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 877251b421)
2018-01-30 10:56:28 +08:00
bc32f1b0fa BaseTools: Fixed incorrect VPD size.
The VPD size is incorrect if that VPD is not used in Module.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Feng Bob C <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit e827d21da1)
2018-01-30 10:56:28 +08:00
ef4864d8d9 BaseTool: Fixed the StructurePcd incorrect value.
If user not set Structure overall value in Dsc,
Structure Pcd value would be incorrect.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 9904222db0)
2018-01-30 10:56:27 +08:00
b90f32046f BaseTools: Fixed some small issues
1. The structure pcd default value should use the default value under sku.
2. Incorrect VpdOffset value for those un-used in module Vpd
3. Add a checkpoint for Structure Pcd Name

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 8e011d83bb)
2018-01-30 10:56:27 +08:00
4672455e80 BaseTools: Fixed build failure for the PCD value initialization.
A pcd is initialized under one SKU but is uninitialized under another SKU.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 841d86fe40)
2018-01-30 10:56:26 +08:00
b650d6da4e BaseTools: Add comments for the Structure Pcd definition in PcdValueInit.c file
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 6a10344080)
2018-01-30 10:56:26 +08:00
f15dd88d04 BaseTool: Combine the HiiPcd value if they link to same Variable
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit e6bf3cfd50)
2018-01-30 10:56:25 +08:00
cd4ae3e155 BaseTools: CommonLib Fix Crash to write the last byte
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 4faf534046)
2018-01-30 10:56:25 +08:00
2946f624a5 BaseTools: Barf on unknown HOST_ARCH in C Makefile
I was getting `HOST_ARCH` set using the linux arch name ("x86_64"), which
is different from the MS one ("X64").

It is not clear anyway we can proceed without valid build variables
(`ARCH_INCLUDE`, `BIN_PATH`, `LIB_PATH`, `SYS_BIN_PATH`, and
`SYS_LIB_PATH`).

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chema Gonzalez <chemag@gmail.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 9d5aab0554)
2018-01-30 10:56:24 +08:00
57d1436760 BaseTools/tools_def CLANG3x: ignore unknown warning options
Ironically, disabling warnings in the OpensslLib library build is
causing breakage when using the CLANG35 toolchain to build for ARM:

error: unknown warning option '-Werror=maybe-uninitialized'; did you mean '-Werror=uninitialized'? [-Werror,-Wunknown-warning-option]

So let's add -Wno-unknown-warning-option to the list of warnings to
ignore when using Clang 3.5, and move the same option from the x86
specific list to the shared list for Clang 3.8.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit faf0475b13)
2018-01-30 10:55:13 +08:00
157bfbda78 BaseTools: Enable MAX_CONCURRENT_THREAD_NUMBER = 0 feature
when set 'MAX_CONCURRENT_THREAD_NUMBER=0',  will auto-detect number of
processor threads as MAX_CONCURRENT_THREAD_NUMBER.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775
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>
(cherry picked from commit 29af38b0f8)
2018-01-30 10:54:06 +08:00
14553a2e5d SecurityPkg: Disable TPM interrupt in DEC
Disable TPM interrupt support in DEC by default to keep compatibility

Cc: Yao Jiewen <jiewen.yao@intel.com>
Cc: Long Qin <qin.long@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
(cherry picked from commit 5552ac4231)
2018-01-30 10:25:12 +08:00
1ed328a0d7 SecurityPkg: Tcg2Smm: Enable TPM2.0 interrupt support
1. Expose _CRS, _SRS, _PRS control method to support TPM interrupt
2. Provide 2 PCDs to configure _CRS and _PRS returned data

Cc: Yao Jiewen <jiewen.yao@intel.com>
Cc: Ronald Aigner <Ronald.Aigner@microsoft.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
(cherry picked from commit c4122dcaad)
2018-01-29 15:11:12 +08:00
c4e2b684d2 ShellPkg/Level2Command: Use UnicodeCollation in StrinCmp
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 630cb8507b)
2018-01-29 09:43:58 +08:00
c14a1acf9e ShellPkg/CommandLib: Locate proper UnicodeCollation instance
Original code locates the first UnicodeCollation instance in
DXE Core protocol database.
It's not correct considering multiple UnicodeCollation instances
exist in system.
The patch changes logic to find the one that matches the current
system language.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com.
(cherry picked from commit d65f2cea36)
2018-01-29 09:43:57 +08:00
fde36f597e ShellPkg/UefiShellLevel2CommandsLib: add missing EFIAPI call conv spec
UefiShellLevel2CommandsLib (somewhat questionably) calls the
BaseLib-internal function InternalCharToUpper().

This function is declared in "MdePkg/Library/BaseLib/BaseLibInternals.h",
which is not a public library class header. UefiShellLevel2CommandsLib
therefore duplicates the function declaration, but a mistake was made: the
EFIAPI calling convention is not spelled out on the duplicated
declaration. Therefore calls made from UefiShellLevel2CommandsLib will not
match the actual function definition in "MdePkg/Library/BaseLib/String.c",
when GCC/X64 toolchains are used.

One consequence of this is that cross-filesystem copies don't work in the
UEFI shell (see the StrniCmp() function in
"UefiShellLevel2CommandsLib.c"). From the original report:

> FS0:\efi\ubuntu\> cp grubx64.efi fs1:\
>
> cp: The source and destination are the same.

Copy the declaration from "BaseLibInternals.h" to
"UefiShellLevel2CommandsLib.c" verbatim.

Reported-by: Rebecca Cran <rebecca@bluestop.org>
Analyzed-by: Thomas Palmer <thomas.palmer@hpe.com>
Analyzed-by: Liming Gao <liming.gao@intel.com>
Ref: http://mid.mail-archive.com/47cd17d8-f022-6ca5-2f52-06a8250f8d14@cran.org.uk
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Rebecca Cran <rebecca@bluestop.org>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Thomas Palmer <thomas.palmer@hpe.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Thomas Palmer <thomas.palmer@hpe.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 038720e899)
2018-01-29 09:43:57 +08:00
b0821b18eb UefiCpuPkg/CpuDxe: remove all code to flush TLB for APs
The reason doing this is that we found that calling StartupAllAps() to
flush TLB for all APs in CpuDxe driver after changing page attributes
will spend a lot of time to complete. If there are many page attributes
update requests, the whole system performance will be slowed down
explicitly, including any shell command and UI operation.

The solution is removing the flush operation for AP in CpuDxe driver
and let AP flush TLB after woken up.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 41a9c3fd11)
2018-01-29 09:38:25 +08:00
1bc6e00bb1 UefiCpuPkg/MpInitLib: force flushing TLB for AP in mwait loop mode
The reason doing this is that we found that calling StartupAllAps() to
flush TLB for all APs in CpuDxe driver after changing page attributes
will spend a lot of time to complete. If there are many page attributes
update requests, the whole system performance will be slowed down
explicitly, including any shell command and UI operation.

The solution is removing the flush operation for AP in CpuDxe driver.
Since TLB is always flushed in HLT loop mode, we just need to enforce
a TLB flush for mwait loop mode.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 199de89677)
2018-01-29 09:38:24 +08:00
2bf01a60be UefiCpuPkg/MpInitLib: fix AP init issue in 64-bit PEI
This issue is introduced by a patch at

   f32bfe6d06

The above patch miss the case of 64-bit PEI, which will link
X64/MpFuncs.nasm instead of Ia32/MpFuncs.nasm. For X64/MpFuncs.nasm,
ExchangeInfo->ModeHighMemory should be always initialized no matter
if separate wakeup buffer is allocated or not. Ia32/MpFuncs.nasm will
not need ModeHighMemory during AP init. So the changes made in this
patch should not affect the functionality of it.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 69dfa8d87a)
2018-01-29 09:38:23 +08:00
9ca7351cec UefiCpuPkg/MpInitLib: Make sure AP uses correct StartupApSignal
Every processor's StartupApSignal is initialized in
MpInitLibInitialize() before calling CollectProcessorCount().
When SortApicId() is called from CollectProcessorCount(), AP Index
is re-assigned by APIC ID. But SortApicId() forgets to set the
correct StartupApSignal when sorting the AP.

The patch fixes this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
(cherry picked from commit bafa76ef5b)
2018-01-26 19:12:33 +08:00
83d6fe4156 UefiCpuPkg/CpuExceptionHandler: Init serial port before context dump
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 7230212a43)
2018-01-26 18:57:48 +08:00
bf5d5af234 MdeModulePkg/Partition: Fix media probe
The call in ProbeMediaStatusEx() to the ReadDisk() function of the
EFI_DISK_IO_PROTOCOL interface implemented in DiskIoDxe/DiskIo.c
crashed in DiskIo2ReadWriteDisk() because of the NULL value of
the destination buffer pointer.

Pass the address of a buffer in the stack instead of a NULL
pointer.

The similar fix was applied to ProbeMediaStatus in commit
df473cc1fc
* MdeModulePkg/PartitionDxe: Fix media probe

Somehow ProbeMediaStatusEx() wasn't changed together.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Tested-by: Jian J Wang <jian.j.wang@intel.com>
(cherry picked from commit 68599525d8)
2018-01-26 18:57:47 +08:00
292241519f IntelSiliconPkg MicrocodeUpdateDxe: TotalSize must be multiples of 1KB
TotalSize must be multiples of 1024 bytes (1 KBytes) according to SDM.

Also enhance the debug message for DataSize that must be
multiples of DWORDs.

Cc: Jiewen Yao <jiewen.yao@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: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 1db271df76)
2018-01-26 18:22:20 +08:00
672629b214 ShellPkg: Update package version from 1.01 to 1.02
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 74f3318cc0)
2018-01-26 10:10:25 +08:00
3547f62336 SecurityPkg:Tpm2DeviceLibDTpm: Support TPM command cancel
Support TPM Command cancel if executing command timeouts. Cancel could
happen in long running command case

Cc: Yao Jiewen <jiewen.yao@intel.com>
Cc: Chinnusamy Rajkumar K <rajkumar.k.chinnusamy@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
(cherry picked from commit 11cf02f6d0)
2018-01-25 22:21:27 +08:00
6d005df6f7 NetworkPkg/HttpBootDxe: Avoid to corrupt HttpBootDxe setup screen.
When giving an invalid URI in Boot URI field within HTTP Boot
configuration page, the AsciiPrint will corrupt the setup screen.

This patch is to resolve the issue.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Karunakar P <karunakarp@amiindia.co.in>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
(cherry picked from commit 7ee089f604)
2018-01-25 13:40:26 +08:00
c99948a2d1 MdeModulePkg/UefiBootManagerLib: Skip the DNS device path node check.
After HTTP boot successfully in home mode, the HTTP device path will be
updated accordingly. So, the new device path may be appended with a DNS
device path node. When executing home mode boot again, the original HTTP
device path will mismatch with the new updated one, which will cause the
HTTP boot failure. So, we need update the current match algorithm to match
the correct FilePath. Since the DNS device path is an optional, we can skip
it check.

This patch is to fix above issue.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 6945837e4c)
2018-01-25 13:40:17 +08:00
c0c7e24862 UefiCpuPkg/MpInitLib: fix issue in wakeup buffer initialization
To fix an issue in which enabling NX feature will mark the AP wakeup
buffer as non-executable and fail the AP init, the buffer was split
into two part: the lower part in memory within 1MB and the higher part
within allocated executable memory (EfiBootServicesCode). But the
address of higher part memory was stored in lower part memory, which
is actually shared with legacy components and will be overwritten by
LegacyBiosDxe driver if CSM is enabled.

This patch fixes this issue by storing the address of higher part
memory in CpuMpData instead of ExchangeInfo.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 66833b2a87)
2018-01-25 10:25:40 +08:00
07a6b195e7 ShellPkg/UefiShellLevel3CommandsLib: fix string over-read
In the for-loop condition of original code, the expression

  *CurrentCommand != CHAR_NULL

is put before expression

  CurrentCommand < SortedCommandList + SortedCommandListSize/sizeof(CHAR16)

When CurrentCommand walks to the end of string buffer, one more character
over the end of string buffer will be read and then stop.

To fix this issue, just move the last expression to the first one. Because
of short-circuit evaludation of and-expression, the following one

  *CurrentCommand != CHAR_NULL

will not be evaluated if the expression before it is evaludated as FALSE.

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: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit c3492bd9bb)
2018-01-25 10:25:39 +08:00
3ab4e71ce7 IntelSiliconPkg IntelVTdDxe: Fix flush cache issue
The patch fixes flush cache issue in
CreateSecondLevelPagingEntryTable().

We found some video cards still not work even they have
been added to the exception list.

In CreateSecondLevelPagingEntryTable(), the check
"(BaseAddress >= MemoryLimit)" may be TRUE and "goto Done"
will be executed, then the FlushPageTableMemory operations
at the end of the function will be skipped.

Instead of "goto Done", this patch uses "break" to break
the for loops, then the FlushPageTableMemory operations
at the end of the function could have opportunity to be
executed.

The patch also fixes a miscalculation for Lvl3End.

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>
(cherry picked from commit bac7f02365)
2018-01-24 18:46:54 +08:00
8e6dff048a MdeModulePkg/NvmExpressDxe: Fix data buffer not mapped for Write cmd
Within function NvmExpressPassThru():

The data buffer for the below 2 Admin command:
Create I/O Completion Queue command (Opcode 01h)
Create I/O Submission Queue command (Opcode 05h)

are not mapped to the PCI controller specific addresses.

But the current code logic also prevents the below NVM command:
Write (Opcode 01h)

from mapping its data buffer.

Hence, this commit refine the logic to resolve this issue.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 748cd9a680)
2018-01-24 13:18:09 +08:00
67a282e0cd MdeModulePkg/PciBusDxe: Install PciEnumerationComplete after PciIo
Per PI spec, the PciEnumerationComplete protocol installation
should be after PciIo installation.
Today's implementation installs the PciEnumerationComplete
after hardware enumeration is completed, but before PciIo
installation.
The change corrects the spec/implementation gap.
The change also benefits certain implementation that depends on
the PciIo handle in PciEnumerationComplete callback.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 42e8bc7d16)
2018-01-24 11:41:28 +08:00
1bfcdd264a MdeModulePkg/PciBusDxe: reference gFullEnumeration in one file
The patch is just a code cleanup with no functionality impact.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 2632981783)
2018-01-24 11:41:27 +08:00
15bb108d5f UefiCpuPkg/MtrrLib: Add comments to recommend to use batch-set API
MtrrSetMemoryAttributesInMtrrSettings() is a batch-set API.
When setting multiple ranges of memory attributes, the single-set
API (MtrrSetMemoryAttributeInMtrrSettings and MtrrSetMemoryAttribute)
may fail, but batch-set API may succeed.
Add comments to recommend caller to use batch-set API when setting
multiple ranges.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Ming Shao <ming.shao@intel.com>
(cherry picked from commit bc6a8b78aa)
2018-01-24 11:14:09 +08:00
0bc9d2d64a UefiCpuPkg/MtrrLib: Update the comments for RETURN_BUFFER_TOO_SMALL
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Ming Shao <ming.shao@intel.com>
(cherry picked from commit 8b2eb7b3f6)
2018-01-24 11:14:08 +08:00
77ba92a2ad UefiCpuPkg/PeiMpLib: Fix a system hang-in-pei issue.
GetWakeupBuffer() tries to find a below-1M free memory, it checks
whether the memory is allocated already in
CheckOverlapWithAllocatedBuffer(). When there is a memory allocation
hob (base = 0xff_00000000, size = 0x10000000),
CheckOverlapWithAllocateBuffer() truncates the base to 0 which causes
it always returns TRUE so GetWakeupBuffer() fails to find a below-1MB
memory.

The patch fixes this issue by using UINT64 type.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jeff Fan <vanjeff_919@hotmail.com>
(cherry picked from commit 5986cf382e)
2018-01-24 11:08:16 +08:00
4fe6697310 BaseTools: Add DefaultStore section format Check
This patch add DefaultStore section format Check and it use same logic
with SKUID 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>
(cherry picked from commit 767ddbe874)
2018-01-24 09:50:04 +08:00
dfb02fb2cd BaseTools: update SKUID value to support both integer and Hex number
This patch updated Skuid value to support both integer and hex value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit e6b10112b3)
2018-01-24 09:50:03 +08:00
b0978b5733 BaseTools: Enhance binary file in [Binaries] section use relative path
Enhance the binary file in Asbuilt inf file [Binaries] section use
relative path.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 5e2c0ecd0b)
2018-01-24 09:50:03 +08:00
75b525e0e2 BaseTools: Add "processing meta-data" string back
Previous build tool will display "processing meta-data ..." to let user
know the progress. this Patch add this string back.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit e74cea4c7b)
2018-01-24 09:50:02 +08:00
3992cba4f0 NetworkPkg: Update package version to 0.98
Update package version of NetworkPkg to 0.98.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
2018-01-23 13:28:45 +08:00
2b5c3808f5 NetworkPkg: Fix incorrect parameter check in PXE.Mtftp() function.
According to UEFI spec, the PXE.Mtftp() should return invalid parameter if the
BufferPtr parameter was NULL and the DontUseBuffer parameter was FALSE.
The DontUseBuffer is only used when perform MTFTP/TFTP read operation.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-23 13:28:31 +08:00
dea2caf4b9 CryptoPkg: Update package version to 0.98
Update package version of CryptoPkg to 0.98.

Cc: Ting Ye <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.long@intel.com>
Reviewed-by: Ting Ye <ting.ye@intel.com>
(cherry picked from commit cd9349ac53)
2018-01-23 08:58:24 +08:00
7be94525b8 SecurityPkg: Update package version to 0.98
Update package version of SecurityPkg to 0.98.

Cc: Qin Long <qin.long@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Qin Long <qin.long@intel.com>
(cherry picked from commit b921c62943)
2018-01-23 08:49:46 +08:00
82e0348c77 MdePkg Smbios.h: Update spec version info to 3.1.1
It was missed to be updated at
SHA-1: 043026ac12.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 0b545abb5f)
2018-01-23 07:25:59 +08:00
7070817c36 UefiCpuPkg: Update package version.
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 30142a32ac)
2018-01-22 19:25:15 +08:00
a76ff42a3b MdeModulePkg: Update package version to 0.98
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 6250a1206e)
2018-01-22 19:10:59 +08:00
f6b2f35191 MdePkg: Update DEC and DSC version from 1.07 to 1.08
UEFI2.7/PI1.6 have been added in MdePkg. Update DEC and DSC version to
reflect those changes in MdePkg.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 3d2bb75495)
2018-01-22 17:21:53 +08:00
4420eee99f MdeModulePkg DxeIpl: remove the hard code alignment adjustment in Decompress()
Section data alignment should be made in the build generation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit d40695ad82)
2018-01-22 17:21:40 +08:00
09759b282b MdeModulePkg DxeIpl: remove the hard code alignment adjustment.
Section data alignment should be made in the build generation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 5367f17db4)
2018-01-22 17:21:39 +08:00
37300101db MdeModulePkg SectionExtractionPei: remove the hard code alignment adjustment
Section data alignment should be made in the build generation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit bc6a7a27ce)
2018-01-22 17:21:38 +08:00
e6aea36c3a MdeModulePkg/UsbStorage: Fix "map -r" cannot detect media change
When system boots to Shell without CDROM in the USB CDROM drive,
and then user inserts one CDROM with Eltorito file system,
"map -r" cannot show the the new Eltorito file system.

The root cause is when "map" command probes the media change
by calling dummy ReadBlockIo(), UsbMassStorage ReadBlockIo()
contains a bug that ignores the media change status:
UsbBootDetectMedia() ignores the EFI_MEDIA_CHANGED status
returned from UsbBootIsUnitReady(), in consequence, the
BlockIo protocol re-installation logic doesn't run.

By checking the code change history, below commit
SHA-1: 19bc852765
* remove unnecessary retry logic from usb mass storage driver.
adds the code to skip EFI_MEDIA_CHANGED status.

Talking with the original committer Tian Feng, he said the
change was just a code cleanup, not for a special bug fix.
So I revert part of the patch, only keep the change that
removes unnecessary retry logic. It can fix this bug.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit a662afb5b0)
2018-01-22 16:16:09 +08:00
34fa6fe307 CryptoPkg/BaseCryptLib: Add error handling for time() wrapper
In time() wrapper implementation, the gRT->GetTime() call may be not
available. This patch adds the extra error handling to avoid the
potential dead loop.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.long@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit ab187ae25a)
2018-01-22 14:33:08 +08:00
fe5adb77df UefiCpuPkg/CpuDxe: fix bad boot performance
If features like memory profile, protection and heap guard are enabled,
a lot of more memory page attributes update actions will happen than
usual. An unnecessary sync of CR0.WP setting among APs will then cause
worse performance in memory allocation action. Removing the calling of
SyncMemoryPageAttributesAp() in function DisableReadOnlyPageWriteProtect
and EnableReadOnlyPageWriteProtect can fix this problem. In DEBUG build
case, the boot performance can be boosted from 11 minute to 6 minute.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 0dbb0f1a5c)
2018-01-22 09:22:45 +08:00
7ce3491760 MdeModulePkg/Core: fix a logic hole in page free
This hole will cause page fault randomly. The root cause is that Guard
page, which is just freed back to page pool but not yet cleared not-
present attribute, will be allocated right away by internal function
CoreFreeMemoryMapStack(). The solution to this issue is to clear the
not-present attribute for freed Guard page before doing any free
operation, instead of after those operation.

The reason we didn't do this before is due to the fact that manipulating
page attributes might cause memory allocation action which would cause a
dead lock inside a memory allocation/free operation. So we always set or
unset Guard page outside the memory lock. After a thorough analysis, we
believe clearing a Guard page will not cause memory allocation because
memory we're to manipulate was already manipulated before for sure.
Therefore there should be no memory allocation occurring in this
situation.

Since we cleared Guard page not-present attribute before freeing instead
of after freeing, the debug code to clear freed memory can now be restored
to its original way (aka no checking and bypassing Guard page).

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@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>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 425d25699b)
2018-01-22 09:22:26 +08:00
a46544a8b0 MdeModulePkg/BootScriptExecutorDxe: remove NX attr for FfsBuffer
If PcdDxeNxMemoryProtectionPolicy is set to enable protection for memory
of EfiReservedMemoryType, the BIOS will hang at a page fault exception
triggered by BootScriptExecutorDxe.

The root cause is that this driver will allocate memory of
EfiReservedMemoryType and relocate itself into this new memory. Since
EfiReservedMemoryType of memory is marked non-executable, re-start this
driver after relocation will cause exception. The fix is removing the NX
attribute after memory allocation.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@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>
(cherry picked from commit 6a3094c996)
2018-01-22 09:22:04 +08:00
4fd863634a MdeModulePkg/PiSmmCore: remove NX attr for SMM RAM
If PcdDxeNxMemoryProtectionPolicy is set to enable protection for memory
of EfiReservedMemoryType, the BIOS will hang at a page fault exception
during starting SMM driver.

The root cause is that SMM RAM is type of EfiReservedMemoryType and
marked as non-executable. The fix is simply removing NX attribute for
those memory.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@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>
(cherry picked from commit 94c0129d24)
2018-01-22 09:21:37 +08:00
79e67b2967 UefiCpuPkg/PiSmmCpuDxeSmm: Enable NXE if it's supported
If PcdDxeNxMemoryProtectionPolicy is set to enable protection for memory
of EfiBootServicesCode, EfiConventionalMemory, the BIOS will hang at a page
fault exception triggered by PiSmmCpuDxeSmm.

The root cause is that PiSmmCpuDxeSmm will access default SMM RAM starting
at 0x30000 which is marked as non-executable, but NX feature was not
enabled during SMM initialization. Accessing memory which has invalid
attributes set will cause page fault exception. This patch fixes it by
checking NX capability in cpuid and enable NXE in EFER MSR if it's
available.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit d4d87596c1)
2018-01-22 09:20:31 +08:00
eae0c9e2df UefiCpuPkg/CpuDxe: clear NX attr for page directory
If PcdDxeNxMemoryProtectionPolicy is set to enable protection for memory
of EfiBootServicesCode, EfiConventionalMemory and EfiReservedMemoryType,
the BIOS will hang at a page fault exception randomly.

The root cause is that the memory allocation for driver images (actually
a memory type conversion from free memory, type of EfiConventionalMemory,
to code memory, type of EfiBootServicesCode/EfiRuntimeServicesCode)
will get memory with NX set, because the CpuDxe driver will keep the NX
attribute (with free memory) in page directory during page table splitting
and then override the NX attribute of all its entries.

This patch fixes this issue by not inheriting NX attribute when turning
a page entry into a page directory during page granularity split.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit fbe2c4b9be)
2018-01-22 09:20:02 +08:00
b4cb082f12 UefiCpuPkg/CpuExceptionHandlerLib: alloc code memory for exception handlers
If PcdDxeNxMemoryProtectionPolicy is set to enable protection for memory
of EfiBootServicesData, EfiConventionalMemory, the BIOS will reset after
timer initialized and started.

The root cause is that the memory used to hold the exception and interrupt
handler is allocated with type of EfiBootServicesData and marked as
non-executable due to NX feature enabled. This patch fixes it by allocating
EfiBootServicesCode type of memory for those handlers instead.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit fceafda518)
2018-01-22 09:19:28 +08:00
da98ddb057 UefiCpuPkg/MpInitLib: split wake up buffer into two parts
If PcdDxeNxMemoryProtectionPolicy is set to enable protection for memory
of EfiBootServicesCode, EfiConventionalMemory, the BIOS will hang at a page
fault exception during MP initialization.

The root cause is that the AP wake up buffer, which is below 1MB and used
to hold both AP init code and data, is type of EfiConventionalMemory (not
really allocated because of potential conflict with legacy code), and is
marked as non-executable. During the transition from real address mode
to long mode, the AP init code has to enable paging which will then cause
itself a page fault exception because it's just running in non-executable
memory.

The solution is splitting AP wake up buffer into two part: lower part is
still below 1MB and shared with legacy system, higher part is really
allocated memory of BootServicesCode type. The init code in the memory
below 1MB will not enable paging but just switch to protected mode and
jump to higher memory, in which the init code will enable paging and
switch to long mode.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit f32bfe6d06)
2018-01-22 09:18:37 +08:00
0f650f4735 UefiCpuPkg/CpuDxe: fix SetMemoryAttributes issue in 32-bit mode
In 32-bit mode, the BIOS will not create page table for memory beyond
4GB and therefore it cannot handle the attributes change request for
those memory. But current CpuDxe doesn't check this situation and still
try to complete the request, which will cause attributes of incorrect
memory address to be changed due to type cast from 64-bit to 32-bit.

This patch fixes this issue by checking the end address of input
memory block and returning EFI_UNSUPPORTED if it's out of range.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.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: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 4f10654e04)
2018-01-22 09:18:05 +08:00
e145a3eb02 BaseTools: Optimizing DscDefaultValue process in BuildReport
DscDefaultValue from Dsc file has been parsed by ValueExpressionEx
when Dsc file parse, so only DscDefaultValue from FDF file need
ValueExpressionEx parse

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>
(cherry picked from commit a676a24656)
2018-01-21 16:32:37 +08:00
1fd5d06c72 BaseTools: Fix GenFds increment build bug that missing cover command option's change
Issue decription:
step 1, build platform X64
step 2, build platform IA32
step 3, build platform X64
step 4, check all ffs files for X64, the content still has IA32 in it

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>
(cherry picked from commit 6735645d9c)
2018-01-21 16:31:38 +08:00
c740cc2aeb IntelFsp2WrapperPkg: Update BaseFspWrapperApiLib to pass XCODE5 build
XCODE5 doesn't support absolute addressing in the assembly code.
This change uses lea instruction to get the address.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit c45f4c5e75)
2018-01-19 13:04:33 +08:00
31deb5f2f6 OvmfPkg: Don't add -mno-mmx -mno-sse option for XCODE5 tool chain
Ovmf appended option -mno-mmx -mno-sse, but these two options were enabled
in Openssl. The compiler option becomes -mmmx ?msse -mno-mmx -mno-sse. It
trig mac clang compiler hang when compile one source file in openssl.
This issue is found when SECURE_BOOT_ENABLE is TRUE. This may be the compiler
issue. To work around it, don't add these two options for XCODE5 tool chain.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 4a64cbda86)
2018-01-19 13:04:22 +08:00
dfe7067a3f UefiCpuPkg: Update PiSmmCpuDxeSmm pass XCODE5 tool chain
https://bugzilla.tianocore.org/show_bug.cgi?id=849

In V2, use "mov rax, strict qword 0" to replace the hard code db.

1. Use lea instruction to get the address instead of mov instruction.
2. Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.
3. On MpFuncs.nasm, use ExchangeInfo to record InitializeFloatingPointUnits.
This way is same to MpInitLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit e21e355e2c)
2018-01-19 13:04:21 +08:00
c0565b7ae7 UefiCpuPkg: Update SmmCpuFeatureLib pass XCODE5 tool chain
https://bugzilla.tianocore.org/show_bug.cgi?id=849

In V2, use "mov rax, strict qword 0" to replace the hard code db.

1. Use lea instruction to get the address instead of mov instruction.
2. Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 1c7a65eba7)
2018-01-19 13:04:20 +08:00
484841f816 UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool chain
https://bugzilla.tianocore.org/show_bug.cgi?id=849

In V2, use mov rax, strict qword 0 to replace the hard code db.

Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 2db0ccc2d7)
2018-01-19 13:04:19 +08:00
38b5e31e0e MdeModulePkg: Update DebugSupportDxe to pass XCODE5 build
XCODE5 doesn't support absolute addressing in the assembly code.
This change uses lea instruction to get the address.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 62382925c9)
2018-01-19 13:04:18 +08:00
7540b23a0e BaseTools: Use nasm as the preferred assembly source files for XCODE5 tool
https://bugzilla.tianocore.org/show_bug.cgi?id=850

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 2583352f24)
2018-01-19 13:04:18 +08:00
280997bcfa BaseTools: Disable -Wno-unused-const-variable in XCODE5 RELEASE target
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit db408fa3c1)
2018-01-19 13:04:17 +08:00
e01d69c659 BaseTools: Disable warning varargs in XCODE5 align to CLANG38
https://bugzilla.tianocore.org/show_bug.cgi?id=741

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 24a105a7d8)
2018-01-19 13:04:16 +08:00
0b1d2b08f2 BaseTools: enhance error handling for option --binary-source
Enhance error handling for option --binary-source to report invalid
option value. --binary-destination use same rule.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit f21547ff64)
2018-01-19 10:55:54 +08:00
42871887be BaseTools: Correct Target Path in CodaTargetList replace Path
Target Path in CodaTargetList is DebugDir path, correct replace
path with DebugDir

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>
(cherry picked from commit c7c5a6c4f7)
2018-01-19 10:54:26 +08:00
53c9a3c746 MdePkg/DMAR: Add the definition for DMA_CTRL_PLATFORM_OPT_IN_FLAG bit
For the support of VTd 2.5, add the BIT definition of
DMA_CTRL_PLATFORM_OPT_IN_FLAG

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: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 8ab0bd2397)
2018-01-19 09:35:20 +08:00
c5db839aa4 CryptoPkg/OpensslLib: ignore uninitialized warning
We also got maybe-uninitialized warning when building OpensslLib.inf
with GCC48 for ARM and AARCH64, so add -Wno-error=maybe-uninitialized
build option just as other platforms.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Cc: Qin Long <qin.long@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Qin Long <qin.long@intel.com>
(cherry picked from commit 1dbd423fbb)
2018-01-18 16:26:14 +08:00
0d0adb6206 CryptoPkg: Adding OpenSSL as one submodule of EDKII repo
A submodule allows to keep another Git repository in a subdirectory
of main repository. The submodule repository has its own history, which
does not interfere with the history of the current repository. This can
be used to have external dependencies such as third party libraries.

After the extra patch for EDKII-OpenSSL build was removed, OpenSSL can
be one typical submodule use case in EDKII project. This patch adds the
openssl git repository into EDKII project as one submodule.

One .gitmodules file will be generated with the submodule info:
    [submodule "CryptoPkg/Library/OpensslLib/openssl"]
            path = CryptoPkg/Library/OpensslLib/openssl
            url = https://github.com/openssl/openssl

The user can use the following command to clone both main EDKII repo and
openssl submodule:
   1) Add the "--recursive" flag to their git clone command:
      $ git clone --recursive https://github.com/tianocore/edk2
or 2) Manually initialize and the submodules after the clone operation:
      $ git clone https://github.com/tianocore/edk2
      $ git submodule update -–init -–recursive

For Pull operations, "git pull" will not update the submodule repository.
So the following combined commands can be used to pull the remote submodule
updates (e.g. Updating to new supported OpenSSL release)
  $ git pull –-recurse-submodules && \
    git submodule update -–recursive --remote

Cc: Ye Ting <ting.ye@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.long@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 0c1ffb9504)
2018-01-18 14:08:57 +08:00
aa722ab271 UefiCpuPkg/MpInitLib: Fix timer interrupt is disabled after SwitchBSP
Commits a2ea6894e6
* UefiCpuPkg/MpInitLib: Fix a bug that AP enters timer INT handler
masked the interrupts in AP.
But it didn't unmask the interrupt in new BSP when Switch BSP
happens.
The patch fixed this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jeff Fan <vanjeff_919@hotmail.com>
Cc: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 9c6961d598)
2018-01-18 13:07:35 +08:00
b82655fe20 IntelSiliconPkg IntelVTdDxe: Fix DMA does not work issue
Fix DMA does not work issue when system memory is not
greater than 4G.

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>
(cherry picked from commit 1d4c17a6ef)
2018-01-18 10:38:18 +08:00
194a398db0 IntelSiliconPkg IntelVTdPmrPei: Get high top by host address width
Get high top by host address width instead of resource HOB.

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>
(cherry picked from commit b2725f57c7)
2018-01-17 18:40:50 +08:00
9bebced571 IntelSiliconPkg IntelVTdDxe: Remove mVtdHostAddressWidthMask
mVtdHostAddressWidthMask is not been used at all,
its definition and related code could be removed.

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>
(cherry picked from commit 9eaa902a52)
2018-01-17 18:40:49 +08:00
ae665c4fa1 IntelSiliconPkg IntelVTdPmrPei: Use HostAddressWidth in DMAR correctly
According to VTd spec, HostAddressWidth + 1 should be used as the real
host address width value.

Host Address Width:
This field indicates the maximum DMA physical
addressability supported by this platform. The
system address map reported by the BIOS
indicates what portions of this addresses are
populated.
The Host Address Width (HAW) of the platform is
computed as (N+1), where N is the value
reported in this field. For example, for a platform
supporting 40 bits of physical addressability, the
value of 100111b is reported in this field.

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>
(cherry picked from commit 9dd8b1908e)
2018-01-17 18:40:48 +08:00
ba5a29b790 IntelSiliconPkg IntelVTdPmrPei: Refine comments about PHMR/PLMR.Limit
According to VTd spec, the real hardware decoded limit should be
PHMR/PLMR.Limit value + alignment value.

"Bits N:0 of the limit register are
decoded by hardware as all 1s."

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>
(cherry picked from commit e8097a74b7)
2018-01-17 10:39:19 +08:00
cd4b3c9004 IntelSiliconPkg IntelVTdDxe: Fix potential NULL pointer dereference
The implementation of MdeModulePkg\Universal\Acpi\AcpiTableDxe reserves
first entry of RSDT/XSDT to FADT, the first entry value is 0 when FADT
is not installed. So the RSDT/XSDT parsing code should check the entry
value first before checking the table signature.

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>
(cherry picked from commit 01bd1c98fa)
2018-01-17 10:28:31 +08:00
6cb913e09b IntelSiliconPkg IntelVTdDxe: Support early SetAttributes()
Support early SetAttributes() before DMAR table is installed.

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>
(cherry picked from commit 0bc94c748b)
2018-01-17 10:27:49 +08:00
feb9b8fe52 IntelSiliconPkg IntelVTdDxe: Use TPL to protect list/engine operation
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>
(cherry picked from commit 3a71670618)
2018-01-17 10:27:48 +08:00
5070c3f408 IntelSiliconPkg IntelVTdDxe: Signal AcpiNotificationFunc() initially
Signal AcpiNotificationFunc() initially for the case that
DMAR table has been installed when creating event.

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>
(cherry picked from commit dcd39e09ff)
2018-01-17 10:27:47 +08:00
b6c446b77e MdeModulePkg/DxeIpIoLib: Fixed the error ASSERT incorrectly used in IpIoAddIp().
* In DxeIpIo, an ASSERT check is incorrectly used in IpIoAddIp(), which result
  debug image hang when this API is called, this patch is to fix this issue.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
(cherry picked from commit 6478baf891)
2018-01-17 08:32:02 +08:00
ce45421cb6 MdeModulePkg/FrameBufferBltLib: Fix copying of unaligned memory
Contributed-under: TianoCore Contribution Agreement 1.1
Reported-by: Christian Ehrhardt <ehrhardt@genua.de>
Signed-off-by: Christian Ehrhardt <ehrhardt@genua.de>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Tested-by: Christian Ehrhardt <ehrhardt@genua.de>
(cherry picked from commit 0e58b55a46)
2018-01-16 15:33:01 +08:00
a6f4c90a05 MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted
The Graphics Output Protocol's mode information specifies the
PixelsPerScanLine property. Most of the time this is identical to
HorizontalResolution. However, due to alignment requirements etc. it
may be slightly larger. I.e. each scan line will have some "pixels"
that are not visible on the screen but consume space in the frame
buffer.

If the graphics output protocol correctly initializes
HorizontalResolution to 1366 and PixelsPerScanLine to 1376. As a
result the graphics output is broken.

If setting HorizontalResolution to 1376 instead, the output is fine
(except for 10 invisible pixels on the right of the screen).

The patch fixes this bug by using PixelsPerScanLine when calculating
the line width.

Contributed-under: TianoCore Contribution Agreement 1.1
Reported-by: Christian Ehrhardt <ehrhardt@genua.de>
Signed-off-by: Christian Ehrhardt <ehrhardt@genua.de>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Christian Ehrhardt <ehrhardt@genua.de>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Tested-by: Christian Ehrhardt <ehrhardt@genua.de>
(cherry picked from commit 5ae0723355)
2018-01-16 15:33:01 +08:00
20e16af964 MdeModulePkg/FrameBufferBltLib: Use UINT32 type for internal data
Unused ColorDepth was removed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Tested-by: Christian Ehrhardt <ehrhardt@genua.de>
(cherry picked from commit 043944c550)
2018-01-16 15:33:00 +08:00
1378dd73eb MdeModulePkg: Did some code enhancement for DxeIpIoLib.
* In DxeIpIo, there are several places use ASSERT() to check input
  parameters without and descriptions or error handling. This patch
  fixed this issue.
* Fixed some incorrect descriptions in code commence.
* Remove unneeded Exit tag in function IpIoOpen and IpIoConfigIp.
* Add EFIAPI tag for function IpIoRefreshNeighbor.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 2b2087478c)
2018-01-16 11:12:14 +08:00
a5f3470200 MdeModulePkg: Freed the received packet buffer if it is not expected.
* When the packet is not normal packet or icmp error packet, the code
  does not recycle it by signal RecycleSignal event, and this will
  result some memory leak. This patch is to fix this issue.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 0a1bd0a35d)
2018-01-16 11:12:09 +08:00
8639f8f74e MdeModulePkg/EhciDxe: call EhcFreeUrb when int-transfer completes
It didn't cause big issues when VT-d was disabled.
But in VT-d enabled platform, lack of EhcFreeUrb call caused
the DMA data was not moved back to user's buffer.
It caused the correct data cannot be got through sync interrupt
transfer.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit c74805f1e7)
2018-01-16 10:58:45 +08:00
5bf7864b8c MdeModulePkg/DebugLib: Print partial when format string is too long
Today's implementation prints nothing when the format string cannot
fit in the report status extended data buffer.
It confuses user.
The patch changes to print partial message by truncating the format
string when it's too long.

The missing enhancement is the extended data buffer only reserves 96
bytes for the var-args. When the format string is not very long but
contains 13 %lx or %p, the var-args buffer is too small. Today's
implementation prints nothing for this case.
This patch doesn't change such behavior.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 137ed15511)
2018-01-16 10:55:33 +08:00
8ceccce6cd UefiCpuPkg: Enhance feature dependency check
Enhance MCA feature dependency check base on SDM pseudocode example 15-1.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song <binx.song@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 57d1afc889)
2018-01-16 09:26:13 +08:00
221ec8fe8f SecurityPkg/PhysicalPresenceLib: Reject illegal PCR bank allocation
According to TCG PP1.3 spec, error PCR bank allocation input should be
rejected by Physical Presence. Firmware has to ensure that at least one
PCR banks is active.

Cc: Long Qin <qin.long@intel.com>
Cc: Yao Jiewen <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
(cherry picked from commit d02a848e32)
2018-01-15 16:50:02 +08:00
a1683b9efd CrptoPkg/BaseCryptLib: Fix type mismatch when calling OpenSSL function
Type definition in UEFI & OpeenSSL is different. Sometime it could cause
write overflow. Should use same data type when accessing the same region

Cc: Long Qin <qin.long@intel.com>
Cc: Chen Chen <chen.a.chen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
(cherry picked from commit 2067d9f8bf)
2018-01-15 16:50:01 +08:00
f910c3b290 CryptoPkg/OpensslLib: Suppress format warning with extra flag.
Under a certain [outdated] GCC482 compiler, the new-added "-Wno-format"
flag will not take effect, and break the x86_64 build.
This is one known issue in some Ubuntu/GCC-4.8.2 environment, which will
overwrite "-Wno-format" with some default setting.  see more information
and discussion from:
  https://gcc.gnu.org/ml/gcc-help/2014-03/msg00003.html
  https://wiki.ubuntu.com/ToolChain/CompilerFlags
This patch adds one extra "-Wno-error=format" for gcc x86_64 builds to
suppress this warning.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Long Qin <qin.long@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 51fd3b8560cde0ece29ac767fa1f6550f3dbe7ac)
2018-01-15 14:31:31 +08:00
c7585c861c BaseTools/DevicePath: Fix potential null pointer dereference
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit e73fbac5d7)
2018-01-15 10:48:32 +08:00
4f50b16caa BaseTools/C/Common: Fix potential null pointer dereference
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 66329d53bd)
2018-01-15 10:48:32 +08:00
32685c2040 BaseTools/DevicePath: Fix potential memory leak
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 46cced287e)
2018-01-15 10:48:32 +08:00
57bcc39da2 BaseTools/C/Common: Fix potential memory leak
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 1f7e7e70d2)
2018-01-15 10:48:32 +08:00
a23808f09d BaseTools/C/Common: Fix code to be more readable
The change doesn't impact the functionality.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 3710ec21d5)
2018-01-15 10:48:32 +08:00
472c2834e9 UefiCpuPkg PiSmmCpuDxeSmm: Remove redundant code to set IDT range to RO
AllocateCodePages() is used to allocate buffer for IDT range,
the code pages will be set to RO in SetMemMapAttributes(),
then the code to set IDT range to RO in PatchGdtIdtMap() is
redundant and could be removed.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.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>
(cherry picked from commit fe90d0d2ad)
2018-01-15 10:42:31 +08:00
4114569b07 UefiCpuPkg PiSmmCpuDxeSmm: Fixed #double fault on #page fault for IA32
When StackGuard is enabled on IA32, the #double fault exception
is reported instead of #page fault.

This issue does not exist on X64, or IA32 without StackGuard.

The fix at e4435f710c was incomplete.

It is because AllocateCodePages() is used to allocate buffer for
GDT and TSS, the code pages will be set to RO in SetMemMapAttributes().
But IA32 Stack Guard need use task switch to switch stack that need
write GDT and TSS, so AllocateCodePages() could not be used.

This patch uses AllocatePages() instead of AllocateCodePages() to
allocate buffer for GDT and TSS if StackGuard is enabled on IA32.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.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>
(cherry picked from commit 6e601a4109)
2018-01-15 10:42:31 +08:00
5f2e08e40a UefiCpuPkg/MpInitLib: fix 32-bit build error
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
2018-01-12 18:19:14 +08:00
7065b59990 UefiCpuPkg/MpInitLib: fix wrong address set as Stack Guard for APs
The reason is that DXE part initialization will reuse the stack allocated
at PEI phase, if MP was initialized before. Some code added to check this
situation and use stack base address saved in HOB passed from PEI.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 523152618d)
2018-01-12 18:19:13 +08:00
afa9d3959d UefiCpuPkg/MpInitLib: fix incorrect stack top init for cpu0
As the name suggests, CpuMpData->CpuInfoInHob[0].ApTopOfStack must be init
to the top of stack. But the MpInitLibInitialize() passed the base address
of stack to InitializeApData(), which is not correct. Although this stack
is not used for BSP, it's should be fixed in case of misunderstanding and
future possible code changes.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit f2655dcf28)
2018-01-12 18:19:12 +08:00
c41d8c62f2 MdeModulePkg/MdeModulePkg.uni: clarify Heap Guard usage
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@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>
(cherry picked from commit 218d55a050)
2018-01-12 18:19:12 +08:00
4dd49c1907 MdeModulePkg/MdeModulePkg.dec: clarify Heap Guard usage
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@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>
(cherry picked from commit b6ad4675b6)
2018-01-12 18:19:11 +08:00
9bdb89e8ba MdeModulePkg/Ip4Dxe: Add an independent timer for reconfig checking
* Since wireless network can switch at very short time, the time interval
  of reconfig event checking is too long for this case. To achieve better
  performance and scalability, separate this task from Ip4 tick timer.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 018432f0ce)
2018-01-12 11:10:51 +08:00
e2cef60f80 MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual().
* The library API use array elements without any index range check, this
patch is to fix this issue to avoid null pointer reference.

V2
* Added an ASSERT check for the case PrefixLength equals to IP6_PREFIX_MAX.
* Synced some code descriptions to head file.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
(cherry picked from commit e0e26f9c1f)
2018-01-12 11:10:45 +08:00
8d129948e9 BaseTools: Add back the cc71d8 version's fix
The version cc71d8's fix was washed out by structure pcd report patch.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 643e8e4bd4)
2018-01-12 09:07:25 +08:00
96facbf773 BaseTools: Not print SKUID info for PCD when it is only Single SKUID
when it is only single SKUID, we don't need to print the SKUID info for
every PCD since in the Global section there already have this info.
For DefaultStore, we use same rule.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 779ddcdf96)
2018-01-12 09:07:24 +08:00
237bc205b8 BaseTools: Fix Sku inherit issue.
The final Pcd value should only be override by its parents.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Feng Bob C <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 09c80b07b4)
2018-01-12 09:07:22 +08:00
fbeacd6c2e BaseTools: Fix Pcd value override issue caused by SKU inherit
Pcd default value in DEC should only be assigned once.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 4cc824283c)
2018-01-12 09:07:20 +08:00
6f5c108a54 BaseTools: Fix an issue in HiiPcd generation
DynamicHiiPcd may be used by PEIM or DXE driver.
All used DynamicHiiPcd value should be collected and placed into
the default setting PCD PcdNvStoreDefaultValueBuffer.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
(cherry picked from commit a3623244b9)
2018-01-12 09:07:19 +08:00
a908ec6d17 BaseTools CommonLib: Fix printf %llx issue on UINT64
UINT64 is defined as the different type for the different ARCHs. To
let it work for all archs and compilers, add (unsigned long long) for
the input value together with %llx.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit beacbc7492)
2018-01-12 09:07:05 +08:00
e4f03dac7d BaseTools: resolve initialization order errors in VfrFormPkg.h
clang generates many warnings
warning: field 'XXX' is uninitialized when used here [-Wuninitialized]
for VfrFormPkg.h.

VfrFormPkg.h defines many classes derived from CIfrObj (along with other
base classes.)
Each of these derived classes defines a non-static member field that serves
as a duplicate pointer to an original pointer defined in the CIfrObj base
class, but cast to a different pointer type.
The derived class constructor passes the duplicate pointer to base class
constructors:
1) Once passes the address of the duplicate pointer to the CIfrObj
   constructor to have it initialized.
2) Then passes the duplicate pointer to one or more subsequent base class
   constructors to be used.
Both 1) and 2) constitute undefined behavior in C++.  C++ prescribes that
base classes are initialized before non-static members when initializing a
derived class.  So when base class constructors are executing, it is not
permitted to assume any non-static members of the derived class exist (even
to the stage of having their storage allocated.)

clang does not issue warnings for 1), but issues warnings -Wuninitialized
for 2).

This coding methodology is resolved as follows:
a) The CIfrObj object accessor method for retrieving the original pointer
   is revised to a template member function that returns the original
   pointer cast to a desired target type.
b) The call to CIfrObj constructor is no longer used to initialize the
   duplicate pointer in the derived class.
c) Any subsequent calls to a base class constructor that need to use the
   pointer, retrieve it from the CIfrObj base class using the template
   accessor method.
d) If the derived class makes no further use of the pointer, then the
   duplicate pointer defined in it is eliminated.
e) If the derived class needs the duplicate pointer for other use, the
   duplicate pointer remains in the derived class and is initialized in
   proper order from the original pointer in CIfrObj.
f) Existing source code that previously used the CIfrObj pointer accessor
   method is revised to use the template method.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zenith432 <zenith432@users.sourceforge.net>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 5397bd425e)
2018-01-12 09:06:56 +08:00
a721de0d00 BaseTools: silence parentheses-equality warning
Some code generated by antlr causes clang to emit warning
warning: equality comparison with extraneous parentheses
  [-Wparentheses-equality]
The warning is suppressed specifically for clang without affecting other
compilers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zenith432 <zenith432@users.sourceforge.net>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 4e97974c1e)
2018-01-12 09:06:55 +08:00
d660c7868a BaseTools: eliminate unused expression result
Remove some code generated by antlr that causes clang to emit warning
warning: expression result unused [-Wunused-value]

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zenith432 <zenith432@users.sourceforge.net>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit a5b84d3480)
2018-01-12 09:06:53 +08:00
26a58bbd36 BaseTools: correct mal-typed CVfrDLGLexer::errstd
The member function CVfrDLGLexer::errstd is intended as an override virtual
function of DLGLexerBase::errstd, but due to mismatched prototype, it
didn't override, and never got called.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zenith432 <zenith432@users.sourceforge.net>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 8b13e18143)
2018-01-12 09:06:51 +08:00
ddec61f2a0 NetworkPkg: Add more parameter or return status check in UDP6 driver
In UDP6Dxe, there are several places that may be enhanced
to check input parameters and returned status. This patch
is to fix these issues.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-11 17:11:37 +08:00
26f4998c74 NetworkPkg: Fix some coding style issues in UDP6 driver
In UDP6Dxe, there are some coding style issues, this patch
is to fix these issues.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-11 17:11:35 +08:00
84a7c3b270 NetworkPkg: Fix a memory leak issue in UDP6 driver
In UDP6Dxe Udp6Groups(), the code return directly without free the
buffer allocated for McastIp when JoinFlag is TRUE. It is a memory
leak issue that needs to be fixed. This patch is to fix this issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-11 17:11:32 +08:00
102117a7d0 NetworkPkg: Add ASSERT error handling for UDP6 driver
In Udp6Dxe, there are several places use ASSERT to check returned
value. But these errors should be handled if they occur, this patch
is to fix this issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-11 17:11:30 +08:00
a337c6e311 MdeModulePkg/Dhcp4Dxe: Free NET_BUF data after sent out to avoid memory leak
* When build a DHCP message in function DhcpSendMessage() or DhcpRetransmit(),
a new NET_BUF is created by the library of NetbufFromExt, but it's not freed
after it is sent out. This patch is to fix this memory leak issue.

V2:
* Since packet has already been referred by DhcpSb->LastPacket, and will be
freed when sending another packet or clean up, there is no need to add an
extra free function in NetbufFromExt.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 479a3b6053)
2018-01-11 08:57:59 +08:00
69fabe97be MdeModulePkg/VarCheckHii: Update data type for variable "ArrayIndex"
In some case the ArrayIndex with UINT16 may be not large enough to
hold the multiplication result of HiiQuestion->VarOffset * 8;
So this patch update the data type to fix this potential issue.

Cc: Star Zeng <star.zeng@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: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 427b2f41a6)
2018-01-10 14:56:14 +08:00
28f0a65a4b NetworkPkg/IScsiDxe: Set ExitBootServiceEvent to NULL after close it.
v2:
* Refine the commit log.

There are two place to close the ISCSI ExitBootServiceEvent:
#1.IScsiOnExitBootService(), which is the callback function of
   ExitBootServiceEvent.
#2.IScsiCleanDriverData(), which will be invoked by ISCSI driver
   binding stop().

So, the ExitBootServiceEvent will be closed and freed when exit boot
server is triggered. But it may be closed and freed again in ISCSI driver
binding stop(), which will result in the issue recorded at
https://bugzilla.tianocore.org/show_bug.cgi?id=742.

This patch is to resolve the issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit a37c60b660)
2018-01-10 08:36:56 +08:00
4c33ac7a72 MdeModulePkg/IScsiDxe: Set ExitBootServiceEvent to NULL after close it.
v2:
* Refine the commit log.

There are two place to close the ISCSI ExitBootServiceEvent:
#1.IScsiOnExitBootService(), which is the callback function of
   ExitBootServiceEvent.
#2.IScsiCleanDriverData(), which will be invoked by ISCSI driver
   binding stop().

So, the ExitBootServiceEvent will be closed and freed when exit boot
server is triggered. But it may be closed and freed again in ISCSI driver
binding stop(), which will result in the issue recorded at
https://bugzilla.tianocore.org/show_bug.cgi?id=742.

This patch is to resolve the issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit d32159853d)
2018-01-10 08:36:49 +08:00
4276a38532 NetworkPkg/HttpDxe: Fix build warning error if CHAR8 is unsigned.
This patch is to fix the compiler warning error: C4245. The issue will happen
if the below build option is enabled:
  *_*_*_CC_FLAGS = -J.

That's because the value of ('A' - 'a') is a negative value, which will
be converted to an unsigned type if CHAR8 is treated as unsigned:
  Src -= ('A' - 'a');

The above issue is also recorded at:
https://bugzilla.tianocore.org/show_bug.cgi?id=815.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 1e4725e569)
2018-01-10 08:36:42 +08:00
e10986608c MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak.
* In function Mtftp4WrqSendBlock(), when packet is not needed, function
  returns EFI_ABORTED but not freed the packet buffer. It results some
  memory leak and this patch is to fix this issue.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
(cherry picked from commit 36c19ee6c7)
2018-01-10 08:36:35 +08:00
7595e9e14c MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start.
* This function sets returned status as token status and signal token
  when error occurs, and it results token status not compliance with
  spec definition. This patch fixed this issue.
* This function restore Tpl twice when Mtftp4WrqStart() returns an
  error, this patch fixed this issue.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
(cherry picked from commit 39b0867d83)
2018-01-10 08:36:28 +08:00
20c436f729 UefiCpuPkg/MpInitLib: Fix a bug that AP enters timer INT handler
When SourceLevelDebug is enabled, AP randomly executes the DXECORE
timer handler logic. The root cause is the interrupts are not
masked in AP wake up procedure.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jeff Fan <vanjeff_919@hotmail.com>
(cherry picked from commit a2ea6894e6)
2018-01-09 13:24:27 +08:00
5ef439ae08 MdePkg/PciExpressLib.h: Add missing include of PciExpress21.h
PCI_ECAM_ADDRESS() macro is defined in PciExpress21.h so
always include PciExpress21.h in the library header file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 5f354f6a4a)
2018-01-09 13:24:26 +08:00
02f4147f02 MdeModulePkg/DxeUdpIoLib: Did some code enhancement for UdpIoLib
* Added some ASSERT descriptions for library APIs.
* Added "Optional" option for Context parameter in UdpIoCancelDgrams().
* Added function return status check for UdpIoFreeIo().

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 6d88babba3)
2018-01-09 09:19:55 +08:00
4a4fe8f63e BaseTools: Fix compile error on VS2010
VS2010 also defined RSIZE_MAX, so we undef it first.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit e4fb8f1d31)
2018-01-04 17:03:52 +08:00
8cc5355693 BaseTools/DevicePath: fix GCC build error in print_mem(), and clean it up
Currently "BaseTools/Source/C/DevicePath/DevicePath.c" fails to build with
GCC48:

> DevicePath.c: In function 'print_mem':
> DevicePath.c:109:5: error: 'for' loop initial declarations are only
> allowed in C99 mode
>      for (size_t i=0; i<n; i++) {
>      ^
> DevicePath.c:109:5: note: use option -std=c99 or -std=gnu99 to compile
> your code

In addition, the print_mem() function does not conform to the edk2 coding
style:

- we use CamelCase and no underscores in identifiers,
- the types and type qualifiers should follow the edk2 style,
- initialization as part of definition is forbidden for local variables.

Clean these up.

While updating the print_mem()/PrintMem() call sites, also remove the
superfluous parentheses around the second argument.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Fixes: 7dbc50bd24
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 9a6b445bc2)
2018-01-04 16:59:48 +08:00
8776b1ba58 MdeModulePkg/DxePrintLibPrint2Protocol: Fix incomplete print output
This is caused by a previous patch which tried to fix string over-read.
It's found that that patch for PrintLib in MdePkg will cause premature
terminating of loop used to traversing format string and cause incomplete
string output. Because this library uses similar code to do the same
job, it has the same issue too. So the fix is also the same.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@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>
(cherry picked from commit b23276135a)
2018-01-04 13:41:09 +08:00
b4498caada MdePkg/BasePrintLib: Fix incomplete print output
This is caused by previous patch which tried to fix string over-read,
which breaks UEFI menu rendering: the following

/------------------------------------------------------------------------------\
|                               Device Manager                                 |
\------------------------------------------------------------------------------/

is rendered as

/\
|                               Device Manager                                 |
\/.0                                                 2.00 GHz

(the spurious digits are SMBIOS data from the home screen)

The problem appears to be that the CHAR16 value of BOXDRAW_HORIZONTAL
equals 0x2500, which means that testing ArgumentString[] != '\0'
(which tests the low byte only) will yield FALSE and terminate the
loop prematurely.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 701e8cc29a)
2018-01-04 13:41:08 +08:00
db269dae16 BaseTools: Fix the regression bug of a74398 for SubFv Image
in version a74398 we use guid value and Fv name as ffs dir for FILE
statement, this patch apply this rule on subFv image.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit ff260aa7ab)
2018-01-04 13:40:25 +08:00
e4a45bb8b2 MdeModulePkg/DxeNetLib: Fix an error in packet length counting.
* In old implementation, the operation len-- assumes AsciiSPrint()
  has counted NULL terminator, and it's not correct. This patch is
  to fix this issue.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 10:56:13 +08:00
667fdaaac8 MdeModulePkg/DxeNetLib: Add parameter check and ASSERT handling.
* Library API should check the input parameters before use, or
  ASSERT to tell it has to meet some requirements. But in DxeNetLib,
  not all functions follows this rule.
* ASSERT shouldn't be used as error handling, add some handling code
  for errors.
* Add some ASSERT commence in function notes.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 10:56:11 +08:00
d22bce7905 MdeModulePkg/DxeNetLib: Fix a potential issue in macro definition.
The NIC_ITEM_CONFIG_SIZE macro in DxeNetLib is defined as:
sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) *
MAX_IP4_CONFIG_IN_VARIABLE. This macro should be surrounded
with parenthesis to avoid being incorrectly used.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 10:56:10 +08:00
49070f3bd3 NetworkPkg: Update PXE driver to check for NULL pointer before use it.
This patch is to fix the issue that dereferencing of "This" (EFI_LOAD_FILE_PROTOCOL)
in EfiPxeLoadFile() is happening before the NULL check.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 09:13:18 +08:00
ffa44f7b87 NetworkPkg: Add assert for buffer pointer from DHCP driver.
The PxeBcDhcp4CallBack() is provided for DHCP driver to invoke packet check
during DHCP process, the DHCP driver should make sure Packet and NewPacket
has meaningful value. This patch adds assert for this.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 09:13:16 +08:00
73001d1c98 NetworkPkg: Fix memory leak problem in PXE driver.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 09:13:14 +08:00
d811a6d681 NetworkPkg: Check allocated buffer pointer before use.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 09:13:12 +08:00
3c9184534e NetworkPkg: Abort the PXE process if DHCP has been started by other instance.
PXE need to use extended DHCP options and check received offers in callback
function, so there is no need to continue the PXE process if DHCP driver has
been started by other instance but not PXE driver itself.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 09:13:10 +08:00
ebcee41c32 MdeModulePkg: Add error handling when IP address is Class E
The Dhcp4.TransmitReceive() API should be able to use at any time according
to UEFI spec. While in classless addressing network, the netmask must be
explicitly provided together with the station address.
But if the DHCP instance haven't be configured with a valid netmask, we need
compute it according to the classful addressing rule. In such case, if the
user configures with class E IP address, ASSERT will happen, we need to handle
this case and return error status code.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
(cherry picked from commit 0ba795d21a)
2018-01-03 13:56:08 +08:00
6f992a1cd4 MdeModulePkg VarCheckPcd: Make sure the bin at required alignment
According to UEFI/PI spec, the AllocateXXXPool() interfaces should
return eight-byte aligned buffer that satisfies the required
HEADER_ALIGNMENT which is 4.

This patch adds ASSERT to make sure the bin at required alignment,
that can help catch the issue earlier about incorrect aligned buffer
returned from AllocateXXXPool().

Cc: Jian J Wang <jian.j.wang@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: Jian J Wang <jian.j.wang@intel.com>
(cherry picked from commit cd16355bbf)
2018-01-02 09:58:17 +08:00
010097b08c MdeModulePkg VarCheckHii: Make sure the bin at required alignment
According to UEFI/PI spec, the AllocateXXXPool() interfaces should
return eight-byte aligned buffer that satisfies the required
HEADER_ALIGNMENT which is 4.

This patch adds ASSERT to make sure the bin at required alignment,
that can help catch the issue earlier about incorrect aligned buffer
returned from AllocateXXXPool().

Cc: Jian J Wang <jian.j.wang@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: Jian J Wang <jian.j.wang@intel.com>
(cherry picked from commit 3d110afbca)
2018-01-02 09:58:16 +08:00
f04d0a9ad7 UefiCpuPkg CpuExceptionHandlerLib: Enhance DumpModuleImageInfo()
Enhance DumpModuleImageInfo() for page fault with I/D set.

If it is page fault with I/D set, the (E/R)IP in SystemContext
could not be used for DumpModuleImageInfo(), instead of, the next
IP of the IP triggering this page fault could be found from stack
by (E/R)SP in SystemContext.

IA32 SDM:
— I/D flag (bit 4).
This flag is 1 if the access causing the page-fault exception was
an instruction fetch. This flag describes the access causing the
page-fault exception, not the access rights specified by paging.

The idea comes from SmiPFHandler () in
UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c and
UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.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>
(cherry picked from commit bb207f6cda)
2018-01-02 09:38:52 +08:00
66ce5b6787 BaseTools: Add DevicePath support for PCD values
Use C code parse device path to output hex string, and Python
run command when PCD Value need device path parse.

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

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-01-02 09:30:08 +08:00
2bd5224c01 MdePkg: Remove the file Udf.h in IndustryStandard
The UDF feature is not ready for production. Remove it from the UDK2018
branch.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
2017-12-29 11:12:38 +08:00
7412c459f8 MdeModulePkg: Remove the UDF/ECMA-167 file system support codes
The UDF feature is not ready for production. Remove it from the UDK2018
branch.

This commit removes the UDF/ECMA-167 file system related code changes
done within:
  MdeModulePkg/Universal/Disk/PartitionDxe/
  MdeModulePkg/Universal/Disk/UdfDxe/
  MdeModulePkg/MdeModulePkg.dsc

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
2017-12-29 11:12:37 +08:00
fc0eeeb5c7 OvmfPkg: Remove the UDF file system support
The UDF feature is not ready for production. Remove it from the UDK2018
branch.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
2017-12-29 11:12:37 +08:00
012f4ed508 Nt32Pkg: Remove the UDF file system support
The UDF feature is not ready for production. Remove it from the UDK2018
branch.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
2017-12-29 11:12:36 +08:00
a9f96b0513 ArmVirtPkg: Remove the UDF file system support
The UDF feature is not ready for production. Remove it from the UDK2018
branch.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
2017-12-29 11:12:35 +08:00
566 changed files with 35404 additions and 27331 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "CryptoPkg/Library/OpensslLib/openssl"]
path = CryptoPkg/Library/OpensslLib/openssl
url = https://github.com/openssl/openssl

View File

@ -307,13 +307,12 @@
OvmfPkg/VirtioRngDxe/VirtioRng.inf
#
# FAT filesystem + GPT/MBR partitioning + UDF filesystem
# FAT filesystem + GPT/MBR partitioning
#
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf
MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
#
# Bds

View File

@ -83,13 +83,12 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
#
# FAT filesystem + GPT/MBR partitioning + UDF filesystem
# FAT filesystem + GPT/MBR partitioning
#
INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
INF FatPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
#
# Platform Driver

View File

@ -296,13 +296,12 @@
OvmfPkg/VirtioRngDxe/VirtioRng.inf
#
# FAT filesystem + GPT/MBR partitioning + UDF filesystem
# FAT filesystem + GPT/MBR partitioning
#
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf
MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
#
# Bds

View File

@ -194,13 +194,12 @@
ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf
#
# FAT filesystem + GPT/MBR partitioning + UDF filesystem
# FAT filesystem + GPT/MBR partitioning
#
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf
MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
#
# Bds

View File

@ -163,7 +163,6 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
INF FatPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
#
# UEFI application (Shell Embedded Boot Loader)

View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
dir=$(dirname "$full_cmd")
cmd=${full_cmd##*/}
if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ]
then
exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd"
elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ]
then
if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ]
then
echo "BaseTools C Tool binary was not found ($cmd)"
echo "You may need to run:"
echo " make -C $EDK_TOOLS_PATH/Source/C"
else
exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@"
fi
elif [ -e "$dir/../../Source/C/bin/$cmd" ]
then
exec "$dir/../../Source/C/bin/$cmd" "$@"
else
echo "Unable to find the real '$cmd' to run"
echo "This message was printed by"
echo " $0"
exit 127
fi

View File

@ -182,7 +182,6 @@
<Command>
[Assembly-Code-File.COMMON.COMMON]
<InputFile.MSFT, InputFile.INTEL, InputFile.RVCT>
?.asm, ?.Asm, ?.ASM
@ -207,6 +206,36 @@
# For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues
"$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii
[Assembly-Code-File.COMMON.ARM]
# Remove --convert-hex for ARM as it breaks MSFT assemblers
<InputFile.MSFT, InputFile.INTEL, InputFile.RVCT>
?.asm, ?.Asm, ?.ASM
<InputFile.GCC, InputFile.GCCLD>
?.S, ?.s
<ExtraDependency>
$(MAKE_FILE)
<OutputFile>
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
<Command.INTEL>
"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
Trim --source-code --convert-hex --trim-long -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
"$(ASM)" /Fo${dst} $(ASM_FLAGS) /I${s_path} $(INC) ${d_path}(+)${s_base}.iii
<Command.MSFT>
"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
Trim --source-code --trim-long -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
"$(ASM)" /Fo${dst} $(ASM_FLAGS) /I${s_path} $(INC) ${d_path}(+)${s_base}.iii
<Command.GCC, Command.GCCLD, Command.RVCT>
"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
Trim --trim-long --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
# For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues
"$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii
[Nasm-Assembly-Code-File.COMMON.COMMON]
<InputFile>
?.nasm
@ -249,8 +278,8 @@
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dtb
<Command.GCC>
"$(PP)" $(DTCPP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
"$(DTC)" -I dts -O dtb -o ${dst} ${d_path}(+)${s_base}.i
"$(DTCPP)" $(DTCPP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
"$(DTC)" $(DTC_FLAGS) -I dts -O dtb -o ${dst} ${d_path}(+)${s_base}.i
[Visual-Form-Representation-File]
<InputFile>

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -59,10 +59,14 @@ TOOL_CHAIN_CONF = Conf/tools_def.txt
# used for the build. The list uses space character separation.
TOOL_CHAIN_TAG = MYTOOLS
# MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent threads. Recommend to set this
# value to one more than the number of your compurter
# cores or CPUs. Less than 2 means disable multithread build.
MAX_CONCURRENT_THREAD_NUMBER = 1
# MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent threads. If not specified or set
# to zero, tool automatically detect number of processor
# threads. Recommend to set this value to one less than the
# number of your computer cores or CPUs. When value set to 1,
# means disable multi-thread build, value set to more than 1,
# means user specify the thread number to build. Not specify
# the default value in this file.
# MAX_CONCURRENT_THREAD_NUMBER = 1
# BUILD_RULE_CONF Filename Optional Specify the file name to use for the build rules that are followed

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
# Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
# Copyright (c) 2015, Hewlett-Packard Development Company, L.P.<BR>
@ -79,6 +79,7 @@ DEFINE VS2017_HOST = x86
DEFINE VS2017_BIN_HOST = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\DEF(VS2017_HOST)
DEFINE VS2017_BIN_IA32 = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\x86
DEFINE VS2017_BIN_X64 = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\x64
DEFINE VS2017_BIN_ARM = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\arm
DEFINE WINSDK_BIN = ENV(WINSDK_PREFIX)
DEFINE WINSDKx86_BIN = ENV(WINSDKx86_PREFIX)
@ -236,6 +237,7 @@ DEFINE IPHONE_TOOLS = /Developer/Platforms/iPhoneOS.platform/Develope
DEFINE SOURCERY_CYGWIN_TOOLS = /cygdrive/c/Program Files/CodeSourcery/Sourcery G++ Lite/bin
DEFINE DTCPP_BIN = ENV(DTCPP_PREFIX)cpp
DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
####################################################################################
@ -335,6 +337,9 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
# Required to build platforms or ACPI tables:
# Intel(r) ACPI Compiler (iasl.exe) from
# https://acpica.org/downloads
# Note:
# Building of XIP firmware images for ARM is not currently supported (only applications).
# /FILEALIGN:4096 and other changes are needed for ARM firmware builds.
# DDK3790 -win32- Requires:
# Microsoft Windows Server 2003 Driver Development Kit (Microsoft WINDDK) version 3790.1830
# Optional:
@ -4169,6 +4174,33 @@ NOOPT_VS2017_X64_NASM_FLAGS = -O0 -f win64 -g
RELEASE_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
NOOPT_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
#################
# ARM definitions
#################
*_VS2017_ARM_CC_PATH = DEF(VS2017_BIN_ARM)\cl.exe
*_VS2017_ARM_VFRPP_PATH = DEF(VS2017_BIN_ARM)\cl.exe
*_VS2017_ARM_SLINK_PATH = DEF(VS2017_BIN_ARM)\lib.exe
*_VS2017_ARM_DLINK_PATH = DEF(VS2017_BIN_ARM)\link.exe
*_VS2017_ARM_APP_PATH = DEF(VS2017_BIN_ARM)\cl.exe
*_VS2017_ARM_PP_PATH = DEF(VS2017_BIN_ARM)\cl.exe
*_VS2017_ARM_ASM_PATH = DEF(VS2017_BIN_ARM)\armasm.exe
*_VS2017_ARM_ASLCC_PATH = DEF(VS2017_BIN_ARM)\cl.exe
*_VS2017_ARM_ASLPP_PATH = DEF(VS2017_BIN_ARM)\cl.exe
*_VS2017_ARM_ASLDLINK_PATH = DEF(VS2017_BIN_ARM)\link.exe
*_VS2017_ARM_MAKE_FLAGS = /nologo
DEBUG_VS2017_ARM_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1b2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm /Gw /Oi-
RELEASE_VS2017_ARM_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1b2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gw /Oi-
NOOPT_VS2017_ARM_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm /Od /Oi-
DEBUG_VS2017_ARM_ASM_FLAGS = /nologo /g
RELEASE_VS2017_ARM_ASM_FLAGS = /nologo
NOOPT_VS2017_ARM_ASM_FLAGS = /nologo
DEBUG_VS2017_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
RELEASE_VS2017_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
NOOPT_VS2017_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
##################
# EBC definitions
##################
@ -4467,6 +4499,9 @@ NOOPT_DDK3790xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF
DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG = --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
RELEASE_*_*_OBJCOPY_ADDDEBUGFLAG =
NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
*_*_*_DTC_FLAGS = -H epapr
*_*_*_DTCPP_PATH = DEF(DTCPP_BIN)
*_*_*_DTC_PATH = DEF(DTC_BIN)
DEFINE GCC_ALL_CC_FLAGS = -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno-common
DEFINE GCC_IA32_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -m32 -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-arg-probe
@ -4880,7 +4915,6 @@ RELEASE_GCC45_X64_CC_FLAGS = DEF(GCC45_X64_CC_FLAGS) -Os
*_GCC46_*_MAKE_PATH = DEF(GCC46_IA32_PREFIX)make
*_GCC46_*_*_DLL = ENV(GCC46_DLL)
*_GCC46_*_ASL_PATH = DEF(UNIX_IASL_BIN)
*_GCC46_*_DTC_PATH = DEF(DTC_BIN)
*_GCC46_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
*_GCC46_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
@ -4991,7 +5025,6 @@ RELEASE_GCC46_ARM_CC_FLAGS = DEF(GCC46_ARM_CC_FLAGS) -Wno-unused-but-set-v
*_GCC47_*_MAKE_PATH = DEF(GCC47_IA32_PREFIX)make
*_GCC47_*_*_DLL = ENV(GCC47_DLL)
*_GCC47_*_ASL_PATH = DEF(UNIX_IASL_BIN)
*_GCC47_*_DTC_PATH = DEF(DTC_BIN)
*_GCC47_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
*_GCC47_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
@ -5131,7 +5164,6 @@ RELEASE_GCC47_AARCH64_CC_FLAGS = DEF(GCC47_AARCH64_CC_FLAGS) -Wno-unused-but-s
*_GCC48_*_MAKE_PATH = DEF(GCC48_IA32_PREFIX)make
*_GCC48_*_*_DLL = ENV(GCC48_DLL)
*_GCC48_*_ASL_PATH = DEF(UNIX_IASL_BIN)
*_GCC48_*_DTC_PATH = DEF(DTC_BIN)
*_GCC48_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
*_GCC48_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
@ -5271,7 +5303,6 @@ RELEASE_GCC48_AARCH64_CC_FLAGS = DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
*_GCC49_*_MAKE_PATH = DEF(GCC49_IA32_PREFIX)make
*_GCC49_*_*_DLL = ENV(GCC49_DLL)
*_GCC49_*_ASL_PATH = DEF(UNIX_IASL_BIN)
*_GCC49_*_DTC_PATH = DEF(DTC_BIN)
*_GCC49_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
*_GCC49_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
@ -5417,7 +5448,6 @@ RELEASE_GCC49_AARCH64_DLINK_FLAGS = DEF(GCC49_AARCH64_DLINK_FLAGS)
*_GCC5_*_MAKE_PATH = DEF(GCC5_IA32_PREFIX)make
*_GCC5_*_*_DLL = ENV(GCC5_DLL)
*_GCC5_*_ASL_PATH = DEF(UNIX_IASL_BIN)
*_GCC5_*_DTC_PATH = DEF(DTC_BIN)
*_GCC5_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
*_GCC5_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
@ -5574,7 +5604,6 @@ RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(W
*_CLANG35_*_MAKE_PATH = make
*_CLANG35_*_*_DLL = ENV(CLANG35_DLL)
*_CLANG35_*_ASL_PATH = DEF(UNIX_IASL_BIN)
*_CLANG35_*_DTC_PATH = DEF(DTC_BIN)
*_CLANG35_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
*_CLANG35_*_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
@ -5595,7 +5624,7 @@ RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(W
DEFINE CLANG35_ARM_TARGET = -target arm-linux-gnueabihf
DEFINE CLANG35_AARCH64_TARGET = -target aarch64-linux-gnu
DEFINE CLANG35_WARNING_OVERRIDES = -Wno-parentheses-equality -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Wno-empty-body
DEFINE CLANG35_WARNING_OVERRIDES = -Wno-parentheses-equality -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Wno-empty-body -Wno-unknown-warning-option
DEFINE CLANG35_ARM_CC_FLAGS = DEF(GCC_ARM_CC_FLAGS) DEF(CLANG35_ARM_TARGET) DEF(CLANG35_WARNING_OVERRIDES)
DEFINE CLANG35_AARCH64_CC_FLAGS = DEF(GCC_AARCH64_CC_FLAGS) DEF(CLANG35_AARCH64_TARGET) -mcmodel=small DEF(CLANG35_WARNING_OVERRIDES)
@ -5652,7 +5681,6 @@ RELEASE_CLANG35_AARCH64_CC_FLAGS = DEF(CLANG35_AARCH64_CC_FLAGS) $(ARCHCC_FLAGS)
*_CLANG38_*_MAKE_PATH = make
*_CLANG38_*_*_DLL = ENV(CLANG38_DLL)
*_CLANG38_*_ASL_PATH = DEF(UNIX_IASL_BIN)
*_CLANG38_*_DTC_PATH = DEF(DTC_BIN)
*_CLANG38_*_APP_FLAGS =
*_CLANG38_*_ASL_FLAGS = DEF(IASL_FLAGS)
@ -5664,8 +5692,8 @@ DEFINE CLANG38_X64_PREFIX = ENV(CLANG38_BIN)
DEFINE CLANG38_IA32_TARGET = -target i686-pc-linux-gnu
DEFINE CLANG38_X64_TARGET = -target x86_64-pc-linux-gnu
DEFINE CLANG38_WARNING_OVERRIDES = -Wno-parentheses-equality -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Wno-empty-body -Wno-unused-const-variable -Wno-varargs
DEFINE CLANG38_ALL_CC_FLAGS = DEF(GCC44_ALL_CC_FLAGS) DEF(CLANG38_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -msoft-float -mno-implicit-float -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference -Wno-unknown-warning-option
DEFINE CLANG38_WARNING_OVERRIDES = -Wno-parentheses-equality -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Wno-empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option
DEFINE CLANG38_ALL_CC_FLAGS = DEF(GCC44_ALL_CC_FLAGS) DEF(CLANG38_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -msoft-float -mno-implicit-float -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference
###########################
# CLANG38 IA32 definitions
@ -7500,7 +7528,6 @@ NOOPT_MYTOOLS_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT
*_XCODE5_*_*_FAMILY = GCC
*_XCODE5_*_*_BUILDRULEFAMILY = XCODE
*_XCODE5_*_*_BUILDRULEORDER = S s nasm
#
# use xcode-select to change Xcode version of command line tools
@ -7550,9 +7577,9 @@ RELEASE_XCODE5_IA32_ASM_FLAGS = -arch i386
*_XCODE5_IA32_NASM_FLAGS = -f macho32
DEBUG_XCODE5_IA32_CC_FLAGS = -arch i386 -c -g -Os -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang $(PLATFORM_FLAGS)
RELEASE_XCODE5_IA32_CC_FLAGS = -arch i386 -c -Os -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang $(PLATFORM_FLAGS)
NOOPT_XCODE5_IA32_CC_FLAGS = -arch i386 -c -g -O0 -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang $(PLATFORM_FLAGS)
DEBUG_XCODE5_IA32_CC_FLAGS = -arch i386 -c -g -Os -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang $(PLATFORM_FLAGS)
RELEASE_XCODE5_IA32_CC_FLAGS = -arch i386 -c -Os -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -Wno-unused-const-variable -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang $(PLATFORM_FLAGS)
NOOPT_XCODE5_IA32_CC_FLAGS = -arch i386 -c -g -O0 -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang $(PLATFORM_FLAGS)
##################
# X64 definitions
@ -7569,9 +7596,9 @@ RELEASE_XCODE5_X64_ASM_FLAGS = -arch x86_64
*_XCODE5_*_PP_FLAGS = -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
*_XCODE5_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE -include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
DEBUG_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
NOOPT_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -O0 -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
RELEASE_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
DEBUG_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
NOOPT_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -O0 -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
RELEASE_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -Wno-unused-const-variable -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
####################################################################################
#

View File

@ -0,0 +1,19 @@
Prerequisite Tools:
1. Install Python 2.7.3 from https://www.python.org/download/releases/2.7.3/
2. Install wxPython 2.8.12.1 from https://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/
generally the libraries will be installed at python's subfolder, for example in windows: c:\python27\Lib\site-packages\
3. Install DoxyGen 1.8.6 from https://sourceforge.net/projects/doxygen/files/rel-1.8.6/
4. (Windows only) Install Htmlhelp tool from https://msdn.microsoft.com/en-us/library/windows/desktop/ms669985(v=vs.85).aspx
Limitation:
1. Current tool doesn't work on latest wxPython and DoxyGen tool. Please use the sepecific version in above.
Run the Tool:
a) Run with GUI:
1. Enter src folder, double click "packagedocapp.pyw" or run command "python packagedocapp.pyw" to open the GUI.
2. Make sure all the information in blank are correct.
3. Click "Generate Package Document!"
b) Run with command line:
1. Open command line window
2. Enter src folder, for example: "cd C:\PackageDocumentTools\src"
3. Run "python packagedoc_cli.py --help" for detail command.

View File

@ -0,0 +1,12 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#

View File

@ -0,0 +1,429 @@
## @file
# This module provide command line entry for generating package document!
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#
import os, sys, logging, traceback, subprocess
from optparse import OptionParser
import plugins.EdkPlugins.edk2.model.baseobject as baseobject
import plugins.EdkPlugins.edk2.model.doxygengen as doxygengen
gArchMarcoDict = {'ALL' : 'MDE_CPU_IA32 MDE_CPU_X64 MDE_CPU_EBC MDE_CPU_IPF _MSC_EXTENSIONS __GNUC__ __INTEL_COMPILER',
'IA32_MSFT': 'MDE_CPU_IA32 _MSC_EXTENSIONS',
'IA32_GNU' : 'MDE_CPU_IA32 __GNUC__',
'X64_MSFT' : 'MDE_CPU_X64 _MSC_EXTENSIONS ASM_PFX= OPTIONAL= ',
'X64_GNU' : 'MDE_CPU_X64 __GNUC__ ASM_PFX= OPTIONAL= ',
'IPF_MSFT' : 'MDE_CPU_IPF _MSC_EXTENSIONS ASM_PFX= OPTIONAL= ',
'IPF_GNU' : 'MDE_CPU_IPF __GNUC__ ASM_PFX= OPTIONAL= ',
'EBC_INTEL': 'MDE_CPU_EBC __INTEL_COMPILER ASM_PFX= OPTIONAL= '}
def parseCmdArgs():
parser = OptionParser(version="Package Document Generation Tools - Version 0.1")
parser.add_option('-w', '--workspace', action='store', type='string', dest='WorkspacePath',
help='Specify workspace absolute path. For example: c:\\tianocore')
parser.add_option('-p', '--decfile', action='store', dest='PackagePath',
help='Specify the absolute path for package DEC file. For example: c:\\tianocore\\MdePkg\\MdePkg.dec')
parser.add_option('-x', '--doxygen', action='store', dest='DoxygenPath',
help='Specify the absolute path of doxygen tools installation. For example: C:\\Program Files\\doxygen\bin\doxygen.exe')
parser.add_option('-o', '--output', action='store', dest='OutputPath',
help='Specify the document output path. For example: c:\\docoutput')
parser.add_option('-a', '--arch', action='store', dest='Arch', choices=gArchMarcoDict.keys(),
help='Specify the architecture used in preprocess package\'s source. For example: -a IA32_MSFT')
parser.add_option('-m', '--mode', action='store', dest='DocumentMode', choices=['CHM', 'HTML'],
help='Specify the document mode from : CHM or HTML')
parser.add_option('-i', '--includeonly', action='store_true', dest='IncludeOnly',
help='Only generate document for package\'s public interfaces produced by include folder. ')
parser.add_option('-c', '--htmlworkshop', dest='HtmlWorkshopPath',
help='Specify the absolute path for Microsoft HTML Workshop\'s hhc.exe file. For example: C:\\Program Files\\HTML Help Workshop\\hhc.exe')
(options, args) = parser.parse_args()
# validate the options
errors = []
if options.WorkspacePath == None:
errors.append('- Please specify workspace path via option -w!')
elif not os.path.exists(options.WorkspacePath):
errors.append("- Invalid workspace path %s! The workspace path should be exist in absolute path!" % options.WorkspacePath)
if options.PackagePath == None:
errors.append('- Please specify package DEC file path via option -p!')
elif not os.path.exists(options.PackagePath):
errors.append("- Invalid package's DEC file path %s! The DEC path should be exist in absolute path!" % options.PackagePath)
default = "C:\\Program Files\\doxygen\\bin\\doxygen.exe"
if options.DoxygenPath == None:
if os.path.exists(default):
print "Warning: Assume doxygen tool is installed at %s. If not, please specify via -x" % default
options.DoxygenPath = default
else:
errors.append('- Please specify the path of doxygen tool installation via option -x! or install it in default path %s' % default)
elif not os.path.exists(options.DoxygenPath):
errors.append("- Invalid doxygen tool path %s! The doxygen tool path should be exist in absolute path!" % options.DoxygenPath)
if options.OutputPath != None:
if not os.path.exists(options.OutputPath):
# create output
try:
os.makedirs(options.OutputPath)
except:
errors.append('- Fail to create the output directory %s' % options.OutputPath)
else:
if options.PackagePath != None and os.path.exists(options.PackagePath):
dirpath = os.path.dirname(options.PackagePath)
default = os.path.join (dirpath, "Document")
print 'Warning: Assume document output at %s. If not, please specify via option -o' % default
options.OutputPath = default
if not os.path.exists(default):
try:
os.makedirs(default)
except:
errors.append('- Fail to create default output directory %s! Please specify document output diretory via option -o' % default)
else:
errors.append('- Please specify document output path via option -o!')
if options.Arch == None:
options.Arch = 'ALL'
print "Warning: Assume arch is \"ALL\". If not, specify via -a"
if options.DocumentMode == None:
options.DocumentMode = "HTML"
print "Warning: Assume document mode is \"HTML\". If not, specify via -m"
if options.IncludeOnly == None:
options.IncludeOnly = False
print "Warning: Assume generate package document for all package\'s source including publich interfaces and implementation libraries and modules."
if options.DocumentMode.lower() == 'chm':
default = "C:\\Program Files\\HTML Help Workshop\\hhc.exe"
if options.HtmlWorkshopPath == None:
if os.path.exists(default):
print 'Warning: Assume the installation path of Microsoft HTML Workshop is %s. If not, specify via option -c.' % default
options.HtmlWorkshopPath = default
else:
errors.append('- Please specify the installation path of Microsoft HTML Workshop via option -c!')
elif not os.path.exists(options.HtmlWorkshopPath):
errors.append('- The installation path of Microsoft HTML Workshop %s does not exists. ' % options.HtmlWorkshopPath)
if len(errors) != 0:
print '\n'
parser.error('Fail to start due to following reasons: \n%s' %'\n'.join(errors))
return (options.WorkspacePath, options.PackagePath, options.DoxygenPath, options.OutputPath,
options.Arch, options.DocumentMode, options.IncludeOnly, options.HtmlWorkshopPath)
def createPackageObject(wsPath, pkgPath):
try:
pkgObj = baseobject.Package(None, wsPath)
pkgObj.Load(pkgPath)
except:
logging.getLogger().error ('Fail to create package object!')
return None
return pkgObj
def callbackLogMessage(msg, level):
print msg.strip()
def callbackCreateDoxygenProcess(doxPath, configPath):
if sys.platform == 'win32':
cmd = '"%s" %s' % (doxPath, configPath)
else:
cmd = '%s %s' % (doxPath, configPath)
print cmd
subprocess.call(cmd, shell=True)
def DocumentFixup(outPath, arch):
# find BASE_LIBRARY_JUMP_BUFFER structure reference page
print '\n >>> Start fixup document \n'
for root, dirs, files in os.walk(outPath):
for dir in dirs:
if dir.lower() in ['.svn', '_svn', 'cvs']:
dirs.remove(dir)
for file in files:
if not file.lower().endswith('.html'): continue
fullpath = os.path.join(outPath, root, file)
try:
f = open(fullpath, 'r')
text = f.read()
f.close()
except:
logging.getLogger().error('\nFail to open file %s\n' % fullpath)
continue
if arch.lower() == 'all':
if text.find('BASE_LIBRARY_JUMP_BUFFER Struct Reference') != -1:
FixPageBASE_LIBRARY_JUMP_BUFFER(fullpath, text)
if text.find('MdePkg/Include/Library/BaseLib.h File Reference') != -1:
FixPageBaseLib(fullpath, text)
if text.find('IA32_IDT_GATE_DESCRIPTOR Union Reference') != -1:
FixPageIA32_IDT_GATE_DESCRIPTOR(fullpath, text)
if text.find('MdePkg/Include/Library/UefiDriverEntryPoint.h File Reference') != -1:
FixPageUefiDriverEntryPoint(fullpath, text)
if text.find('MdePkg/Include/Library/UefiApplicationEntryPoint.h File Reference') != -1:
FixPageUefiApplicationEntryPoint(fullpath, text)
print ' >>> Finish all document fixing up! \n'
def FixPageBaseLib(path, text):
print ' >>> Fixup BaseLib file page at file %s \n' % path
lines = text.split('\n')
lastBaseJumpIndex = -1
lastIdtGateDescriptor = -1
for index in range(len(lines) - 1, -1, -1):
line = lines[index]
if line.strip() == '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT&nbsp;&nbsp;&nbsp;4 </td>':
lines[index] = '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT&nbsp;&nbsp;&nbsp;4&nbsp;[IA32] </td>'
if line.strip() == '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT&nbsp;&nbsp;&nbsp;0x10 </td>':
lines[index] = '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT&nbsp;&nbsp;&nbsp;0x10&nbsp;[IPF] </td>'
if line.strip() == '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT&nbsp;&nbsp;&nbsp;8 </td>':
lines[index] = '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT&nbsp;&nbsp;&nbsp;9&nbsp;[EBC, x64] </td>'
if line.find('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a>&nbsp;&nbsp;&nbsp;4') != -1:
lines[index] = lines[index].replace('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a>&nbsp;&nbsp;&nbsp;4',
'BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a>&nbsp;&nbsp;&nbsp;4&nbsp;[IA32]')
if line.find('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a>&nbsp;&nbsp;&nbsp;0x10') != -1:
lines[index] = lines[index].replace('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a>&nbsp;&nbsp;&nbsp;0x10',
'BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a>&nbsp;&nbsp;&nbsp;0x10&nbsp;[IPF]')
if line.find('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a>&nbsp;&nbsp;&nbsp;8') != -1:
lines[index] = lines[index].replace('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a>&nbsp;&nbsp;&nbsp;8',
'BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a>&nbsp;&nbsp;&nbsp;8&nbsp;[x64, EBC]')
if line.find('>BASE_LIBRARY_JUMP_BUFFER</a>') != -1:
if lastBaseJumpIndex != -1:
del lines[lastBaseJumpIndex]
lastBaseJumpIndex = index
if line.find('>IA32_IDT_GATE_DESCRIPTOR</a></td>') != -1:
if lastIdtGateDescriptor != -1:
del lines[lastIdtGateDescriptor]
lastIdtGateDescriptor = index
try:
f = open(path, 'w')
f.write('\n'.join(lines))
f.close()
except:
logging.getLogger().error(" <<< Fail to fixup file %s\n" % path)
return
print " <<< Finish to fixup file %s\n" % path
def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text):
print ' >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at file %s \n' % path
lines = text.split('\n')
for index in range(len(lines) - 1, -1, -1):
line = lines[index].strip()
if line.find('struct {</td>') != -1 and lines[index - 2].find('>Uint64</a></td>') != -1:
lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For X64</h2></td></tr>')
if line.find('struct {</td>') != -1 and lines[index - 1].find('Data Fields') != -1:
lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For IA32</h2></td></tr>')
try:
f = open(path, 'w')
f.write('\n'.join(lines))
f.close()
except:
logging.getLogger().error(" <<< Fail to fixup file %s\n" % path)
return
print " <<< Finish to fixup file %s\n" % path
def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text):
print ' >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at file %s \n' % path
lines = text.split('\n')
bInDetail = True
bNeedRemove = False
for index in range(len(lines) - 1, -1, -1):
line = lines[index]
if line.find('Detailed Description') != -1:
bInDetail = False
if line.startswith('EBC context buffer used by') and lines[index - 1].startswith('x64 context buffer'):
lines[index] = "IA32/IPF/X64/" + line
bNeedRemove = True
if line.startswith("x64 context buffer") or line.startswith('IPF context buffer used by') or \
line.startswith('IA32 context buffer used by'):
if bNeedRemove:
lines.remove(line)
if line.find('>R0</a>') != -1 and not bInDetail:
if lines[index - 1] != '<tr><td colspan="2"><br><h2>Data Fields For EBC</h2></td></tr>':
lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For EBC</h2></td></tr>')
if line.find('>Rbx</a>') != -1 and not bInDetail:
if lines[index - 1] != '<tr><td colspan="2"><br><h2>Data Fields For X64</h2></td></tr>':
lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For X64</h2></td></tr>')
if line.find('>F2</a>') != -1 and not bInDetail:
if lines[index - 1] != '<tr><td colspan="2"><br><h2>Data Fields For IPF</h2></td></tr>':
lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For IPF</h2></td></tr>')
if line.find('>Ebx</a>') != -1 and not bInDetail:
if lines[index - 1] != '<tr><td colspan="2"><br><h2>Data Fields For IA32</h2></td></tr>':
lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For IA32</h2></td></tr>')
try:
f = open(path, 'w')
f.write('\n'.join(lines))
f.close()
except:
logging.getLogger().error(" <<< Fail to fixup file %s" % path)
return
print " <<< Finish to fixup file %s\n" % path
def FixPageUefiDriverEntryPoint(path, text):
print ' >>> Fixup file reference MdePkg/Include/Library/UefiDriverEntryPoint.h at file %s \n' % path
lines = text.split('\n')
bInModuleEntry = False
bInEfiMain = False
ModuleEntryDlCount = 0
ModuleEntryDelStart = 0
ModuleEntryDelEnd = 0
EfiMainDlCount = 0
EfiMainDelStart = 0
EfiMainDelEnd = 0
for index in range(len(lines)):
line = lines[index].strip()
if line.find('EFI_STATUS</a> EFIAPI _ModuleEntryPoint </td>') != -1:
bInModuleEntry = True
if line.find('EFI_STATUS</a> EFIAPI EfiMain </td>') != -1:
bInEfiMain = True
if line.startswith('<p>References <a'):
if bInModuleEntry:
ModuleEntryDelEnd = index - 1
bInModuleEntry = False
elif bInEfiMain:
EfiMainDelEnd = index - 1
bInEfiMain = False
if bInModuleEntry:
if line.startswith('</dl>'):
ModuleEntryDlCount = ModuleEntryDlCount + 1
if ModuleEntryDlCount == 1:
ModuleEntryDelStart = index + 1
if bInEfiMain:
if line.startswith('</dl>'):
EfiMainDlCount = EfiMainDlCount + 1
if EfiMainDlCount == 1:
EfiMainDelStart = index + 1
if EfiMainDelEnd > EfiMainDelStart:
for index in range(EfiMainDelEnd, EfiMainDelStart, -1):
del lines[index]
if ModuleEntryDelEnd > ModuleEntryDelStart:
for index in range(ModuleEntryDelEnd, ModuleEntryDelStart, -1):
del lines[index]
try:
f = open(path, 'w')
f.write('\n'.join(lines))
f.close()
except:
logging.getLogger().error(" <<< Fail to fixup file %s" % path)
return
print " <<< Finish to fixup file %s\n" % path
def FixPageUefiApplicationEntryPoint(path, text):
print ' >>> Fixup file reference MdePkg/Include/Library/UefiApplicationEntryPoint.h at file %s \n' % path
lines = text.split('\n')
bInModuleEntry = False
bInEfiMain = False
ModuleEntryDlCount = 0
ModuleEntryDelStart = 0
ModuleEntryDelEnd = 0
EfiMainDlCount = 0
EfiMainDelStart = 0
EfiMainDelEnd = 0
for index in range(len(lines)):
line = lines[index].strip()
if line.find('EFI_STATUS</a> EFIAPI _ModuleEntryPoint </td>') != -1:
bInModuleEntry = True
if line.find('EFI_STATUS</a> EFIAPI EfiMain </td>') != -1:
bInEfiMain = True
if line.startswith('<p>References <a'):
if bInModuleEntry:
ModuleEntryDelEnd = index - 1
bInModuleEntry = False
elif bInEfiMain:
EfiMainDelEnd = index - 1
bInEfiMain = False
if bInModuleEntry:
if line.startswith('</dl>'):
ModuleEntryDlCount = ModuleEntryDlCount + 1
if ModuleEntryDlCount == 1:
ModuleEntryDelStart = index + 1
if bInEfiMain:
if line.startswith('</dl>'):
EfiMainDlCount = EfiMainDlCount + 1
if EfiMainDlCount == 1:
EfiMainDelStart = index + 1
if EfiMainDelEnd > EfiMainDelStart:
for index in range(EfiMainDelEnd, EfiMainDelStart, -1):
del lines[index]
if ModuleEntryDelEnd > ModuleEntryDelStart:
for index in range(ModuleEntryDelEnd, ModuleEntryDelStart, -1):
del lines[index]
try:
f = open(path, 'w')
f.write('\n'.join(lines))
f.close()
except:
logging.getLogger().error(" <<< Fail to fixup file %s" % path)
return
print " <<< Finish to fixup file %s\n" % path
if __name__ == '__main__':
wspath, pkgpath, doxpath, outpath, archtag, docmode, isinc, hwpath = parseCmdArgs()
# configure logging system
logfilepath = os.path.join(outpath, 'log.txt')
logging.basicConfig(format='%(levelname)-8s %(message)s', level=logging.DEBUG)
# create package model object firstly
pkgObj = createPackageObject(wspath, pkgpath)
if pkgObj == None:
sys.exit(-1)
# create doxygen action model
arch = None
tooltag = None
if archtag.lower() != 'all':
arch = archtag.split('_')[0]
tooltag = archtag.split('_')[1]
else:
arch = 'all'
tooltag = 'all'
# preprocess package and call doxygen
try:
action = doxygengen.PackageDocumentAction(doxpath,
hwpath,
outpath,
pkgObj,
docmode,
callbackLogMessage,
arch,
tooltag,
isinc,
True)
action.RegisterCallbackDoxygenProcess(callbackCreateDoxygenProcess)
action.Generate()
except:
message = traceback.format_exception(*sys.exc_info())
logging.getLogger().error('Fail to create doxygen action! \n%s' % ''.join(message))
sys.exit(-1)
DocumentFixup(outpath, arch)
# generate CHM is necessary
if docmode.lower() == 'chm':
indexpath = os.path.join(outpath, 'html', 'index.hhp')
if sys.platform == 'win32':
cmd = '"%s" %s' % (hwpath, indexpath)
else:
cmd = '%s %s' % (hwpath, indexpath)
subprocess.call(cmd)
print '\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.chm')
else:
print '\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.html')

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#

View File

@ -0,0 +1,12 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#

View File

@ -0,0 +1,449 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#
import os
from message import *
class BaseDoxygeItem:
def __init__(self, name, tag=''):
self.mName = name
self.mTag = tag
self.mDescription = ''
self.mText = []
def AddDescription(self, desc):
self.mDescription = '%s%s' % (self.mDescription, desc)
def __str__(self):
return '\n'.join(self.mText)
def Generate(self):
"""This interface need to be override"""
class Section(BaseDoxygeItem):
def Generate(self):
"""This interface need to be override"""
if len(self.mTag) != 0:
self.mText.append(' \section %s %s' % (self.mName, self.mTag))
else:
self.mText.append(' \section %s' % self.mName)
self.mText.append(self.mDescription)
return self.mText
class Page(BaseDoxygeItem):
def __init__(self, name, tag=None, isSort=True):
BaseDoxygeItem.__init__(self, name, tag)
self.mSubPages = []
self.mIsMainPage = False
self.mSections = []
self.mIsSort = isSort
def GetSubpageCount(self):
return len(self.mSubPages)
def AddPage(self, subpage):
self.mSubPages.append(subpage)
return subpage
def AddPages(self, pageArray):
if pageArray == None:
return
for page in pageArray:
self.AddPage(page)
def AddSection(self, section):
self.mSections.append(section)
self.mSections.sort(cmp=lambda x,y: cmp(x.mName.lower(), y.mName.lower()))
def Generate(self):
if self.mIsMainPage:
self.mText.append('/** \mainpage %s' % self.mName)
self.mIsSort = False
else:
self.mText.append('/** \page %s %s' % (self.mTag, self.mName))
if len(self.mDescription) != 0:
self.mText.append(self.mDescription)
endIndex = len(self.mText)
self.mSections.sort()
for sect in self.mSections:
self.mText += sect.Generate()
endIndex = len(self.mText)
if len(self.mSubPages) != 0:
self.mText.insert(endIndex, "<p> \section content_index INDEX")
endIndex = len(self.mText)
self.mText.insert(endIndex, '<ul>')
endIndex += 1
if self.mIsSort:
self.mSubPages.sort(cmp=lambda x,y: cmp(x.mName.lower(), y.mName.lower()))
for page in self.mSubPages:
self.mText.insert(endIndex, '<li>\subpage %s \"%s\" </li>' % (page.mTag, page.mName))
endIndex += 1
self.mText += page.Generate()
self.mText.insert(endIndex, '</ul>')
endIndex += 1
self.mText.insert(endIndex, ' **/')
return self.mText
class DoxygenFile(Page):
def __init__(self, name, file):
Page.__init__(self, name)
self.mFilename = file
self.mIsMainPage = True
def GetFilename(self):
return self.mFilename.replace('/', '\\')
def Save(self):
str = self.Generate()
try:
f = open(self.mFilename, 'w')
f.write('\n'.join(str))
f.close()
except IOError, e:
ErrorMsg ('Fail to write file %s' % self.mFilename)
return False
return True
doxygenConfigTemplate = """
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = %(ProjectName)s
PROJECT_NUMBER = %(ProjectVersion)s
OUTPUT_DIRECTORY = %(OutputDir)s
CREATE_SUBDIRS = YES
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class " \\
"The $name widget " \\
"The $name file " \\
is \\
provides \\
specifies \\
contains \\
represents \\
a \\
an \\
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = %(StripPath)s
STRIP_FROM_INC_PATH =
SHORT_NAMES = YES
JAVADOC_AUTOBRIEF = NO
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = YES
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 1
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = YES
SUBGROUPING = YES
TYPEDEF_HIDES_STRUCT = NO
EXTRACT_ALL = YES
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
EXTRACT_LOCAL_METHODS = NO
EXTRACT_ANON_NSPACES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = NO
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = YES
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = NO
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = YES
WARN_FORMAT = "$file:$line: $text "
WARN_LOGFILE = %(WarningFile)s
INPUT = %(FileList)s
INPUT_ENCODING = UTF-8
FILE_PATTERNS = %(Pattern)s
RECURSIVE = NO
EXCLUDE = *.svn
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = .svn
EXCLUDE_SYMBOLS =
EXAMPLE_PATH = %(ExamplePath)s
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = NO
USE_HTAGS = NO
VERBATIM_HEADERS = NO
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = %(WhetherGenerateHtmlHelp)s
HTML_DYNAMIC_SECTIONS = NO
CHM_FILE = index.chm
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = %(WhetherGenerateTreeView)s
TREEVIEW_WIDTH = 250
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
GENERATE_AUTOGEN_DEF = NO
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
SEARCH_INCLUDES = YES
INCLUDE_PATH = %(IncludePath)s
INCLUDE_FILE_PATTERNS = *.h
PREDEFINED = %(PreDefined)s
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = NO
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
CLASS_DIAGRAMS = NO
MSCGEN_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = YES
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
SEARCHENGINE = NO
"""
class DoxygenConfigFile:
def __init__(self):
self.mProjectName = ''
self.mOutputDir = ''
self.mFileList = []
self.mIncludeList = []
self.mStripPath = ''
self.mExamplePath = ''
self.mPattern = ['*.c', '*.h',
'*.asm', '*.s', '.nasm', '*.html', '*.dox']
self.mMode = 'HTML'
self.mWarningFile = ''
self.mPreDefined = []
self.mProjectVersion = 0.1
def SetChmMode(self):
self.mMode = 'CHM'
def SetHtmlMode(self):
self.mMode = 'HTML'
def SetProjectName(self, str):
self.mProjectName = str
def SetProjectVersion(self, str):
self.mProjectVersion = str
def SetOutputDir(self, str):
self.mOutputDir = str
def SetStripPath(self, str):
self.mStripPath = str
def SetExamplePath(self, str):
self.mExamplePath = str
def SetWarningFilePath(self, str):
self.mWarningFile = str.replace('\\', '/')
def FileExists(self, path):
if path == None:
return False
if len(path) == 0:
return False
for p in self.mFileList:
if path.lower() == p.lower():
return True
return False
def AddFile(self, path):
if path == None:
return
if len(path) == 0:
return
path = path.replace('\\', '/')
if not self.FileExists(path):
self.mFileList.append(path)
def AddIncludePath(self, path):
path = path.replace('\\', '/')
if path not in self.mIncludeList:
self.mIncludeList.append(path)
def AddPattern(self, pattern):
self.mPattern.append(pattern)
def AddPreDefined(self, macro):
self.mPreDefined.append(macro)
def Generate(self, path):
files = ' \\\n'.join(self.mFileList)
includes = ' \\\n'.join(self.mIncludeList)
patterns = ' \\\n'.join(self.mPattern)
if self.mMode.lower() == 'html':
sHtmlHelp = 'NO'
sTreeView = 'YES'
else:
sHtmlHelp = 'YES'
sTreeView = 'NO'
text = doxygenConfigTemplate % {'ProjectName':self.mProjectName,
'OutputDir':self.mOutputDir,
'StripPath':self.mStripPath,
'ExamplePath':self.mExamplePath,
'FileList':files,
'Pattern':patterns,
'WhetherGenerateHtmlHelp':sHtmlHelp,
'WhetherGenerateTreeView':sTreeView,
'IncludePath':includes,
'WarningFile':self.mWarningFile,
'PreDefined':' '.join(self.mPreDefined),
'ProjectVersion':self.mProjectVersion}
try:
f = open(path, 'w')
f.write(text)
f.close()
except IOError, e:
ErrorMsg ('Fail to generate doxygen config file %s' % path)
return False
return True
########################################################################
# TEST CODE
########################################################################
if __name__== '__main__':
df = DoxygenFile('Platform Document', 'm:\tree')
df.AddPage(Page('Module', 'module'))
p = df.AddPage(Page('Library', 'library'))
p.AddDescription(desc)
p.AddPage(Page('PCD', 'pcds'))
df.Generate()
print df

View File

@ -0,0 +1,611 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#
import array
import uuid
import re
import os
import logging
import core.pe as pe
def GetLogger():
return logging.getLogger('EFI Binary File')
class EFIBinaryError(Exception):
def __init__(self, message):
Exception.__init__(self)
self._message = message
def GetMessage(self):
return self._message
class EfiFd(object):
EFI_FV_HEADER_SIZE = 0x48
def __init__(self):
self._fvs = []
def Load(self, fd, size):
index = fd.tell()
while (index + self.EFI_FV_HEADER_SIZE < size):
fv = EfiFv(self)
fv.Load(fd)
self._fvs.append(fv)
index += fv.GetHeader().GetFvLength()
index = align(index, 8)
fd.seek(index)
def GetFvs(self):
return self._fvs
class EfiFv(object):
FILE_SYSTEM_GUID = uuid.UUID('{8c8ce578-8a3d-4f1c-9935-896185c32dd3}')
def __init__(self, parent=None):
self._size = 0
self._filename = None
self._fvheader = None
self._blockentries = []
self._ffs = []
# following field is for FV in FD
self._parent = parent
self._offset = 0
self._raw = array.array('B')
def Load(self, fd):
self._offset = fd.tell()
self._filename = fd.name
# get file header
self._fvheader = EfiFirmwareVolumeHeader.Read(fd)
#self._fvheader.Dump()
self._size = self._fvheader.GetFvLength()
if self._fvheader.GetFileSystemGuid() != self.FILE_SYSTEM_GUID:
fd.seek(self._offset)
self._raw.fromfile(fd, self.GetHeader().GetFvLength())
return
# read block map
blockentry = BlockMapEntry.Read(fd)
self._blockentries.append(blockentry)
while (blockentry.GetNumberBlocks() != 0 and blockentry.GetLength() != 0):
self._blockentries.append(blockentry)
blockentry = BlockMapEntry.Read(fd)
if self._fvheader.GetSize() + (len(self._blockentries)) * 8 != \
self._fvheader.GetHeaderLength():
raise EFIBinaryError("Volume Header length not consistent with block map!")
index = align(fd.tell(), 8)
count = 0
while ((index + EfiFfs.FFS_HEADER_SIZE) < self._size):
ffs = EfiFfs.Read(fd, self)
if not isValidGuid(ffs.GetNameGuid()):
break
self._ffs.append(ffs)
count += 1
index = align(fd.tell(), 8)
fd.seek(self._offset)
self._raw.fromfile(fd, self.GetHeader().GetFvLength())
def GetFfs(self):
return self._ffs
def GetHeader(self):
return self._fvheader
def GetBlockEntries(self):
return self._blockentries
def GetHeaderRawData(self):
ret = []
ret += self._fvheader.GetRawData()
for block in self._blockentries:
ret += block.GetRawData()
return ret
def GetOffset(self):
return 0
def GetRawData(self):
return self._raw.tolist()
class BinaryItem(object):
def __init__(self, parent=None):
self._size = 0
self._arr = array.array('B')
self._parent = parent
@classmethod
def Read(cls, fd, parent=None):
item = cls(parent)
item.fromfile(fd)
return item
def Load(self, fd):
self.fromfile(fd)
def GetSize(self):
"""should be implemented by inherited class"""
def fromfile(self, fd):
self._arr.fromfile(fd, self.GetSize())
def GetParent(self):
return self._parent
class EfiFirmwareVolumeHeader(BinaryItem):
def GetSize(self):
return 56
def GetSigunature(self):
list = self._arr.tolist()
sig = ''
for x in list[40:44]:
sig += chr(x)
return sig
def GetAttribute(self):
return list2int(self._arr.tolist()[44:48])
def GetErasePolarity(self):
list = self.GetAttrStrings()
if 'EFI_FVB2_ERASE_POLARITY' in list:
return True
return False
def GetAttrStrings(self):
list = []
value = self.GetAttribute()
if (value & 0x01) != 0:
list.append('EFI_FVB2_READ_DISABLED_CAP')
if (value & 0x02) != 0:
list.append('EFI_FVB2_READ_ENABLED_CAP')
if (value & 0x04) != 0:
list.append('EFI_FVB2_READ_STATUS')
if (value & 0x08) != 0:
list.append('EFI_FVB2_WRITE_DISABLED_CAP')
if (value & 0x10) != 0:
list.append('EFI_FVB2_WRITE_ENABLED_CAP')
if (value & 0x20) != 0:
list.append('EFI_FVB2_WRITE_STATUS')
if (value & 0x40) != 0:
list.append('EFI_FVB2_LOCK_CAP')
if (value & 0x80) != 0:
list.append('EFI_FVB2_LOCK_STATUS')
if (value & 0x200) != 0:
list.append('EFI_FVB2_STICKY_WRITE')
if (value & 0x400) != 0:
list.append('EFI_FVB2_MEMORY_MAPPED')
if (value & 0x800) != 0:
list.append('EFI_FVB2_ERASE_POLARITY')
if (value & 0x1000) != 0:
list.append('EFI_FVB2_READ_LOCK_CAP')
if (value & 0x00002000) != 0:
list.append('EFI_FVB2_READ_LOCK_STATUS')
if (value & 0x00004000) != 0:
list.append('EFI_FVB2_WRITE_LOCK_CAP')
if (value & 0x00008000) != 0:
list.append('EFI_FVB2_WRITE_LOCK_STATUS')
if (value == 0):
list.append('EFI_FVB2_ALIGNMENT_1')
if (value & 0x001F0000) == 0x00010000:
list.append('EFI_FVB2_ALIGNMENT_2')
if (value & 0x001F0000) == 0x00020000:
list.append('EFI_FVB2_ALIGNMENT_4')
if (value & 0x001F0000) == 0x00030000:
list.append('EFI_FVB2_ALIGNMENT_8')
if (value & 0x001F0000) == 0x00040000:
list.append('EFI_FVB2_ALIGNMENT_16')
if (value & 0x001F0000) == 0x00050000:
list.append('EFI_FVB2_ALIGNMENT_32')
if (value & 0x001F0000) == 0x00060000:
list.append('EFI_FVB2_ALIGNMENT_64')
if (value & 0x001F0000) == 0x00070000:
list.append('EFI_FVB2_ALIGNMENT_128')
if (value & 0x001F0000) == 0x00080000:
list.append('EFI_FVB2_ALIGNMENT_256')
if (value & 0x001F0000) == 0x00090000:
list.append('EFI_FVB2_ALIGNMENT_512')
if (value & 0x001F0000) == 0x000A0000:
list.append('EFI_FVB2_ALIGNMENT_1K')
if (value & 0x001F0000) == 0x000B0000:
list.append('EFI_FVB2_ALIGNMENT_2K')
if (value & 0x001F0000) == 0x000C0000:
list.append('EFI_FVB2_ALIGNMENT_4K')
if (value & 0x001F0000) == 0x000D0000:
list.append('EFI_FVB2_ALIGNMENT_8K')
if (value & 0x001F0000) == 0x000E0000:
list.append('EFI_FVB2_ALIGNMENT_16K')
if (value & 0x001F0000) == 0x000F0000:
list.append('EFI_FVB2_ALIGNMENT_32K')
if (value & 0x001F0000) == 0x00100000:
list.append('EFI_FVB2_ALIGNMENT_64K')
if (value & 0x001F0000) == 0x00110000:
list.append('EFI_FVB2_ALIGNMENT_128K')
if (value & 0x001F0000) == 0x00120000:
list.append('EFI_FVB2_ALIGNMENT_256K')
if (value & 0x001F0000) == 0x00130000:
list.append('EFI_FVB2_ALIGNMENT_512K')
return list
def GetHeaderLength(self):
return list2int(self._arr.tolist()[48:50])
def Dump(self):
print 'Signature: %s' % self.GetSigunature()
print 'Attribute: 0x%X' % self.GetAttribute()
print 'Header Length: 0x%X' % self.GetHeaderLength()
print 'File system Guid: ', self.GetFileSystemGuid()
print 'Revision: 0x%X' % self.GetRevision()
print 'FvLength: 0x%X' % self.GetFvLength()
def GetFileSystemGuid(self):
list = self._arr.tolist()
return list2guid(list[16:32])
def GetRevision(self):
list = self._arr.tolist()
return int(list[55])
def GetFvLength(self):
list = self._arr.tolist()
return list2int(list[32:40])
def GetRawData(self):
return self._arr.tolist()
class BlockMapEntry(BinaryItem):
def GetSize(self):
return 8
def GetNumberBlocks(self):
list = self._arr.tolist()
return list2int(list[0:4])
def GetLength(self):
list = self._arr.tolist()
return list2int(list[4:8])
def GetRawData(self):
return self._arr.tolist()
def __str__(self):
return '[BlockEntry] Number = 0x%X, length=0x%X' % (self.GetNumberBlocks(), self.GetLength())
class EfiFfs(object):
FFS_HEADER_SIZE = 24
def __init__(self, parent=None):
self._header = None
# following field is for FFS in FV file.
self._parent = parent
self._offset = 0
self._sections = []
def Load(self, fd):
self._offset = align(fd.tell(), 8)
self._header = EfiFfsHeader.Read(fd, self)
if not isValidGuid(self.GetNameGuid()):
return
index = self._offset
fileend = self._offset + self.GetSize()
while (index + EfiSection.EFI_SECTION_HEADER_SIZE < fileend):
section = EfiSection(self)
section.Load(fd)
if section.GetSize() == 0 and section.GetHeader().GetType() == 0:
break
self._sections.append(section)
index = fd.tell()
# rebase file pointer to next ffs file
index = self._offset + self._header.GetFfsSize()
index = align(index, 8)
fd.seek(index)
def GetOffset(self):
return self._offset
def GetSize(self):
return self._header.GetFfsSize()
@classmethod
def Read(cls, fd, parent=None):
item = cls(parent)
item.Load(fd)
return item
def GetNameGuid(self):
return self._header.GetNameGuid()
def DumpContent(self):
list = self._content.tolist()
line = []
count = 0
for item in list:
if count < 32:
line.append('0x%X' % int(item))
count += 1
else:
print ' '.join(line)
count = 0
line = []
line.append('0x%X' % int(item))
count += 1
def GetHeader(self):
return self._header
def GetParent(self):
return self._parent
def GetSections(self):
return self._sections
class EfiFfsHeader(BinaryItem):
ffs_state_map = {0x01:'EFI_FILE_HEADER_CONSTRUCTION',
0x02:'EFI_FILE_HEADER_VALID',
0x04:'EFI_FILE_DATA_VALID',
0x08:'EFI_FILE_MARKED_FOR_UPDATE',
0x10:'EFI_FILE_DELETED',
0x20:'EFI_FILE_HEADER_INVALID'}
def GetSize(self):
return 24
def GetNameGuid(self):
list = self._arr.tolist()
return list2guid(list[0:16])
def GetType(self):
list = self._arr.tolist()
return int(list[18])
def GetTypeString(self):
value = self.GetType()
if value == 0x01:
return 'EFI_FV_FILETYPE_RAW'
if value == 0x02:
return 'EFI_FV_FILETYPE_FREEFORM'
if value == 0x03:
return 'EFI_FV_FILETYPE_SECURITY_CORE'
if value == 0x04:
return 'EFI_FV_FILETYPE_PEI_CORE'
if value == 0x05:
return 'EFI_FV_FILETYPE_DXE_CORE'
if value == 0x06:
return 'EFI_FV_FILETYPE_PEIM'
if value == 0x07:
return 'EFI_FV_FILETYPE_DRIVER'
if value == 0x08:
return 'EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER'
if value == 0x09:
return 'EFI_FV_FILETYPE_APPLICATION'
if value == 0x0B:
return 'EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE'
if value == 0xc0:
return 'EFI_FV_FILETYPE_OEM_MIN'
if value == 0xdf:
return 'EFI_FV_FILETYPE_OEM_MAX'
if value == 0xe0:
return 'EFI_FV_FILETYPE_DEBUG_MIN'
if value == 0xef:
return 'EFI_FV_FILETYPE_DEBUG_MAX'
if value == 0xf0:
return 'EFI_FV_FILETYPE_FFS_PAD'
if value == 0xff:
return 'EFI_FV_FILETYPE_FFS_MAX'
return 'Unknown FFS Type'
def GetAttributes(self):
list = self._arr.tolist()
return int(list[19])
def GetFfsSize(self):
list = self._arr.tolist()
return list2int(list[20:23])
def GetState(self):
list = self._arr.tolist()
state = int(list[23])
polarity = self.GetParent().GetParent().GetHeader().GetErasePolarity()
if polarity:
state = (~state) & 0xFF
HighestBit = 0x80
while (HighestBit != 0) and (HighestBit & state) == 0:
HighestBit = HighestBit >> 1
return HighestBit
def GetStateString(self):
state = self.GetState()
if state in self.ffs_state_map.keys():
return self.ffs_state_map[state]
return 'Unknown Ffs State'
def Dump(self):
print "FFS name: ", self.GetNameGuid()
print "FFS type: ", self.GetType()
print "FFS attr: 0x%X" % self.GetAttributes()
print "FFS size: 0x%X" % self.GetFfsSize()
print "FFS state: 0x%X" % self.GetState()
def GetRawData(self):
return self._arr.tolist()
class EfiSection(object):
EFI_SECTION_HEADER_SIZE = 4
def __init__(self, parent=None):
self._size = 0
self._parent = parent
self._offset = 0
self._contents = array.array('B')
def Load(self, fd):
self._offset = align(fd.tell(), 4)
self._header = EfiSectionHeader.Read(fd, self)
if self._header.GetTypeString() == "EFI_SECTION_PE32":
pefile = pe.PEFile(self)
pefile.Load(fd, self.GetContentSize())
fd.seek(self._offset)
self._contents.fromfile(fd, self.GetContentSize())
# rebase file pointer to next section
index = self._offset + self.GetSize()
index = align(index, 4)
fd.seek(index)
def GetContentSize(self):
return self.GetSize() - self.EFI_SECTION_HEADER_SIZE
def GetContent(self):
return self._contents.tolist()
def GetSize(self):
return self._header.GetSectionSize()
def GetHeader(self):
return self._header
def GetSectionOffset(self):
return self._offset + self.EFI_SECTION_HEADER_SIZE
class EfiSectionHeader(BinaryItem):
section_type_map = {0x01: 'EFI_SECTION_COMPRESSION',
0x02: 'EFI_SECTION_GUID_DEFINED',
0x10: 'EFI_SECTION_PE32',
0x11: 'EFI_SECTION_PIC',
0x12: 'EFI_SECTION_TE',
0x13: 'EFI_SECTION_DXE_DEPEX',
0x14: 'EFI_SECTION_VERSION',
0x15: 'EFI_SECTION_USER_INTERFACE',
0x16: 'EFI_SECTION_COMPATIBILITY16',
0x17: 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE',
0x18: 'EFI_SECTION_FREEFORM_SUBTYPE_GUID',
0x19: 'EFI_SECTION_RAW',
0x1B: 'EFI_SECTION_PEI_DEPEX'}
def GetSize(self):
return 4
def GetSectionSize(self):
list = self._arr.tolist()
return list2int(list[0:3])
def GetType(self):
list = self._arr.tolist()
return int(list[3])
def GetTypeString(self):
type = self.GetType()
if type not in self.section_type_map.keys():
return 'Unknown Section Type'
return self.section_type_map[type]
def Dump(self):
print 'size = 0x%X' % self.GetSectionSize()
print 'type = 0x%X' % self.GetType()
rMapEntry = re.compile('^(\w+)[ \(\w\)]* \(BaseAddress=([0-9a-fA-F]+), EntryPoint=([0-9a-fA-F]+), GUID=([0-9a-fA-F\-]+)')
class EfiFvMapFile(object):
def __init__(self):
self._mapentries = {}
def Load(self, path):
if not os.path.exists(path):
return False
try:
file = open(path, 'r')
lines = file.readlines()
file.close()
except:
return False
for line in lines:
if line[0] != ' ':
# new entry
ret = rMapEntry.match(line)
if ret != None:
name = ret.groups()[0]
baseaddr = int(ret.groups()[1], 16)
entry = int(ret.groups()[2], 16)
guidstr = '{' + ret.groups()[3] + '}'
guid = uuid.UUID(guidstr)
self._mapentries[guid] = EfiFvMapFileEntry(name, baseaddr, entry, guid)
return True
def GetEntry(self, guid):
if guid in self._mapentries.keys():
return self._mapentries[guid]
return None
class EfiFvMapFileEntry(object):
def __init__(self, name, baseaddr, entry, guid):
self._name = name
self._baseaddr = baseaddr
self._entry = entry
self._guid = guid
def GetName(self):
return self._name
def GetBaseAddress(self):
return self._baseaddr
def GetEntryPoint(self):
return self._entry
def list2guid(list):
val1 = list2int(list[0:4])
val2 = list2int(list[4:6])
val3 = list2int(list[6:8])
val4 = 0
for item in list[8:16]:
val4 = (val4 << 8) | int(item)
val = val1 << 12 * 8 | val2 << 10 * 8 | val3 << 8 * 8 | val4
guid = uuid.UUID(int=val)
return guid
def list2int(list):
val = 0
for index in range(len(list) - 1, -1, -1):
val = (val << 8) | int(list[index])
return val
def align(value, alignment):
return (value + ((alignment - value) & (alignment - 1)))
gInvalidGuid = uuid.UUID(int=0xffffffffffffffffffffffffffffffff)
def isValidGuid(guid):
if guid == gInvalidGuid:
return False
return True

View File

@ -0,0 +1,480 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#
from message import *
import re
import os
section_re = re.compile(r'^\[([\w., "]+)\]')
class BaseINIFile(object):
_objs = {}
def __new__(cls, *args, **kwargs):
"""Maintain only a single instance of this object
@return: instance of this class
"""
if len(args) == 0: return object.__new__(cls, *args, **kwargs)
filename = args[0]
parent = None
if len(args) > 1:
parent = args[1]
key = os.path.normpath(filename)
if key not in cls._objs.keys():
cls._objs[key] = object.__new__(cls, *args, **kwargs)
if parent != None:
cls._objs[key].AddParent(parent)
return cls._objs[key]
def __init__(self, filename=None, parent=None):
self._lines = []
self._sections = {}
self._filename = filename
self._globals = []
self._isModify = True
def AddParent(self, parent):
if parent == None: return
if not hasattr(self, "_parents"):
self._parents = []
if parent in self._parents:
ErrorMsg("Duplicate parent is found for INI file %s" % self._filename)
return
self._parents.append(parent)
def GetFilename(self):
return os.path.normpath(self._filename)
def IsModified(self):
return self._isModify
def Modify(self, modify=True, obj=None):
if modify == self._isModify: return
self._isModify = modify
if modify:
for parent in self._parents:
parent.Modify(True, self)
def _ReadLines(self, filename):
#
# try to open file
#
if not os.path.exists(filename):
return False
try:
handle = open(filename, 'r')
self._lines = handle.readlines()
handle.close()
except:
raise EdkException("Fail to open file %s" % filename)
return True
def GetSectionInstance(self, parent, name, isCombined=False):
return BaseINISection(parent, name, isCombined)
def GetSectionByName(self, name):
arr = []
for key in self._sections.keys():
if '.private' in key:
continue
for item in self._sections[key]:
if item.GetBaseName().lower().find(name.lower()) != -1:
arr.append(item)
return arr
def GetSectionObjectsByName(self, name):
arr = []
sects = self.GetSectionByName(name)
for sect in sects:
for obj in sect.GetObjects():
arr.append(obj)
return arr
def Parse(self):
if not self._isModify: return True
if not self._ReadLines(self._filename): return False
sObjs = []
inGlobal = True
# process line
for index in range(len(self._lines)):
templine = self._lines[index].strip()
# skip comments
if len(templine) == 0: continue
if re.match("^\[=*\]", templine) or re.match("^#", templine) or \
re.match("\*+/", templine):
continue
m = section_re.match(templine)
if m!= None: # found a section
inGlobal = False
# Finish the latest section first
if len(sObjs) != 0:
for sObj in sObjs:
sObj._end = index - 1
if not sObj.Parse():
ErrorMsg("Fail to parse section %s" % sObj.GetBaseName(),
self._filename,
sObj._start)
# start new section
sname_arr = m.groups()[0].split(',')
sObjs = []
for name in sname_arr:
sObj = self.GetSectionInstance(self, name, (len(sname_arr) > 1))
sObj._start = index
sObjs.append(sObj)
if not self._sections.has_key(name.lower()):
self._sections[name.lower()] = [sObj]
else:
self._sections[name.lower()].append(sObj)
elif inGlobal: # not start any section and find global object
gObj = BaseINIGlobalObject(self)
gObj._start = index
gObj.Parse()
self._globals.append(gObj)
# Finish the last section
if len(sObjs) != 0:
for sObj in sObjs:
sObj._end = index
if not sObj.Parse():
ErrorMsg("Fail to parse section %s" % sObj.GetBaseName(),
self._filename,
sObj._start)
self._isModify = False
return True
def Destroy(self, parent):
# check referenced parent
if parent != None:
assert parent in self._parents, "when destory ini object, can not found parent reference!"
self._parents.remove(parent)
if len(self._parents) != 0: return
for sects in self._sections.values():
for sect in sects:
sect.Destroy()
# dereference from _objs array
assert self.GetFilename() in self._objs.keys(), "When destroy ini object, can not find obj reference!"
assert self in self._objs.values(), "When destroy ini object, can not find obj reference!"
del self._objs[self.GetFilename()]
# dereference self
self.Clear()
def GetDefine(self, name):
sects = self.GetSectionByName('Defines')
for sect in sects:
for obj in sect.GetObjects():
line = obj.GetLineByOffset(obj._start).split('#')[0].strip()
arr = line.split('=')
if arr[0].strip().lower() == name.strip().lower():
return arr[1].strip()
return None
def Clear(self):
for sects in self._sections.values():
for sect in sects:
del sect
self._sections.clear()
for gObj in self._globals:
del gObj
del self._globals[:]
del self._lines[:]
def Reload(self):
self.Clear()
ret = self.Parse()
if ret:
self._isModify = False
return ret
def AddNewSection(self, sectName):
if sectName.lower() in self._sections.keys():
ErrorMsg('Section %s can not be created for conflict with existing section')
return None
sectionObj = self.GetSectionInstance(self, sectName)
sectionObj._start = len(self._lines)
sectionObj._end = len(self._lines) + 1
self._lines.append('[%s]\n' % sectName)
self._lines.append('\n\n')
self._sections[sectName.lower()] = sectionObj
return sectionObj
def CopySectionsByName(self, oldDscObj, nameStr):
sects = oldDscObj.GetSectionByName(nameStr)
for sect in sects:
sectObj = self.AddNewSection(sect.GetName())
sectObj.Copy(sect)
def __str__(self):
return ''.join(self._lines)
## Get file header's comment from basic INI file.
# The file comments has two style:
# 1) #/** @file
# 2) ## @file
#
def GetFileHeader(self):
desc = []
lineArr = self._lines
inHeader = False
for num in range(len(self._lines)):
line = lineArr[num].strip()
if not inHeader and (line.startswith("#/**") or line.startswith("##")) and \
line.find("@file") != -1:
inHeader = True
continue
if inHeader and (line.startswith("#**/") or line.startswith('##')):
inHeader = False
break
if inHeader:
prefixIndex = line.find('#')
if prefixIndex == -1:
desc.append(line)
else:
desc.append(line[prefixIndex + 1:])
return '<br>\n'.join(desc)
class BaseINISection(object):
def __init__(self, parent, name, isCombined=False):
self._parent = parent
self._name = name
self._isCombined = isCombined
self._start = 0
self._end = 0
self._objs = []
def __del__(self):
for obj in self._objs:
del obj
del self._objs[:]
def GetName(self):
return self._name
def GetObjects(self):
return self._objs
def GetParent(self):
return self._parent
def GetStartLinenumber(self):
return self._start
def GetEndLinenumber(self):
return self._end
def GetLine(self, linenumber):
return self._parent._lines[linenumber]
def GetFilename(self):
return self._parent.GetFilename()
def GetSectionINIObject(self, parent):
return BaseINISectionObject(parent)
def Parse(self):
# skip first line in section, it is used by section name
visit = self._start + 1
iniObj = None
while (visit <= self._end):
line = self.GetLine(visit).strip()
if re.match("^\[=*\]", line) or re.match("^#", line) or len(line) == 0:
visit += 1
continue
line = line.split('#')[0].strip()
if iniObj != None:
if line.endswith('}'):
iniObj._end = visit - self._start
if not iniObj.Parse():
ErrorMsg("Fail to parse ini object",
self.GetFilename(),
iniObj.GetStartLinenumber())
else:
self._objs.append(iniObj)
iniObj = None
else:
iniObj = self.GetSectionINIObject(self)
iniObj._start = visit - self._start
if not line.endswith('{'):
iniObj._end = visit - self._start
if not iniObj.Parse():
ErrorMsg("Fail to parse ini object",
self.GetFilename(),
iniObj.GetStartLinenumber())
else:
self._objs.append(iniObj)
iniObj = None
visit += 1
return True
def Destroy(self):
for obj in self._objs:
obj.Destroy()
def GetBaseName(self):
return self._name
def AddLine(self, line):
end = self.GetEndLinenumber()
self._parent._lines.insert(end, line)
self._end += 1
def Copy(self, sectObj):
index = sectObj.GetStartLinenumber() + 1
while index < sectObj.GetEndLinenumber():
line = sectObj.GetLine(index)
if not line.strip().startswith('#'):
self.AddLine(line)
index += 1
def AddObject(self, obj):
lines = obj.GenerateLines()
for line in lines:
self.AddLine(line)
def GetComment(self):
comments = []
start = self._start - 1
bFound = False
while (start > 0):
line = self.GetLine(start).strip()
if len(line) == 0:
start -= 1
continue
if line.startswith('##'):
bFound = True
index = line.rfind('#')
if (index + 1) < len(line):
comments.append(line[index + 1:])
break
if line.startswith('#'):
start -= 1
continue
break
if bFound:
end = start + 1
while (end < self._start):
line = self.GetLine(end).strip()
if len(line) == 0: break
if not line.startswith('#'): break
index = line.rfind('#')
if (index + 1) < len(line):
comments.append(line[index + 1:])
end += 1
return comments
class BaseINIGlobalObject(object):
def __init__(self, parent):
self._start = 0
self._end = 0
def Parse(self):
return True
def __str__(self):
return parent._lines[self._start]
def __del__(self):
pass
class BaseINISectionObject(object):
def __init__(self, parent):
self._start = 0
self._end = 0
self._parent = parent
def __del__(self):
self._parent = None
def GetParent(self):
return self._parent
def GetFilename(self):
return self.GetParent().GetFilename()
def GetPackageName(self):
return self.GetFilename()
def GetFileObj(self):
return self.GetParent().GetParent()
def GetStartLinenumber(self):
return self.GetParent()._start + self._start
def GetLineByOffset(self, offset):
sect_start = self._parent.GetStartLinenumber()
linenumber = sect_start + offset
return self._parent.GetLine(linenumber)
def GetLinenumberByOffset(self, offset):
return offset + self._parent.GetStartLinenumber()
def Parse(self):
return True
def Destroy(self):
pass
def __str__(self):
return self.GetLineByOffset(self._start).strip()
def GenerateLines(self):
return ['default setion object string\n']
def GetComment(self):
comments = []
start = self.GetStartLinenumber() - 1
bFound = False
while (start > 0):
line = self.GetParent().GetLine(start).strip()
if len(line) == 0:
start -= 1
continue
if line.startswith('##'):
bFound = True
index = line.rfind('#')
if (index + 1) < len(line):
comments.append(line[index + 1:])
break
if line.startswith('#'):
start -= 1
continue
break
if bFound:
end = start + 1
while (end <= self.GetStartLinenumber() - 1):
line = self.GetParent().GetLine(end).strip()
if len(line) == 0: break
if not line.startswith('#'): break
index = line.rfind('#')
if (index + 1) < len(line):
comments.append(line[index + 1:])
end += 1
return comments

View File

@ -0,0 +1,23 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#
import core.editor
class INIDoc(core.editor.EditorDocument):
def __init__(self):
core.editor.EditorDocument.__init__(self)
self._iniobj = None
class INIView(core.editor.EditorView):
pass

View File

@ -0,0 +1,52 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#
def GetEdkLogger():
import logging
return logging.getLogger('edk')
class EdkException(Exception):
def __init__(self, message, fName=None, fNo=None):
self._message = message
ErrorMsg(message, fName, fNo)
def GetMessage(self):
return '[EDK Failure]: %s' %self._message
def ErrorMsg(mess, fName=None, fNo=None):
GetEdkLogger().error(NormalMessage('#ERR#', mess, fName, fNo))
def LogMsg(mess, fName=None, fNo=None):
GetEdkLogger().info(NormalMessage('@LOG@', mess, fName, fNo))
def WarnMsg(mess, fName=None, fNo=None):
GetEdkLogger().warning(NormalMessage('!WAR!', mess, fName, fNo))
def NormalMessage(type, mess, fName=None, fNo=None):
strMsg = type
if fName != None:
strMsg += ' %s' % fName.replace('/', '\\')
if fNo != None:
strMsg += '(%d):' % fNo
else:
strMsg += ' :'
if fName == None and fNo == None:
strMsg += ' '
strMsg += mess
return strMsg

View File

@ -0,0 +1,12 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#

View File

@ -0,0 +1,12 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#

View File

@ -0,0 +1,934 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
import plugins.EdkPlugins.basemodel.ini as ini
import plugins.EdkPlugins.edk2.model.dsc as dsc
import plugins.EdkPlugins.edk2.model.inf as inf
import plugins.EdkPlugins.edk2.model.dec as dec
import os
from plugins.EdkPlugins.basemodel.message import *
class SurfaceObject(object):
_objs = {}
def __new__(cls, *args, **kwargs):
"""Maintain only a single instance of this object
@return: instance of this class
"""
obj = object.__new__(cls, *args, **kwargs)
if not cls._objs.has_key("None"):
cls._objs["None"] = []
cls._objs["None"].append(obj)
return obj
def __init__(self, parent, workspace):
self._parent = parent
self._fileObj = None
self._workspace = workspace
self._isModify = False
self._modifiedObjs = []
def __del__(self):
pass
def Destroy(self):
key = self.GetRelativeFilename()
self.GetFileObj().Destroy(self)
del self._fileObj
# dereference self from _objs arrary
assert self._objs.has_key(key), "when destory, object is not in obj list"
assert self in self._objs[key], "when destory, object is not in obj list"
self._objs[key].remove(self)
if len(self._objs[key]) == 0:
del self._objs[key]
def GetParent(self):
return self._parent
def GetWorkspace(self):
return self._workspace
def GetFileObjectClass(self):
return ini.BaseINIFile
def GetFilename(self):
return self.GetFileObj().GetFilename()
def GetFileObj(self):
return self._fileObj
def GetRelativeFilename(self):
fullPath = self.GetFilename()
return fullPath[len(self._workspace) + 1:]
def Load(self, relativePath):
# if has been loaded, directly return
if self._fileObj != None: return True
relativePath = os.path.normpath(relativePath)
fullPath = os.path.join(self._workspace, relativePath)
fullPath = os.path.normpath(fullPath)
if not os.path.exists(fullPath):
ErrorMsg("file does not exist!", fullPath)
return False
self._fileObj = self.GetFileObjectClass()(fullPath, self)
if not self._fileObj.Parse():
ErrorMsg("Fail to parse file!", fullPath)
return False
# remove self from None list to list with filename as key
cls = self.__class__
if self not in cls._objs["None"]:
ErrorMsg("Sufrace object does not be create into None list")
cls._objs["None"].remove(self)
if not cls._objs.has_key(relativePath):
cls._objs[relativePath] = []
cls._objs[relativePath].append(self)
return True
def Reload(self, force=False):
ret = True
# whether require must be update
if force:
ret = self.GetFileObj().Reload(True)
else:
if self.IsModified():
if self.GetFileObj().IsModified():
ret = self.GetFileObj().Reload()
return ret
def Modify(self, modify=True, modifiedObj=None):
if modify:
#LogMsg("%s is modified, modified object is %s" % (self.GetFilename(), modifiedObj))
if issubclass(modifiedObj.__class__, ini.BaseINIFile) and self._isModify:
return
self._isModify = modify
self.GetParent().Modify(modify, self)
else:
self._isModify = modify
def IsModified(self):
return self._isModify
def GetModifiedObjs(self):
return self._modifiedObjs
def FilterObjsByArch(self, objs, arch):
arr = []
for obj in objs:
if obj.GetArch().lower() == 'common':
arr.append(obj)
continue
if obj.GetArch().lower() == arch.lower():
arr.append(obj)
continue
return arr
class Platform(SurfaceObject):
def __init__(self, parent, workspace):
SurfaceObject.__init__(self, parent, workspace)
self._modules = []
self._packages = []
def Destroy(self):
for module in self._modules:
module.Destroy()
del self._modules[:]
del self._packages[:]
SurfaceObject.Destroy(self)
def GetName(self):
return self.GetFileObj().GetDefine("PLATFORM_NAME")
def GetFileObjectClass(self):
return dsc.DSCFile
def GetModuleCount(self):
if self.GetFileObj() == None:
ErrorMsg("Fail to get module count because DSC file has not been load!")
return len(self.GetFileObj().GetComponents())
def GetSupportArchs(self):
return self.GetFileObj().GetDefine("SUPPORTED_ARCHITECTURES").strip().split('#')[0].split('|')
def LoadModules(self, precallback=None, postcallback=None):
for obj in self.GetFileObj().GetComponents():
mFilename = obj.GetFilename()
if precallback != None:
precallback(self, mFilename)
arch = obj.GetArch()
if arch.lower() == 'common':
archarr = self.GetSupportArchs()
else:
archarr = [arch]
for arch in archarr:
module = Module(self, self.GetWorkspace())
if module.Load(mFilename, arch, obj.GetOveridePcds(), obj.GetOverideLibs()):
self._modules.append(module)
if postcallback != None:
postcallback(self, module)
else:
del module
ErrorMsg("Fail to load module %s" % mFilename)
def GetModules(self):
return self._modules
def GetLibraryPath(self, classname, arch, type):
objs = self.GetFileObj().GetSectionObjectsByName("libraryclasses")
for obj in objs:
if classname.lower() != obj.GetClass().lower():
continue
if obj.GetArch().lower() != 'common' and \
obj.GetArch().lower() != arch.lower():
continue
if obj.GetModuleType().lower() != 'common' and \
obj.GetModuleType().lower() != type.lower():
continue
return obj.GetInstance()
ErrorMsg("Fail to get library class %s [%s][%s] from platform %s" % (classname, arch, type, self.GetFilename()))
return None
def GetPackage(self, path):
package = self.GetParent().GetPackage(path)
if package not in self._packages:
self._packages.append(package)
return package
def GetPcdBuildObjs(self, name, arch=None):
arr = []
objs = self.GetFileObj().GetSectionObjectsByName('pcds')
for obj in objs:
if obj.GetPcdName().lower() == name.lower():
arr.append(obj)
if arch != None:
arr = self.FilterObjsByArch(arr, arch)
return arr
def Reload(self, callback=None):
# do not care force paramter for platform object
isFileChanged = self.GetFileObj().IsModified()
ret = SurfaceObject.Reload(self, False)
if not ret: return False
if isFileChanged:
# destroy all modules and reload them again
for obj in self._modules:
obj.Destroy()
del self._modules[:]
del self._packages[:]
self.LoadModules(callback)
else:
for obj in self._modules:
callback(self, obj.GetFilename())
obj.Reload()
self.Modify(False)
return True
def Modify(self, modify=True, modifiedObj=None):
if modify:
#LogMsg("%s is modified, modified object is %s" % (self.GetFilename(), modifiedObj))
if issubclass(modifiedObj.__class__, ini.BaseINIFile) and self._isModify:
return
self._isModify = modify
self.GetParent().Modify(modify, self)
else:
if self.GetFileObj().IsModified():
return
for obj in self._modules:
if obj.IsModified():
return
self._isModify = modify
self.GetParent().Modify(modify, self)
def GetModuleObject(self, relativePath, arch):
path = os.path.normpath(relativePath)
for obj in self._modules:
if obj.GetRelativeFilename() == path:
if arch.lower() == 'common':
return obj
if obj.GetArch() == arch:
return obj
return None
def GenerateFullReferenceDsc(self):
oldDsc = self.GetFileObj()
newDsc = dsc.DSCFile()
newDsc.CopySectionsByName(oldDsc, 'defines')
newDsc.CopySectionsByName(oldDsc, 'SkuIds')
#
# Dynamic common section should also be copied
#
newDsc.CopySectionsByName(oldDsc, 'PcdsDynamicDefault')
newDsc.CopySectionsByName(oldDsc, 'PcdsDynamicHii')
newDsc.CopySectionsByName(oldDsc, 'PcdsDynamicVpd')
newDsc.CopySectionsByName(oldDsc, 'PcdsDynamicEx')
sects = oldDsc.GetSectionByName('Components')
for oldSect in sects:
newSect = newDsc.AddNewSection(oldSect.GetName())
for oldComObj in oldSect.GetObjects():
module = self.GetModuleObject(oldComObj.GetFilename(), oldSect.GetArch())
if module == None: continue
newComObj = dsc.DSCComponentObject(newSect)
newComObj.SetFilename(oldComObj.GetFilename())
# add all library instance for override section
libdict = module.GetLibraries()
for libclass in libdict.keys():
if libdict[libclass] != None:
newComObj.AddOverideLib(libclass, libdict[libclass].GetRelativeFilename().replace('\\', '/'))
# add all pcds for override section
pcddict = module.GetPcds()
for pcd in pcddict.values():
buildPcd = pcd.GetBuildObj()
buildType = buildPcd.GetPcdType()
buildValue = None
if buildType.lower() == 'pcdsdynamichii' or \
buildType.lower() == 'pcdsdynamicvpd' or \
buildType.lower() == 'pcdsdynamicdefault':
buildType = 'PcdsDynamic'
if buildType != 'PcdsDynamic':
buildValue = buildPcd.GetPcdValue()
newComObj.AddOveridePcd(buildPcd.GetPcdName(),
buildType,
buildValue)
newSect.AddObject(newComObj)
return newDsc
class Module(SurfaceObject):
def __init__(self, parent, workspace):
SurfaceObject.__init__(self, parent, workspace)
self._arch = 'common'
self._parent = parent
self._overidePcds = {}
self._overideLibs = {}
self._libs = {}
self._pcds = {}
self._ppis = []
self._protocols = []
self._depexs = []
self._guids = []
self._packages = []
def Destroy(self):
for lib in self._libs.values():
if lib != None:
lib.Destroy()
self._libs.clear()
for pcd in self._pcds.values():
pcd.Destroy()
self._pcds.clear()
for ppi in self._ppis:
ppi.DeRef(self)
del self._ppis[:]
for protocol in self._protocols:
if protocol != None:
protocol.DeRef(self)
del self._protocols[:]
for guid in self._guids:
if guid != None:
guid.DeRef(self)
del self._guids[:]
del self._packages[:]
del self._depexs[:]
SurfaceObject.Destroy(self)
def GetFileObjectClass(self):
return inf.INFFile
def GetLibraries(self):
return self._libs
def Load(self, filename, arch='common', overidePcds=None, overideLibs=None):
if not SurfaceObject.Load(self, filename):
return False
self._arch = arch
if overidePcds != None:
self._overideLibs = overideLibs
if overideLibs != None:
self._overidePcds = overidePcds
self._SearchLibraries()
self._SearchPackage()
self._SearchSurfaceItems()
return True
def GetArch(self):
return self._arch
def GetModuleName(self):
return self.GetFileObj().GetDefine("BASE_NAME")
def GetModuleType(self):
return self.GetFileObj().GetDefine("MODULE_TYPE")
def GetPlatform(self):
return self.GetParent()
def GetModuleObj(self):
return self
def GetPcds(self):
pcds = self._pcds.copy()
for lib in self._libs.values():
if lib == None: continue
for name in lib._pcds.keys():
pcds[name] = lib._pcds[name]
return pcds
def GetPpis(self):
ppis = []
ppis += self._ppis
for lib in self._libs.values():
if lib == None: continue
ppis += lib._ppis
return ppis
def GetProtocols(self):
pros = []
pros = self._protocols
for lib in self._libs.values():
if lib == None: continue
pros += lib._protocols
return pros
def GetGuids(self):
guids = []
guids += self._guids
for lib in self._libs.values():
if lib == None: continue
guids += lib._guids
return guids
def GetDepexs(self):
deps = []
deps += self._depexs
for lib in self._libs.values():
if lib == None: continue
deps += lib._depexs
return deps
def IsLibrary(self):
return self.GetFileObj().GetDefine("LIBRARY_CLASS") != None
def GetLibraryInstance(self, classname, arch, type):
if classname not in self._libs.keys():
# find in overide lib firstly
if classname in self._overideLibs.keys():
self._libs[classname] = Library(self, self.GetWorkspace())
self._libs[classname].Load(self._overideLibs[classname])
return self._libs[classname]
parent = self.GetParent()
if issubclass(parent.__class__, Platform):
path = parent.GetLibraryPath(classname, arch, type)
if path == None:
ErrorMsg('Fail to get library instance for %s' % classname, self.GetFilename())
return None
self._libs[classname] = Library(self, self.GetWorkspace())
if not self._libs[classname].Load(path, self.GetArch()):
self._libs[classname] = None
else:
self._libs[classname] = parent.GetLibraryInstance(classname, arch, type)
return self._libs[classname]
def GetSourceObjs(self):
return self.GetFileObj().GetSectionObjectsByName('source')
def _SearchLibraries(self):
objs = self.GetFileObj().GetSectionObjectsByName('libraryclasses')
arch = self.GetArch()
type = self.GetModuleType()
for obj in objs:
if obj.GetArch().lower() != 'common' and \
obj.GetArch().lower() not in self.GetPlatform().GetSupportArchs():
continue
classname = obj.GetClass()
instance = self.GetLibraryInstance(classname, arch, type)
if not self.IsLibrary() and instance != None:
instance._isInherit = False
if classname not in self._libs.keys():
self._libs[classname] = instance
def _SearchSurfaceItems(self):
# get surface item from self's inf
pcds = []
ppis = []
pros = []
deps = []
guids = []
if self.GetFileObj() != None:
pcds = self.FilterObjsByArch(self.GetFileObj().GetSectionObjectsByName('pcd'),
self.GetArch())
for pcd in pcds:
if pcd.GetPcdName() not in self._pcds.keys():
pcdItem = PcdItem(pcd.GetPcdName(), self, pcd)
self._pcds[pcd.GetPcdName()] = ModulePcd(self,
pcd.GetPcdName(),
pcd,
pcdItem)
ppis += self.FilterObjsByArch(self.GetFileObj().GetSectionObjectsByName('ppis'),
self.GetArch())
for ppi in ppis:
item = PpiItem(ppi.GetName(), self, ppi)
if item not in self._ppis:
self._ppis.append(item)
pros += self.FilterObjsByArch(self.GetFileObj().GetSectionObjectsByName('protocols'),
self.GetArch())
for pro in pros:
item = ProtocolItem(pro.GetName(), self, pro)
if item not in self._protocols:
self._protocols.append(item)
deps += self.FilterObjsByArch(self.GetFileObj().GetSectionObjectsByName('depex'),
self.GetArch())
for dep in deps:
item = DepexItem(self, dep)
self._depexs.append(item)
guids += self.FilterObjsByArch(self.GetFileObj().GetSectionObjectsByName('guids'),
self.GetArch())
for guid in guids:
item = GuidItem(guid.GetName(), self, guid)
if item not in self._guids:
self._guids.append(item)
def _SearchPackage(self):
objs = self.GetFileObj().GetSectionObjectsByName('packages')
for obj in objs:
package = self.GetPlatform().GetPackage(obj.GetPath())
if package != None:
self._packages.append(package)
def GetPackages(self):
return self._packages
def GetPcdObjects(self):
if self.GetFileObj() == None:
return []
return self.GetFileObj().GetSectionObjectsByName('pcd')
def GetLibraryClassHeaderFilePath(self):
lcname = self.GetFileObj().GetProduceLibraryClass()
if lcname == None: return None
pkgs = self.GetPackages()
for package in pkgs:
path = package.GetLibraryClassHeaderPathByName(lcname)
if path != None:
return os.path.realpath(os.path.join(package.GetFileObj().GetPackageRootPath(), path))
return None
def Reload(self, force=False, callback=None):
if callback != None:
callback(self, "Starting reload...")
ret = SurfaceObject.Reload(self, force)
if not ret: return False
if not force and not self.IsModified():
return True
for lib in self._libs.values():
if lib != None:
lib.Destroy()
self._libs.clear()
for pcd in self._pcds.values():
pcd.Destroy()
self._pcds.clear()
for ppi in self._ppis:
ppi.DeRef(self)
del self._ppis[:]
for protocol in self._protocols:
protocol.DeRef(self)
del self._protocols[:]
for guid in self._guids:
guid.DeRef(self)
del self._guids[:]
del self._packages[:]
del self._depexs[:]
if callback != None:
callback(self, "Searching libraries...")
self._SearchLibraries()
if callback != None:
callback(self, "Searching packages...")
self._SearchPackage()
if callback != None:
callback(self, "Searching surface items...")
self._SearchSurfaceItems()
self.Modify(False)
return True
def Modify(self, modify=True, modifiedObj=None):
if modify:
#LogMsg("%s is modified, modified object is %s" % (self.GetFilename(), modifiedObj))
if issubclass(modifiedObj.__class__, ini.BaseINIFile) and self._isModify:
return
self._isModify = modify
self.GetParent().Modify(modify, self)
else:
if self.GetFileObj().IsModified():
return
self._isModify = modify
self.GetParent().Modify(modify, self)
class Library(Module):
def __init__(self, parent, workspace):
Module.__init__(self, parent, workspace)
self._isInherit = True
def IsInherit(self):
return self._isInherit
def GetModuleType(self):
return self.GetParent().GetModuleType()
def GetPlatform(self):
return self.GetParent().GetParent()
def GetModuleObj(self):
return self.GetParent()
def GetArch(self):
return self.GetParent().GetArch()
def Destroy(self):
self._libs.clear()
self._pcds.clear()
SurfaceObject.Destroy(self)
class Package(SurfaceObject):
def __init__(self, parent, workspace):
SurfaceObject.__init__(self, parent, workspace)
self._pcds = {}
self._guids = {}
self._protocols = {}
self._ppis = {}
def GetPcds(self):
return self._pcds
def GetPpis(self):
return self._ppis.values()
def GetProtocols(self):
return self._protocols.values()
def GetGuids(self):
return self._guids.values()
def Destroy(self):
for pcd in self._pcds.values():
if pcd != None:
pcd.Destroy()
for guid in self._guids.values():
if guid != None:
guid.Destroy()
for protocol in self._protocols.values():
if protocol != None:
protocol.Destroy()
for ppi in self._ppis.values():
if ppi != None:
ppi.Destroy()
self._pcds.clear()
self._guids.clear()
self._protocols.clear()
self._ppis.clear()
self._pcds.clear()
SurfaceObject.Destroy(self)
def Load(self, relativePath):
ret = SurfaceObject.Load(self, relativePath)
if not ret: return False
pcds = self.GetFileObj().GetSectionObjectsByName('pcds')
for pcd in pcds:
if pcd.GetPcdName() in self._pcds.keys():
if self._pcds[pcd.GetPcdName()] != None:
self._pcds[pcd.GetPcdName()].AddDecObj(pcd)
else:
self._pcds[pcd.GetPcdName()] = PcdItem(pcd.GetPcdName(), self, pcd)
guids = self.GetFileObj().GetSectionObjectsByName('guids')
for guid in guids:
if guid.GetName() not in self._guids.keys():
self._guids[guid.GetName()] = GuidItem(guid.GetName(), self, guid)
else:
WarnMsg("Duplicate definition for %s" % guid.GetName())
ppis = self.GetFileObj().GetSectionObjectsByName('ppis')
for ppi in ppis:
if ppi.GetName() not in self._ppis.keys():
self._ppis[ppi.GetName()] = PpiItem(ppi.GetName(), self, ppi)
else:
WarnMsg("Duplicate definition for %s" % ppi.GetName())
protocols = self.GetFileObj().GetSectionObjectsByName('protocols')
for protocol in protocols:
if protocol.GetName() not in self._protocols.keys():
self._protocols[protocol.GetName()] = ProtocolItem(protocol.GetName(), self, protocol)
else:
WarnMsg("Duplicate definition for %s" % protocol.GetName())
return True
def GetFileObjectClass(self):
return dec.DECFile
def GetName(self):
return self.GetFileObj().GetDefine("PACKAGE_NAME")
def GetPcdDefineObjs(self, name=None):
arr = []
objs = self.GetFileObj().GetSectionObjectsByName('pcds')
if name == None: return objs
for obj in objs:
if obj.GetPcdName().lower() == name.lower():
arr.append(obj)
return arr
def GetLibraryClassObjs(self):
return self.GetFileObj().GetSectionObjectsByName('libraryclasses')
def Modify(self, modify=True, modifiedObj=None):
if modify:
self._isModify = modify
self.GetParent().Modify(modify, self)
else:
if self.GetFileObj().IsModified():
return
self._isModify = modify
self.GetParent().Modify(modify, self)
def GetLibraryClassHeaderPathByName(self, clsname):
objs = self.GetLibraryClassObjs()
for obj in objs:
if obj.GetClassName() == clsname:
return obj.GetHeaderFile()
return None
class DepexItem(object):
def __init__(self, parent, infObj):
self._parent = parent
self._infObj = infObj
def GetDepexString(self):
return str(self._infObj)
def GetInfObject(self):
return self._infObj
class ModulePcd(object):
_type_mapping = {'FeaturePcd': 'PcdsFeatureFlag',
'FixedPcd': 'PcdsFixedAtBuild',
'PatchPcd': 'PcdsPatchableInModule'}
def __init__(self, parent, name, infObj, pcdItem):
assert issubclass(parent.__class__, Module), "Module's PCD's parent must be module!"
assert pcdItem != None, 'Pcd %s does not in some package!' % name
self._name = name
self._parent = parent
self._pcdItem = pcdItem
self._infObj = infObj
def GetName(self):
return self._name
def GetParent(self):
return self._name
def GetArch(self):
return self._parent.GetArch()
def Destroy(self):
self._pcdItem.DeRef(self._parent)
self._infObj = None
def GetBuildObj(self):
platformInfos = self._parent.GetPlatform().GetPcdBuildObjs(self._name, self.GetArch())
modulePcdType = self._infObj.GetPcdType()
# if platform do not gives pcd's value, get default value from package
if len(platformInfos) == 0:
if modulePcdType.lower() == 'pcd':
return self._pcdItem.GetDecObject()
else:
for obj in self._pcdItem.GetDecObjects():
if modulePcdType not in self._type_mapping.keys():
ErrorMsg("Invalid PCD type %s" % modulePcdType)
return None
if self._type_mapping[modulePcdType] == obj.GetPcdType():
return obj
ErrorMsg ('Module PCD type %s does not in valied range [%s] in package!' % \
(modulePcdType))
else:
if modulePcdType.lower() == 'pcd':
if len(platformInfos) > 1:
WarnMsg("Find more than one value for PCD %s in platform %s" % \
(self._name, self._parent.GetPlatform().GetFilename()))
return platformInfos[0]
else:
for obj in platformInfos:
if modulePcdType not in self._type_mapping.keys():
ErrorMsg("Invalid PCD type %s" % modulePcdType)
return None
if self._type_mapping[modulePcdType] == obj.GetPcdType():
return obj
ErrorMsg('Can not find value for pcd %s in pcd type %s' % \
(self._name, modulePcdType))
return None
class SurfaceItem(object):
_objs = {}
def __new__(cls, *args, **kwargs):
"""Maintain only a single instance of this object
@return: instance of this class
"""
name = args[0]
parent = args[1]
fileObj = args[2]
if issubclass(parent.__class__, Package):
if name in cls._objs.keys():
ErrorMsg("%s item is duplicated defined in packages: %s and %s" %
(name, parent.GetFilename(), cls._objs[name].GetParent().GetFilename()))
return None
obj = object.__new__(cls, *args, **kwargs)
cls._objs[name] = obj
return obj
elif issubclass(parent.__class__, Module):
if name not in cls._objs.keys():
ErrorMsg("%s item does not defined in any package! It is used by module %s" % \
(name, parent.GetFilename()))
return None
return cls._objs[name]
return None
def __init__(self, name, parent, fileObj):
if issubclass(parent.__class__, Package):
self._name = name
self._parent = parent
self._decObj = [fileObj]
self._refMods = {}
else:
self.RefModule(parent, fileObj)
@classmethod
def GetObjectDict(cls):
return cls._objs
def GetParent(self):
return self._parent
def GetReference(self):
return self._refMods
def RefModule(self, mObj, infObj):
if mObj in self._refMods.keys():
return
self._refMods[mObj] = infObj
def DeRef(self, mObj):
if mObj not in self._refMods.keys():
WarnMsg("%s is not referenced by module %s" % (self._name, mObj.GetFilename()))
return
del self._refMods[mObj]
def Destroy(self):
self._refMods.clear()
cls = self.__class__
del cls._objs[self._name]
def GetName(self):
return self._name
def GetDecObject(self):
return self._decObj[0]
def GetDecObjects(self):
return self._decObj
class PcdItem(SurfaceItem):
def AddDecObj(self, fileObj):
for decObj in self._decObj:
if decObj.GetFilename() != fileObj.GetFilename():
ErrorMsg("Pcd %s defined in more than one packages : %s and %s" % \
(self._name, decObj.GetFilename(), fileObj.GetFilename()))
return
if decObj.GetPcdType() == fileObj.GetPcdType() and \
decObj.GetArch().lower() == fileObj.GetArch():
ErrorMsg("Pcd %s is duplicated defined in pcd type %s in package %s" % \
(self._name, decObj.GetPcdType(), decObj.GetFilename()))
return
self._decObj.append(fileObj)
def GetValidPcdType(self):
types = []
for obj in self._decObj:
if obj.GetPcdType() not in types:
types += obj.GetPcdType()
return types
class GuidItem(SurfaceItem):
pass
class PpiItem(SurfaceItem):
pass
class ProtocolItem(SurfaceItem):
pass

View File

@ -0,0 +1,319 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#
import plugins.EdkPlugins.basemodel.ini as ini
import re, os
from plugins.EdkPlugins.basemodel.message import *
class DECFile(ini.BaseINIFile):
def GetSectionInstance(self, parent, name, isCombined=False):
return DECSection(parent, name, isCombined)
def GetComponents(self):
return self.GetSectionByName('Components')
def GetPackageRootPath(self):
return os.path.dirname(self.GetFilename()).strip()
def GetBaseName(self):
return self.GetDefine("PACKAGE_NAME").strip()
def GetVersion(self):
return self.GetDefine("PACKAGE_VERSION").strip()
def GetSectionObjectsByName(self, name, arch=None):
arr = []
sects = self.GetSectionByName(name)
for sect in sects:
# skip unmatched archtecture content
if not sect.IsArchMatch(arch):
continue
for obj in sect.GetObjects():
arr.append(obj)
return arr
class DECSection(ini.BaseINISection):
def GetSectionINIObject(self, parent):
type = self.GetType()
if type.lower().find('defines') != -1:
return DECDefineSectionObject(self)
if type.lower().find('includes') != -1:
return DECIncludeObject(self)
if type.lower().find('pcd') != -1:
return DECPcdObject(self)
if type.lower() == 'libraryclasses':
return DECLibraryClassObject(self)
if type.lower() == 'guids':
return DECGuidObject(self)
if type.lower() == 'ppis':
return DECPpiObject(self)
if type.lower() == 'protocols':
return DECProtocolObject(self)
return DECSectionObject(self)
def GetType(self):
arr = self._name.split('.')
return arr[0].strip()
def GetArch(self):
arr = self._name.split('.')
if len(arr) == 1:
return 'common'
return arr[1]
def IsArchMatch(self, arch):
if arch == None or self.GetArch() == 'common':
return True
if self.GetArch().lower() != arch.lower():
return False
return True
class DECSectionObject(ini.BaseINISectionObject):
def GetArch(self):
return self.GetParent().GetArch()
class DECDefineSectionObject(DECSectionObject):
def __init__(self, parent):
DECSectionObject.__init__(self, parent)
self._key = None
self._value = None
def Parse(self):
assert (self._start == self._end), 'The object in define section must be in single line'
line = self.GetLineByOffset(self._start).strip()
line = line.split('#')[0]
arr = line.split('=')
if len(arr) != 2:
ErrorMsg('Invalid define section object',
self.GetFilename(),
self.GetParent().GetName()
)
return False
self._key = arr[0].strip()
self._value = arr[1].strip()
return True
def GetKey(self):
return self._key
def GetValue(self):
return self._value
class DECGuidObject(DECSectionObject):
_objs = {}
def __init__(self, parent):
DECSectionObject.__init__(self, parent)
self._name = None
def Parse(self):
line = self.GetLineByOffset(self._start).strip().split('#')[0]
self._name = line.split('=')[0].strip()
self._guid = line.split('=')[1].strip()
objdict = DECGuidObject._objs
if self._name not in objdict.keys():
objdict[self._name] = [self]
else:
objdict[self._name].append(self)
return True
def GetName(self):
return self._name
def GetGuid(self):
return self._guid
def Destroy(self):
objdict = DECGuidObject._objs
objdict[self._name].remove(self)
if len(objdict[self._name]) == 0:
del objdict[self._name]
@staticmethod
def GetObjectDict():
return DECGuidObject._objs
class DECPpiObject(DECSectionObject):
_objs = {}
def __init__(self, parent):
DECSectionObject.__init__(self, parent)
self._name = None
def Parse(self):
line = self.GetLineByOffset(self._start).strip().split('#')[0]
self._name = line.split('=')[0].strip()
self._guid = line.split('=')[1].strip()
objdict = DECPpiObject._objs
if self._name not in objdict.keys():
objdict[self._name] = [self]
else:
objdict[self._name].append(self)
return True
def GetName(self):
return self._name
def GetGuid(self):
return self._guid
def Destroy(self):
objdict = DECPpiObject._objs
objdict[self._name].remove(self)
if len(objdict[self._name]) == 0:
del objdict[self._name]
@staticmethod
def GetObjectDict():
return DECPpiObject._objs
class DECProtocolObject(DECSectionObject):
_objs = {}
def __init__(self, parent):
DECSectionObject.__init__(self, parent)
self._name = None
def Parse(self):
line = self.GetLineByOffset(self._start).strip().split('#')[0]
self._name = line.split('=')[0].strip()
self._guid = line.split('=')[1].strip()
objdict = DECProtocolObject._objs
if self._name not in objdict.keys():
objdict[self._name] = [self]
else:
objdict[self._name].append(self)
return True
def GetName(self):
return self._name
def GetGuid(self):
return self._guid
def Destroy(self):
objdict = DECProtocolObject._objs
objdict[self._name].remove(self)
if len(objdict[self._name]) == 0:
del objdict[self._name]
@staticmethod
def GetObjectDict():
return DECProtocolObject._objs
class DECLibraryClassObject(DECSectionObject):
_objs = {}
def __init__(self, parent):
DECSectionObject.__init__(self, parent)
self.mClassName = None
self.mHeaderFile = None
def Parse(self):
line = self.GetLineByOffset(self._start).strip().split('#')[0]
self.mClassName, self.mHeaderFile = line.split('|')
objdict = DECLibraryClassObject._objs
if self.mClassName not in objdict.keys():
objdict[self.mClassName] = [self]
else:
objdict[self.mClassName].append(self)
return True
def GetClassName(self):
return self.mClassName
def GetName(self):
return self.mClassName
def GetHeaderFile(self):
return self.mHeaderFile
def Destroy(self):
objdict = DECLibraryClassObject._objs
objdict[self.mClassName].remove(self)
if len(objdict[self.mClassName]) == 0:
del objdict[self.mClassName]
@staticmethod
def GetObjectDict():
return DECLibraryClassObject._objs
class DECIncludeObject(DECSectionObject):
def __init__(self, parent):
DECSectionObject.__init__(self, parent)
def GetPath(self):
return self.GetLineByOffset(self._start).split('#')[0].strip()
class DECPcdObject(DECSectionObject):
_objs = {}
def __init__(self, parent):
DECSectionObject.__init__(self, parent)
self.mPcdName = None
self.mPcdDefaultValue = None
self.mPcdDataType = None
self.mPcdToken = None
def Parse(self):
line = self.GetLineByOffset(self._start).strip().split('#')[0]
(self.mPcdName, self.mPcdDefaultValue, self.mPcdDataType, self.mPcdToken) = line.split('|')
objdict = DECPcdObject._objs
if self.mPcdName not in objdict.keys():
objdict[self.mPcdName] = [self]
else:
objdict[self.mPcdName].append(self)
return True
def Destroy(self):
objdict = DECPcdObject._objs
objdict[self.mPcdName].remove(self)
if len(objdict[self.mPcdName]) == 0:
del objdict[self.mPcdName]
def GetPcdType(self):
return self.GetParent().GetType()
def GetPcdName(self):
return self.mPcdName
def GetPcdValue(self):
return self.mPcdDefaultValue
def GetPcdDataType(self):
return self.mPcdDataType
def GetPcdToken(self):
return self.mPcdToken
def GetName(self):
return self.GetPcdName().split('.')[1]
@staticmethod
def GetObjectDict():
return DECPcdObject._objs

View File

@ -0,0 +1,201 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#
import plugins.EdkPlugins.basemodel.ini as ini
import re, os
from plugins.EdkPlugins.basemodel.message import *
class DSCFile(ini.BaseINIFile):
def GetSectionInstance(self, parent, name, isCombined=False):
return DSCSection(parent, name, isCombined)
def GetComponents(self):
return self.GetSectionObjectsByName('Components')
class DSCSection(ini.BaseINISection):
def GetSectionINIObject(self, parent):
type = self.GetType()
if type.lower() == 'components':
return DSCComponentObject(self)
if type.lower() == 'libraryclasses':
return DSCLibraryClassObject(self)
if type.lower() == 'defines':
return ini.BaseINISectionObject(self)
if type.lower() == 'pcdsfeatureflag' or \
type.lower() == 'pcdsfixedatbuild' or \
type.lower() == 'pcdspatchableinmodule' or\
type.lower() == 'pcdsdynamicdefault' or \
type.lower() == 'pcdsdynamicex' or \
type.lower() == 'pcdsdynamichii' or \
type.lower() == 'pcdsdynamicvpd':
return DSCPcdObject(self)
return DSCSectionObject(self)
def GetType(self):
arr = self._name.split('.')
return arr[0].strip()
def GetArch(self):
arr = self._name.split('.')
if len(arr) == 1:
return 'common'
return arr[1]
def GetModuleType(self):
arr = self._name.split('.')
if len(arr) < 3:
return 'common'
return arr[2]
class DSCSectionObject(ini.BaseINISectionObject):
def GetArch(self):
return self.GetParent().GetArch()
class DSCPcdObject(DSCSectionObject):
def __init__(self, parent):
ini.BaseINISectionObject.__init__(self, parent)
self._name = None
def Parse(self):
line = self.GetLineByOffset(self._start).strip().split('#')[0]
self._name = line.split('|')[0]
self._value = line.split('|')[1]
return True
def GetPcdName(self):
return self._name
def GetPcdType(self):
return self.GetParent().GetType()
def GetPcdValue(self):
return self._value
class DSCLibraryClassObject(DSCSectionObject):
def __init__(self, parent):
ini.BaseINISectionObject.__init__(self, parent)
def GetClass(self):
line = self.GetLineByOffset(self._start)
return line.split('#')[0].split('|')[0].strip()
def GetInstance(self):
line = self.GetLineByOffset(self._start)
return line.split('#')[0].split('|')[1].strip()
def GetArch(self):
return self.GetParent().GetArch()
def GetModuleType(self):
return self.GetParent().GetModuleType()
class DSCComponentObject(DSCSectionObject):
def __init__(self, parent):
ini.BaseINISectionObject.__init__(self, parent)
self._OveridePcds = {}
self._OverideLibraries = {}
self._Filename = ''
def __del__(self):
self._OverideLibraries.clear()
self._OverideLibraries.clear()
ini.BaseINISectionObject.__del__(self)
def AddOverideLib(self, libclass, libinstPath):
if libclass not in self._OverideLibraries.keys():
self._OverideLibraries[libclass] = libinstPath
def AddOveridePcd(self, name, type, value=None):
if type not in self._OveridePcds.keys():
self._OveridePcds[type] = []
self._OveridePcds[type].append((name, value))
def GetOverideLibs(self):
return self._OverideLibraries
def GetArch(self):
return self.GetParent().GetArch()
def GetOveridePcds(self):
return self._OveridePcds
def GetFilename(self):
return self.GetLineByOffset(self._start).split('#')[0].split('{')[0].strip()
def SetFilename(self, fName):
self._Filename = fName
def Parse(self):
if (self._start < self._end):
#
# The first line is inf path and could be ignored
# The end line is '}' and could be ignored
#
curr = self._start + 1
end = self._end - 1
OverideName = ''
while (curr <= end):
line = self.GetLineByOffset(curr).strip()
if len(line) > 0 and line[0] != '#':
line = line.split('#')[0].strip()
if line[0] == '<':
OverideName = line[1:len(line)-1]
elif OverideName.lower() == 'libraryclasses':
arr = line.split('|')
self._OverideLibraries[arr[0].strip()] = arr[1].strip()
elif OverideName.lower() == 'pcds':
ErrorMsg('EDES does not support PCD overide',
self.GetFileName(),
self.GetParent().GetLinenumberByOffset(curr))
curr = curr + 1
return True
def GenerateLines(self):
lines = []
hasLib = False
hasPcd = False
if len(self._OverideLibraries) != 0:
hasLib = True
if len(self._OveridePcds) != 0:
hasPcd = True
if hasLib or hasPcd:
lines.append((' %s {\n' % self._Filename))
else:
lines.append((' %s \n' % self._Filename))
return lines
if hasLib:
lines.append(' <LibraryClasses>\n')
for libKey in self._OverideLibraries.keys():
lines.append(' %s|%s\n' % (libKey, self._OverideLibraries[libKey]))
if hasPcd:
for key in self._OveridePcds.keys():
lines.append(' <%s>\n' % key)
for name, value in self._OveridePcds[key]:
if value != None:
lines.append(' %s|%s\n' % (name, value))
else:
lines.append(' %s\n' % name)
if hasLib or hasPcd:
lines.append(' }\n')
return lines

View File

@ -0,0 +1,341 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#
import plugins.EdkPlugins.basemodel.ini as ini
import re, os
from plugins.EdkPlugins.basemodel.message import *
class INFFile(ini.BaseINIFile):
_libobjs = {}
def GetSectionInstance(self, parent, name, isCombined=False):
return INFSection(parent, name, isCombined)
def GetProduceLibraryClass(self):
obj = self.GetDefine("LIBRARY_CLASS")
if obj == None: return None
return obj.split('|')[0].strip()
def GetSectionObjectsByName(self, name, arch=None):
arr = []
sects = self.GetSectionByName(name)
for sect in sects:
# skip unmatched archtecture content
if not sect.IsArchMatch(arch):
continue
for obj in sect.GetObjects():
arr.append(obj)
return arr
def GetSourceObjects(self, arch=None, tool=None):
arr = []
sects = self.GetSectionByName('sources')
for sect in sects:
# skip unmatched archtecture content
if not sect.IsArchMatch(arch):
continue
for obj in sect.GetObjects():
if not obj.IsMatchFamily(tool):
continue
arr.append(obj)
return arr
def Parse(self):
if not ini.BaseINIFile.Parse(self):
return False
classname = self.GetProduceLibraryClass()
if classname != None:
libobjdict = INFFile._libobjs
if libobjdict.has_key(classname):
if self not in libobjdict[classname]:
libobjdict[classname].append(self)
else:
libobjdict[classname] = [self]
return True
def GetBaseName(self):
return self.GetDefine("BASE_NAME").strip()
def GetModuleRootPath(self):
return os.path.dirname(self.GetFilename())
def Clear(self):
classname = self.GetProduceLibraryClass()
if classname != None:
libobjdict = INFFile._libobjs
libobjdict[classname].remove(self)
if len(libobjdict[classname]) == 0:
del libobjdict[classname]
ini.BaseINIFile.Clear(self)
class INFSection(ini.BaseINISection):
def GetSectionINIObject(self, parent):
type = self.GetType()
if type.lower() == 'libraryclasses':
return INFLibraryClassObject(self)
if type.lower() == 'sources':
return INFSourceObject(self)
if type.lower().find('pcd') != -1:
return INFPcdObject(self)
if type.lower() == 'packages':
return INFDependentPackageObject(self)
if type.lower() in ['guids', 'protocols', 'ppis']:
return INFGuidObject(self)
if type.lower() == 'defines':
return INFDefineSectionObject(self)
return INFSectionObject(self)
def GetType(self):
arr = self._name.split('.')
return arr[0].strip()
def GetArch(self):
arr = self._name.split('.')
if len(arr) == 1:
return 'common'
return arr[1]
def IsArchMatch(self, arch):
if arch == None or self.GetArch() == 'common':
return True
if self.GetArch().lower() != arch.lower():
return False
return True
class INFSectionObject(ini.BaseINISectionObject):
def GetArch(self):
return self.GetParent().GetArch()
class INFDefineSectionObject(INFSectionObject):
def __init__(self, parent):
INFSectionObject.__init__(self, parent)
self._key = None
self._value = None
def Parse(self):
assert (self._start == self._end), 'The object in define section must be in single line'
line = self.GetLineByOffset(self._start).strip()
line = line.split('#')[0]
arr = line.split('=')
if len(arr) != 2:
ErrorMsg('Invalid define section object',
self.GetFilename(),
self._start
)
return False
self._key = arr[0].strip()
self._value = arr[1].strip()
return True
def GetKey(self):
return self._key
def GetValue(self):
return self._value
class INFLibraryClassObject(INFSectionObject):
_objs = {}
def __init__(self, parent):
INFSectionObject.__init__(self, parent)
self._classname = None
def GetClass(self):
return self._classname
def Parse(self):
self._classname = self.GetLineByOffset(self._start).split('#')[0].strip()
objdict = INFLibraryClassObject._objs
if objdict.has_key(self._classname):
objdict[self._classname].append(self)
else:
objdict[self._classname] = [self]
return True
def Destroy(self):
objdict = INFLibraryClassObject._objs
objdict[self._classname].remove(self)
if len(objdict[self._classname]) == 0:
del objdict[self._classname]
def GetName(self):
return self._classname
@staticmethod
def GetObjectDict():
return INFLibraryClassObject._objs
class INFDependentPackageObject(INFSectionObject):
def GetPath(self):
return self.GetLineByOffset(self._start).split('#')[0].strip()
class INFSourceObject(INFSectionObject):
_objs = {}
def __init__(self, parent):
INFSectionObject.__init__(self, parent)
self.mSourcename = None
self.mToolCode = None
self.mFamily = None
self.mTagName = None
self.mFeaturePcd = None
self.mFilename = None
def GetSourcePath(self):
return self.mSourcename
def GetSourceFullPath(self):
path = os.path.dirname(self.GetFilename())
path = os.path.join(path, self.GetSourcePath())
return os.path.normpath(path)
def GetToolCode(self):
return self.mToolCode
def GetFamily(self):
return self.mFamily
def GetTagName(self):
return self.mTagName
def GetFeaturePcd(self):
return self.mFeaturePcd
def Parse(self):
line = self.GetLineByOffset(self._start).strip().split('#')[0]
arr = line.split('|')
self.mSourcename = arr[0].strip()
if len(arr) >= 2:
self.mFamily = arr[1].strip()
if len(arr) >= 3:
self.mTagName = arr[2].strip()
if len(arr) >= 4:
self.mToolCode = arr[3].strip()
if len(arr) >= 5:
self.mFeaturePcd = arr[4].strip()
self.mFilename = os.path.basename(self.GetSourceFullPath())
objdict = INFSourceObject._objs
if not objdict.has_key(self.mFilename):
objdict[self.mFilename] = [self]
else:
objdict[self.mFilename].append(self)
return True
def GetName(self):
return self.mFilename
def Destroy(self):
objdict = INFSourceObject._objs
objdict[self.mFilename].remove(self)
if len(objdict[self.mFilename]) == 0:
del objdict[self.mFilename]
def IsMatchFamily(self, family):
if family == None:
return True
if self.mFamily != None:
if family.strip().lower() == self.mFamily.lower():
return True
else:
return False
else:
fname = self.GetSourcePath()
if fname.endswith('.S') and family.lower() != 'gcc':
return False
if fname.endswith('.s') and (self.GetArch().lower() != 'ipf' and self.GetArch().lower() != 'common'):
return False
if fname.lower().endswith('.asm') and (family.lower() != 'msft' and family.lower() != 'intel'):
return False
return True
@staticmethod
def GetObjectDict():
return INFSourceObject._objs
class INFPcdObject(INFSectionObject):
_objs = {}
def __init__(self, parent):
INFSectionObject.__init__(self, parent)
self.mPcdType = None
self.mDefaultValue = None
self.mPcdName = None
@staticmethod
def GetObjectDict():
return INFPcdObject._objs
def Parse(self):
line = self.GetLineByOffset(self._start).strip().split('#')[0]
arr = line.split('|')
self.mPcdName = arr[0].strip()
if len(arr) >= 2:
self.mDefaultValue = arr[1].strip()
objdict = INFPcdObject._objs
if objdict.has_key(self.GetName()):
if self not in objdict[self.GetName()]:
objdict[self.GetName()].append(self)
else:
objdict[self.GetName()] = [self]
return True
def GetPcdName(self):
return self.mPcdName
def GetPcdType(self):
return self.GetParent().GetType()
def GetName(self):
return self.mPcdName.split('.')[1]
def Destroy(self):
objdict = INFPcdObject._objs
objdict[self.GetName()].remove(self)
if len(objdict[self.GetName()]) == 0:
del objdict[self.GetName()]
class INFGuidObject(INFSectionObject):
def __init__(self, parent):
INFSectionObject.__init__(self, parent)
self._name = None
def Parse(self):
line = self.GetLineByOffset(self._start).strip().split('#')[0].split("|")[0]
self._name = line.strip()
return True
def GetName(self):
return self._name

View File

@ -0,0 +1,12 @@
## @file
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
# 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.
#

View File

@ -11,7 +11,7 @@
# must ensure that files that are required by the cx_freeze frozen binaries are
# present in the Bin\Win32 directory.
#
# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available under
# the terms and conditions of the BSD License which accompanies this distribution.
@ -59,6 +59,7 @@ UPT.exe
VfrCompile.exe
VolInfo.exe
Pkcs7Sign.exe
DevicePath.exe
[ExtraFiles.Win32]
TestSigningPrivateKey.pem

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'BootSectImage' module build.
#
# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = BootSectImage

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'Brotli' module build.
#
# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = Brotli

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/** @file
Common library assistance routines.
Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -17,10 +17,30 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Common/UefiBaseTypes.h>
#include <Common/BuildVersion.h>
#include <assert.h>
#define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination
#define MAX_LONG_FILE_PATH 500
#define MAX_UINTN MAX_ADDRESS
#define MAX_UINT64 ((UINT64)0xFFFFFFFFFFFFFFFFULL)
#define MAX_UINT16 ((UINT16)0xFFFF)
#define MAX_UINT8 ((UINT8)0xFF)
#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0]))
#define ASCII_RSIZE_MAX 1000000
#undef RSIZE_MAX
#define RSIZE_MAX 1000000
#define IS_COMMA(a) ((a) == L',')
#define IS_HYPHEN(a) ((a) == L'-')
#define IS_DOT(a) ((a) == L'.')
#define IS_LEFT_PARENTH(a) ((a) == L'(')
#define IS_RIGHT_PARENTH(a) ((a) == L')')
#define IS_SLASH(a) ((a) == L'/')
#define IS_NULL(a) ((a) == L'\0')
#define ASSERT(x) assert(x)
#ifdef __cplusplus
extern "C" {
#endif
@ -149,6 +169,285 @@ CHAR8 *
LongFilePath (
IN CHAR8 *FileName
);
UINTN
StrLen (
CONST CHAR16 *String
);
VOID *
AllocateCopyPool (
UINTN AllocationSize,
CONST VOID *Buffer
);
INTN
StrnCmp (
CONST CHAR16 *FirstString,
CONST CHAR16 *SecondString,
UINTN Length
);
RETURN_STATUS
StrToGuid (
CONST CHAR16 *String,
EFI_GUID *Guid
);
RETURN_STATUS
StrHexToBytes (
CONST CHAR16 *String,
UINTN Length,
UINT8 *Buffer,
UINTN MaxBufferSize
);
UINTN
InternalHexCharToUintn (
CHAR16 Char
);
VOID *
InternalAllocateCopyPool (
UINTN AllocationSize,
CONST VOID *Buffer
);
BOOLEAN
InternalIsDecimalDigitCharacter (
CHAR16 Char
);
UINT32
SwapBytes32 (
UINT32 Value
);
UINT16
SwapBytes16 (
UINT16 Value
);
EFI_GUID *
CopyGuid (
EFI_GUID *DestinationGuid,
CONST EFI_GUID *SourceGuid
);
UINT64
WriteUnaligned64 (
UINT64 *Buffer,
UINT64 Value
);
UINT64
ReadUnaligned64 (
CONST UINT64 *Buffer
);
UINTN
StrSize (
CONST CHAR16 *String
);
UINTN
StrHexToUintn (
CONST CHAR16 *String
);
UINTN
StrDecimalToUintn (
CONST CHAR16 *String
);
UINT64
StrHexToUint64 (
CONST CHAR16 *String
);
UINT64
StrDecimalToUint64 (
CONST CHAR16 *String
);
RETURN_STATUS
StrHexToUint64S (
CONST CHAR16 *String,
CHAR16 **EndPointer,
UINT64 *Data
);
RETURN_STATUS
StrHexToUintnS (
CONST CHAR16 *String,
CHAR16 **EndPointer, OPTIONAL
UINTN *Data
);
RETURN_STATUS
StrDecimalToUint64S (
CONST CHAR16 *String,
CHAR16 **EndPointer, OPTIONAL
UINT64 *Data
);
RETURN_STATUS
StrDecimalToUintnS (
CONST CHAR16 *String,
CHAR16 **EndPointer, OPTIONAL
UINTN *Data
);
VOID *
ReallocatePool (
UINTN OldSize,
UINTN NewSize,
VOID *OldBuffer OPTIONAL
);
VOID *
InternalReallocatePool (
UINTN OldSize,
UINTN NewSize,
VOID *OldBuffer OPTIONAL
);
VOID *
InternalAllocateZeroPool (
UINTN AllocationSize
) ;
VOID *
InternalAllocatePool (
UINTN AllocationSize
);
UINTN
StrnLenS (
CONST CHAR16 *String,
UINTN MaxSize
);
CHAR16
InternalCharToUpper (
CHAR16 Char
);
INTN
StrCmp (
CONST CHAR16 *FirstString,
CONST CHAR16 *SecondString
);
UINT64
SwapBytes64 (
UINT64 Value
);
UINT64
InternalMathSwapBytes64 (
UINT64 Operand
);
RETURN_STATUS
StrToIpv4Address (
CONST CHAR16 *String,
CHAR16 **EndPointer,
EFI_IPv4_ADDRESS *Address,
UINT8 *PrefixLength
);
RETURN_STATUS
StrToIpv6Address (
CONST CHAR16 *String,
CHAR16 **EndPointer,
EFI_IPv6_ADDRESS *Address,
UINT8 *PrefixLength
);
RETURN_STATUS
StrCpyS (
CHAR16 *Destination,
UINTN DestMax,
CONST CHAR16 *Source
);
RETURN_STATUS
UnicodeStrToAsciiStrS (
CONST CHAR16 *Source,
CHAR8 *Destination,
UINTN DestMax
);
VOID *
AllocatePool (
UINTN AllocationSize
);
UINT16
WriteUnaligned16 (
UINT16 *Buffer,
UINT16 Value
);
UINT16
ReadUnaligned16 (
CONST UINT16 *Buffer
);
VOID *
AllocateZeroPool (
UINTN AllocationSize
);
BOOLEAN
InternalIsHexaDecimalDigitCharacter (
CHAR16 Char
);
BOOLEAN
InternalSafeStringIsOverlap (
IN VOID *Base1,
IN UINTN Size1,
IN VOID *Base2,
IN UINTN Size2
);
BOOLEAN
InternalSafeStringNoStrOverlap (
IN CHAR16 *Str1,
IN UINTN Size1,
IN CHAR16 *Str2,
IN UINTN Size2
);
BOOLEAN
IsHexStr (
CHAR16 *Str
);
UINTN
Strtoi (
CHAR16 *Str
);
VOID
Strtoi64 (
CHAR16 *Str,
UINT64 *Data
);
VOID
StrToAscii (
CHAR16 *Str,
CHAR8 **AsciiStr
);
CHAR16 *
SplitStr (
CHAR16 **List,
CHAR16 Separator
);
/*++
Routine Description:
@ -166,8 +465,6 @@ Returns:
}
#endif
#define ASSERT(x) assert(x)
#ifdef __GNUC__
#include <stdio.h>
#include <sys/stat.h>

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'Common' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
# VPATH = ..

View File

@ -1,7 +1,7 @@
/** @file
This file contains the PcdValue structure definition.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -72,6 +72,9 @@ Returns:
CHAR8 *Token;
Token = malloc (TokenEnd - TokenStart + 1);
if (Token == NULL) {
return;
}
memcpy (Token, &FileBuffer[TokenStart], TokenEnd - TokenStart);
Token[TokenEnd - TokenStart] = 0;
switch (TokenIndex) {
@ -106,6 +109,9 @@ Returns:
case 5:
PcdList[PcdIndex].Value = Token;
break;
default:
free (Token);
break;
}
}
@ -266,11 +272,7 @@ Returns:
sprintf(PcdList[Index].Value, "0x%08x", (UINT32)(Value & 0xffffffff));
break;
case PcdDataTypeUint64:
#ifdef __GNUC__
sprintf(PcdList[Index].Value, "0x%016lx", Value);
#else
sprintf(PcdList[Index].Value, "0x%016llx", Value);
#endif
sprintf(PcdList[Index].Value, "0x%016llx", (unsigned long long)Value);
break;
case PcdDataTypePointer:
fprintf (stderr, "PCD %s.%s.%s.%s is structure. Use PcdSetPtr()\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
@ -310,7 +312,6 @@ Returns:
CHAR8 *Value;
UINT8 *Buffer;
CHAR8 *End;
UINT8 Byte;
Index = LookupPcdIndex (SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
if (Index < 0) {
@ -328,12 +329,14 @@ Returns:
break;
case PcdDataTypePointer:
Value = &PcdList[Index].Value[1];
printf ("Value = %s\n", PcdList[Index].Value);
for (*Size = 0, Byte = (UINT8) strtoul(Value, &End, 16); Value != End; Byte = (UINT8) strtoul(Value, &End, 16), *Size = *Size + 1) {
printf("%x\n", Byte);
for (*Size = 0, strtoul(Value, &End, 16); Value != End; strtoul(Value, &End, 16), *Size = *Size + 1) {
Value = End + 1;
}
Buffer = malloc(*Size);
Buffer = malloc(*Size + 1);
if (Buffer == NULL) {
*Size = 0;
return NULL;
}
Value = &PcdList[Index].Value[1];
for (*Size = 0, Buffer[*Size] = (UINT8) strtoul(Value, &End, 16); Value != End; *Size = *Size + 1, Buffer[*Size] = (UINT8) strtoul(Value, &End, 16)) {
Value = End + 1;
@ -395,7 +398,6 @@ Returns:
PcdList[Index].Value = malloc(Size * 5 + 3);
PcdList[Index].Value[0] = '{';
for (ValueIndex = 0; ValueIndex < Size; ValueIndex++) {
printf("Value[%d] = %02x\n", ValueIndex, Value[ValueIndex]);
sprintf(&PcdList[Index].Value[1 + ValueIndex * 5], "0x%02x,", Value[ValueIndex]);
}
PcdList[Index].Value[1 + Size * 5 - 1] = '}';
@ -718,15 +720,11 @@ Returns:
if (*InputFileName == NULL) {
fprintf (stderr, "Missing option. Input files is not specified\n");
exit (EXIT_FAILURE);
} else {
printf ("Input file name is %s\n", *InputFileName);
}
if (*OutputFileName == NULL) {
fprintf (stderr, "Missing option. Output file is not specified\n");
exit (EXIT_FAILURE);
} else {
printf ("Output file name is %s\n", *OutputFileName);
}
}
@ -755,7 +753,6 @@ Returns:
UINT8 *FileBuffer;
UINT32 FileSize;
printf ("PCD tool start.\n");
InputFileName = NULL;
OutputFileName = NULL;
@ -784,7 +781,5 @@ Returns:
//
WriteOutputFile (OutputFileName);
printf ("PCD tool done.\n");
exit (EXIT_SUCCESS);
}

View File

@ -0,0 +1,200 @@
/** @file
Definition for Device Path Tool.
Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
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 "UefiDevicePathLib.h"
//
// Utility Name
//
#define UTILITY_NAME "DevicePath"
//
// Utility version information
//
#define UTILITY_MAJOR_VERSION 0
#define UTILITY_MINOR_VERSION 1
EFI_GUID gEfiDebugPortDevicePathGuid = DEVICE_PATH_MESSAGING_DEBUGPORT;
EFI_GUID gEfiPcAnsiGuid = EFI_PC_ANSI_GUID;
EFI_GUID gEfiVT100Guid = EFI_VT_100_GUID;
EFI_GUID gEfiVT100PlusGuid = EFI_VT_100_PLUS_GUID;
EFI_GUID gEfiVTUTF8Guid = EFI_VT_UTF8_GUID;
EFI_GUID gEfiUartDevicePathGuid = EFI_UART_DEVICE_PATH_GUID;
EFI_GUID gEfiSasDevicePathGuid = EFI_SAS_DEVICE_PATH_GUID;
EFI_GUID gEfiVirtualDiskGuid = EFI_VIRTUAL_DISK_GUID;
EFI_GUID gEfiVirtualCdGuid = EFI_VIRTUAL_CD_GUID;
EFI_GUID gEfiPersistentVirtualDiskGuid = EFI_PERSISTENT_VIRTUAL_DISK_GUID;
EFI_GUID gEfiPersistentVirtualCdGuid = EFI_PERSISTENT_VIRTUAL_CD_GUID;
STATIC
VOID
Version (
VOID
)
/*++
Routine Description:
Displays the standard utility information to SDTOUT
Arguments:
None
Returns:
None
--*/
{
fprintf (stdout, "%s Version %d.%d %s \n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
}
STATIC
VOID
Usage (
VOID
)
/*++
Routine Description:
Displays the utility usage syntax to STDOUT
Arguments:
None
Returns:
None
--*/
{
//
// Summary usage
//
fprintf (stdout, "\nUsage: %s [options]\n\n", UTILITY_NAME);
//
// Copyright declaration
//
fprintf (stdout, "Copyright (c) 2017, Intel Corporation. All rights reserved.\n\n");
//
// Details Option
//
fprintf (stdout, "Options:\n");
fprintf (stdout, " DevicePathString Device Path string is specified, no space character.\n"
" Example: \"PciRoot(0)/Pci(0,0)\"\n");
fprintf (stdout, " --version Show program's version number and exit.\n");
fprintf (stdout, " -h, --help Show this help message and exit.\n");
}
STATIC
VOID
PrintMem (
CONST VOID *Buffer,
UINTN Count
)
{
CONST UINT8 *Bytes;
UINTN Idx;
Bytes = Buffer;
for (Idx = 0; Idx < Count; Idx++) {
printf("0x%02x ", Bytes[Idx]);
}
}
VOID
Ascii2UnicodeString (
CHAR8 *String,
CHAR16 *UniString
)
/*++
Routine Description:
Write ascii string as unicode string format to FILE
Arguments:
String - Pointer to string that is written to FILE.
UniString - Pointer to unicode string
Returns:
NULL
--*/
{
while (*String != '\0') {
*(UniString++) = (CHAR16) *(String++);
}
//
// End the UniString with a NULL.
//
*UniString = '\0';
}
int main(int argc, CHAR8 *argv[])
{
CHAR8 * Str;
CHAR16* Str16;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
if (argc == 1) {
Error (NULL, 0, 1001, "Missing options", "No input options specified.");
Usage ();
return STATUS_ERROR;
}
if ((stricmp (argv[1], "-h") == 0) || (stricmp (argv[1], "--help") == 0)) {
Version ();
Usage ();
return STATUS_SUCCESS;
}
if (stricmp (argv[1], "--version") == 0) {
Version ();
return STATUS_SUCCESS;
}
Str = argv[1];
if (Str == NULL) {
fprintf(stderr, "Invalid option value, Device Path can't be NULL");
return STATUS_ERROR;
}
Str16 = (CHAR16 *)malloc(1024);
if (Str16 == NULL) {
fprintf(stderr, "Resource, memory cannot be allcoated");
return STATUS_ERROR;
}
Ascii2UnicodeString(Str, Str16);
DevicePath = UefiDevicePathLibConvertTextToDevicePath(Str16);
if (DevicePath == NULL) {
fprintf(stderr, "Convert fail, Cannot convert text to a device path");
free(Str16);
return STATUS_ERROR;
}
while (!((DevicePath->Type == END_DEVICE_PATH_TYPE) && (DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)) )
{
PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8);
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)DevicePath + (DevicePath->Length[0] | DevicePath->Length[1] << 8));
}
PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8);
putchar('\n');
free(Str16);
return STATUS_SUCCESS;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,875 @@
/** @file
Device Path services. The thing to remember is device paths are built out of
nodes. The device path is terminated by an end node that is length
sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)
all over this file.
The only place where multi-instance device paths are supported is in
environment varibles. Multi-instance device paths should never be placed
on a Handle.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
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 "UefiDevicePathLib.h"
#include <Protocol/DevicePathUtilities.h>
//
// Template for an end-of-device path node.
//
CONST EFI_DEVICE_PATH_PROTOCOL mUefiDevicePathLibEndDevicePath = {
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
END_DEVICE_PATH_LENGTH,
0
}
};
/**
Determine whether a given device path is valid.
If DevicePath is NULL, then ASSERT().
@param DevicePath A pointer to a device path data structure.
@param MaxSize The maximum size of the device path data structure.
@retval TRUE DevicePath is valid.
@retval FALSE The length of any node node in the DevicePath is less
than sizeof (EFI_DEVICE_PATH_PROTOCOL).
@retval FALSE If MaxSize is not zero, the size of the DevicePath
exceeds MaxSize.
@retval FALSE If PcdMaximumDevicePathNodeCount is not zero, the node
count of the DevicePath exceeds PcdMaximumDevicePathNodeCount.
**/
BOOLEAN
IsDevicePathValid (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
UINTN MaxSize
)
{
UINTN Count;
UINTN Size;
UINTN NodeLength;
ASSERT (DevicePath != NULL);
if (MaxSize == 0) {
MaxSize = MAX_UINTN;
}
//
// Validate the input size big enough to touch the first node.
//
if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
return FALSE;
}
for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
NodeLength = DevicePathNodeLength (DevicePath);
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
return FALSE;
}
if (NodeLength > MAX_UINTN - Size) {
return FALSE;
}
Size += NodeLength;
//
// Validate next node before touch it.
//
if (Size > MaxSize - END_DEVICE_PATH_LENGTH ) {
return FALSE;
}
Count++;
if (Count >= MAX_DEVICE_PATH_NODE_COUNT) {
return FALSE;
}
}
//
// Only return TRUE when the End Device Path node is valid.
//
return (BOOLEAN) (DevicePathNodeLength (DevicePath) == END_DEVICE_PATH_LENGTH);
}
/**
Returns the Type field of a device path node.
Returns the Type field of the device path node specified by Node.
If Node is NULL, then ASSERT().
@param Node A pointer to a device path node data structure.
@return The Type field of the device path node specified by Node.
**/
UINT8
DevicePathType (
CONST VOID *Node
)
{
ASSERT (Node != NULL);
return ((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Type;
}
/**
Returns the SubType field of a device path node.
Returns the SubType field of the device path node specified by Node.
If Node is NULL, then ASSERT().
@param Node A pointer to a device path node data structure.
@return The SubType field of the device path node specified by Node.
**/
UINT8
DevicePathSubType (
CONST VOID *Node
)
{
ASSERT (Node != NULL);
return ((EFI_DEVICE_PATH_PROTOCOL *)(Node))->SubType;
}
/**
Returns the 16-bit Length field of a device path node.
Returns the 16-bit Length field of the device path node specified by Node.
Node is not required to be aligned on a 16-bit boundary, so it is recommended
that a function such as ReadUnaligned16() be used to extract the contents of
the Length field.
If Node is NULL, then ASSERT().
@param Node A pointer to a device path node data structure.
@return The 16-bit Length field of the device path node specified by Node.
**/
UINTN
DevicePathNodeLength (
CONST VOID *Node
)
{
ASSERT (Node != NULL);
return ReadUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0]);
}
/**
Returns a pointer to the next node in a device path.
Returns a pointer to the device path node that follows the device path node
specified by Node.
If Node is NULL, then ASSERT().
@param Node A pointer to a device path node data structure.
@return a pointer to the device path node that follows the device path node
specified by Node.
**/
EFI_DEVICE_PATH_PROTOCOL *
NextDevicePathNode (
CONST VOID *Node
)
{
ASSERT (Node != NULL);
return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node));
}
/**
Determines if a device path node is an end node of a device path.
This includes nodes that are the end of a device path instance and nodes that
are the end of an entire device path.
Determines if the device path node specified by Node is an end node of a device path.
This includes nodes that are the end of a device path instance and nodes that are the
end of an entire device path. If Node represents an end node of a device path,
then TRUE is returned. Otherwise, FALSE is returned.
If Node is NULL, then ASSERT().
@param Node A pointer to a device path node data structure.
@retval TRUE The device path node specified by Node is an end node of a
device path.
@retval FALSE The device path node specified by Node is not an end node of
a device path.
**/
BOOLEAN
IsDevicePathEndType (
CONST VOID *Node
)
{
ASSERT (Node != NULL);
return (BOOLEAN) (DevicePathType (Node) == END_DEVICE_PATH_TYPE);
}
/**
Determines if a device path node is an end node of an entire device path.
Determines if a device path node specified by Node is an end node of an entire
device path. If Node represents the end of an entire device path, then TRUE is
returned. Otherwise, FALSE is returned.
If Node is NULL, then ASSERT().
@param Node A pointer to a device path node data structure.
@retval TRUE The device path node specified by Node is the end of an entire
device path.
@retval FALSE The device path node specified by Node is not the end of an
entire device path.
**/
BOOLEAN
IsDevicePathEnd (
CONST VOID *Node
)
{
ASSERT (Node != NULL);
return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE);
}
/**
Determines if a device path node is an end node of a device path instance.
Determines if a device path node specified by Node is an end node of a device
path instance. If Node represents the end of a device path instance, then TRUE
is returned. Otherwise, FALSE is returned.
If Node is NULL, then ASSERT().
@param Node A pointer to a device path node data structure.
@retval TRUE The device path node specified by Node is the end of a device
path instance.
@retval FALSE The device path node specified by Node is not the end of a
device path instance.
**/
BOOLEAN
IsDevicePathEndInstance (
CONST VOID *Node
)
{
ASSERT (Node != NULL);
return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_INSTANCE_DEVICE_PATH_SUBTYPE);
}
/**
Sets the length, in bytes, of a device path node.
Sets the length of the device path node specified by Node to the value specified
by NodeLength. NodeLength is returned. Node is not required to be aligned on
a 16-bit boundary, so it is recommended that a function such as WriteUnaligned16()
be used to set the contents of the Length field.
If Node is NULL, then ASSERT().
If NodeLength >= SIZE_64KB, then ASSERT().
If NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL), then ASSERT().
@param Node A pointer to a device path node data structure.
@param Length The length, in bytes, of the device path node.
@return Length
**/
UINT16
SetDevicePathNodeLength (
VOID *Node,
UINTN Length
)
{
ASSERT (Node != NULL);
ASSERT ((Length >= sizeof (EFI_DEVICE_PATH_PROTOCOL)) && (Length < SIZE_64KB));
return WriteUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0], (UINT16)(Length));
}
/**
Fills in all the fields of a device path node that is the end of an entire device path.
Fills in all the fields of a device path node specified by Node so Node represents
the end of an entire device path. The Type field of Node is set to
END_DEVICE_PATH_TYPE, the SubType field of Node is set to
END_ENTIRE_DEVICE_PATH_SUBTYPE, and the Length field of Node is set to
END_DEVICE_PATH_LENGTH. Node is not required to be aligned on a 16-bit boundary,
so it is recommended that a function such as WriteUnaligned16() be used to set
the contents of the Length field.
If Node is NULL, then ASSERT().
@param Node A pointer to a device path node data structure.
**/
VOID
SetDevicePathEndNode (
VOID *Node
)
{
ASSERT (Node != NULL);
memcpy (Node, &mUefiDevicePathLibEndDevicePath, sizeof (mUefiDevicePathLibEndDevicePath));
}
/**
Returns the size of a device path in bytes.
This function returns the size, in bytes, of the device path data structure
specified by DevicePath including the end of device path node.
If DevicePath is NULL or invalid, then 0 is returned.
@param DevicePath A pointer to a device path data structure.
@retval 0 If DevicePath is NULL or invalid.
@retval Others The size of a device path in bytes.
**/
UINTN
UefiDevicePathLibGetDevicePathSize (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
CONST EFI_DEVICE_PATH_PROTOCOL *Start;
if (DevicePath == NULL) {
return 0;
}
if (!IsDevicePathValid (DevicePath, 0)) {
return 0;
}
//
// Search for the end of the device path structure
//
Start = DevicePath;
while (!IsDevicePathEnd (DevicePath)) {
DevicePath = NextDevicePathNode (DevicePath);
}
//
// Compute the size and add back in the size of the end device path structure
//
return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);
}
/**
Creates a new copy of an existing device path.
This function allocates space for a new copy of the device path specified by DevicePath.
If DevicePath is NULL, then NULL is returned. If the memory is successfully
allocated, then the contents of DevicePath are copied to the newly allocated
buffer, and a pointer to that buffer is returned. Otherwise, NULL is returned.
The memory for the new device path is allocated from EFI boot services memory.
It is the responsibility of the caller to free the memory allocated.
@param DevicePath A pointer to a device path data structure.
@retval NULL DevicePath is NULL or invalid.
@retval Others A pointer to the duplicated device path.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibDuplicateDevicePath (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
UINTN Size;
//
// Compute the size
//
Size = GetDevicePathSize (DevicePath);
if (Size == 0) {
return NULL;
}
//
// Allocate space for duplicate device path
//
return AllocateCopyPool (Size, DevicePath);
}
/**
Creates a new device path by appending a second device path to a first device path.
This function creates a new device path by appending a copy of SecondDevicePath
to a copy of FirstDevicePath in a newly allocated buffer. Only the end-of-device-path
device node from SecondDevicePath is retained. The newly created device path is
returned. If FirstDevicePath is NULL, then it is ignored, and a duplicate of
SecondDevicePath is returned. If SecondDevicePath is NULL, then it is ignored,
and a duplicate of FirstDevicePath is returned. If both FirstDevicePath and
SecondDevicePath are NULL, then a copy of an end-of-device-path is returned.
If there is not enough memory for the newly allocated buffer, then NULL is returned.
The memory for the new device path is allocated from EFI boot services memory.
It is the responsibility of the caller to free the memory allocated.
@param FirstDevicePath A pointer to a device path data structure.
@param SecondDevicePath A pointer to a device path data structure.
@retval NULL If there is not enough memory for the newly allocated buffer.
@retval NULL If FirstDevicePath or SecondDevicePath is invalid.
@retval Others A pointer to the new device path if success.
Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibAppendDevicePath (
CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,
CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath
)
{
UINTN Size;
UINTN Size1;
UINTN Size2;
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePath2;
//
// If there's only 1 path, just duplicate it.
//
if (FirstDevicePath == NULL) {
return DuplicateDevicePath ((SecondDevicePath != NULL) ? SecondDevicePath : &mUefiDevicePathLibEndDevicePath);
}
if (SecondDevicePath == NULL) {
return DuplicateDevicePath (FirstDevicePath);
}
if (!IsDevicePathValid (FirstDevicePath, 0) || !IsDevicePathValid (SecondDevicePath, 0)) {
return NULL;
}
//
// Allocate space for the combined device path. It only has one end node of
// length EFI_DEVICE_PATH_PROTOCOL.
//
Size1 = GetDevicePathSize (FirstDevicePath);
Size2 = GetDevicePathSize (SecondDevicePath);
Size = Size1 + Size2 - END_DEVICE_PATH_LENGTH;
NewDevicePath = AllocatePool (Size);
if (NewDevicePath != NULL) {
NewDevicePath = memcpy (NewDevicePath, FirstDevicePath, Size1);
//
// Over write FirstDevicePath EndNode and do the copy
//
DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath +
(Size1 - END_DEVICE_PATH_LENGTH));
memcpy (DevicePath2, SecondDevicePath, Size2);
}
return NewDevicePath;
}
/**
Creates a new path by appending the device node to the device path.
This function creates a new device path by appending a copy of the device node
specified by DevicePathNode to a copy of the device path specified by DevicePath
in an allocated buffer. The end-of-device-path device node is moved after the
end of the appended device node.
If DevicePathNode is NULL then a copy of DevicePath is returned.
If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device
path device node is returned.
If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path
device node is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
@param DevicePath A pointer to a device path data structure.
@param DevicePathNode A pointer to a single device path node.
@retval NULL If there is not enough memory for the new device path.
@retval Others A pointer to the new device path if success.
A copy of DevicePathNode followed by an end-of-device-path node
if both FirstDevicePath and SecondDevicePath are NULL.
A copy of an end-of-device-path node if both FirstDevicePath
and SecondDevicePath are NULL.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibAppendDevicePathNode (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode
)
{
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
EFI_DEVICE_PATH_PROTOCOL *NextNode;
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
UINTN NodeLength;
if (DevicePathNode == NULL) {
return DuplicateDevicePath ((DevicePath != NULL) ? DevicePath : &mUefiDevicePathLibEndDevicePath);
}
//
// Build a Node that has a terminator on it
//
NodeLength = DevicePathNodeLength (DevicePathNode);
TempDevicePath = AllocatePool (NodeLength + END_DEVICE_PATH_LENGTH);
if (TempDevicePath == NULL) {
return NULL;
}
TempDevicePath = memcpy (TempDevicePath, DevicePathNode, NodeLength);
//
// Add and end device path node to convert Node to device path
//
NextNode = NextDevicePathNode (TempDevicePath);
SetDevicePathEndNode (NextNode);
//
// Append device paths
//
NewDevicePath = AppendDevicePath (DevicePath, TempDevicePath);
free (TempDevicePath);
return NewDevicePath;
}
/**
Creates a new device path by appending the specified device path instance to the specified device
path.
This function creates a new device path by appending a copy of the device path
instance specified by DevicePathInstance to a copy of the device path specified
by DevicePath in a allocated buffer.
The end-of-device-path device node is moved after the end of the appended device
path instance and a new end-of-device-path-instance node is inserted between.
If DevicePath is NULL, then a copy if DevicePathInstance is returned.
If DevicePathInstance is NULL, then NULL is returned.
If DevicePath or DevicePathInstance is invalid, then NULL is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
@param DevicePath A pointer to a device path data structure.
@param DevicePathInstance A pointer to a device path instance.
@return A pointer to the new device path.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibAppendDevicePathInstance (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
)
{
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
UINTN SrcSize;
UINTN InstanceSize;
if (DevicePath == NULL) {
return DuplicateDevicePath (DevicePathInstance);
}
if (DevicePathInstance == NULL) {
return NULL;
}
if (!IsDevicePathValid (DevicePath, 0) || !IsDevicePathValid (DevicePathInstance, 0)) {
return NULL;
}
SrcSize = GetDevicePathSize (DevicePath);
InstanceSize = GetDevicePathSize (DevicePathInstance);
NewDevicePath = AllocatePool (SrcSize + InstanceSize);
if (NewDevicePath != NULL) {
TempDevicePath = memcpy (NewDevicePath, DevicePath, SrcSize);;
while (!IsDevicePathEnd (TempDevicePath)) {
TempDevicePath = NextDevicePathNode (TempDevicePath);
}
TempDevicePath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
TempDevicePath = NextDevicePathNode (TempDevicePath);
memcpy (TempDevicePath, DevicePathInstance, InstanceSize);
}
return NewDevicePath;
}
/**
Creates a copy of the current device path instance and returns a pointer to the next device path
instance.
This function creates a copy of the current device path instance. It also updates
DevicePath to point to the next device path instance in the device path (or NULL
if no more) and updates Size to hold the size of the device path instance copy.
If DevicePath is NULL, then NULL is returned.
If DevicePath points to a invalid device path, then NULL is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
If Size is NULL, then ASSERT().
@param DevicePath On input, this holds the pointer to the current
device path instance. On output, this holds
the pointer to the next device path instance
or NULL if there are no more device path
instances in the device path pointer to a
device path data structure.
@param Size On output, this holds the size of the device
path instance, in bytes or zero, if DevicePath
is NULL.
@return A pointer to the current device path instance.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibGetNextDevicePathInstance (
EFI_DEVICE_PATH_PROTOCOL **DevicePath,
UINTN *Size
)
{
EFI_DEVICE_PATH_PROTOCOL *DevPath;
EFI_DEVICE_PATH_PROTOCOL *ReturnValue;
UINT8 Temp;
ASSERT (Size != NULL);
if (DevicePath == NULL || *DevicePath == NULL) {
*Size = 0;
return NULL;
}
if (!IsDevicePathValid (*DevicePath, 0)) {
return NULL;
}
//
// Find the end of the device path instance
//
DevPath = *DevicePath;
while (!IsDevicePathEndType (DevPath)) {
DevPath = NextDevicePathNode (DevPath);
}
//
// Compute the size of the device path instance
//
*Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
//
// Make a copy and return the device path instance
//
Temp = DevPath->SubType;
DevPath->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
ReturnValue = DuplicateDevicePath (*DevicePath);
DevPath->SubType = Temp;
//
// If DevPath is the end of an entire device path, then another instance
// does not follow, so *DevicePath is set to NULL.
//
if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) {
*DevicePath = NULL;
} else {
*DevicePath = NextDevicePathNode (DevPath);
}
return ReturnValue;
}
/**
Creates a device node.
This function creates a new device node in a newly allocated buffer of size
NodeLength and initializes the device path node header with NodeType and NodeSubType.
The new device path node is returned.
If NodeLength is smaller than a device path header, then NULL is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
@param NodeType The device node type for the new device node.
@param NodeSubType The device node sub-type for the new device node.
@param NodeLength The length of the new device node.
@return The new device path.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibCreateDeviceNode (
UINT8 NodeType,
UINT8 NodeSubType,
UINT16 NodeLength
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
//
// NodeLength is less than the size of the header.
//
return NULL;
}
DevicePath = AllocateZeroPool (NodeLength);
if (DevicePath != NULL) {
DevicePath->Type = NodeType;
DevicePath->SubType = NodeSubType;
SetDevicePathNodeLength (DevicePath, NodeLength);
}
return DevicePath;
}
/**
Determines if a device path is single or multi-instance.
This function returns TRUE if the device path specified by DevicePath is
multi-instance.
Otherwise, FALSE is returned.
If DevicePath is NULL or invalid, then FALSE is returned.
@param DevicePath A pointer to a device path data structure.
@retval TRUE DevicePath is multi-instance.
@retval FALSE DevicePath is not multi-instance, or DevicePath
is NULL or invalid.
**/
BOOLEAN
UefiDevicePathLibIsDevicePathMultiInstance (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
CONST EFI_DEVICE_PATH_PROTOCOL *Node;
if (DevicePath == NULL) {
return FALSE;
}
if (!IsDevicePathValid (DevicePath, 0)) {
return FALSE;
}
Node = DevicePath;
while (!IsDevicePathEnd (Node)) {
if (IsDevicePathEndInstance (Node)) {
return TRUE;
}
Node = NextDevicePathNode (Node);
}
return FALSE;
}
/**
Retrieves the device path protocol from a handle.
This function returns the device path protocol from the handle specified by Handle.
If Handle is NULL or Handle does not contain a device path protocol, then NULL
is returned.
@param Handle The handle from which to retrieve the device
path protocol.
@return The device path protocol from the handle specified by Handle.
**/
/*
EFI_DEVICE_PATH_PROTOCOL *
DevicePathFromHandle (
EFI_HANDLE Handle
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_STATUS Status;
Status = gBS->HandleProtocol (
Handle,
&gEfiDevicePathProtocolGuid,
(VOID *) &DevicePath
);
if (EFI_ERROR (Status)) {
DevicePath = NULL;
}
return DevicePath;
}
*/
/**
Allocates a device path for a file and appends it to an existing device path.
If Device is a valid device handle that contains a device path protocol, then a device path for
the file specified by FileName is allocated and appended to the device path associated with the
handle Device. The allocated device path is returned. If Device is NULL or Device is a handle
that does not support the device path protocol, then a device path containing a single device
path node for the file specified by FileName is allocated and returned.
The memory for the new device path is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
If FileName is NULL, then ASSERT().
If FileName is not aligned on a 16-bit boundary, then ASSERT().
@param Device A pointer to a device handle. This parameter
is optional and may be NULL.
@param FileName A pointer to a Null-terminated Unicode string.
@return The allocated device path.
**/
EFI_DEVICE_PATH_PROTOCOL *
FileDevicePath (
EFI_HANDLE Device, OPTIONAL
CONST CHAR16 *FileName
)
{
UINTN Size;
FILEPATH_DEVICE_PATH *FilePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;
DevicePath = NULL;
Size = StrSize (FileName);
FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + END_DEVICE_PATH_LENGTH);
if (FileDevicePath != NULL) {
FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;
FilePath->Header.Type = MEDIA_DEVICE_PATH;
FilePath->Header.SubType = MEDIA_FILEPATH_DP;
memcpy (&FilePath->PathName, FileName, Size);
SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);
SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header));
//if (Device != NULL) {
// DevicePath = DevicePathFromHandle (Device);
//}
DevicePath = AppendDevicePath (DevicePath, FileDevicePath);
free (FileDevicePath);
}
return DevicePath;
}

View File

@ -0,0 +1,30 @@
## @file
# GNU/Linux makefile for 'DevicePath' module build.
#
# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
# 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.
#
ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = DevicePath
OBJECTS = DevicePath.o UefiDevicePathLib.o DevicePathFromText.o DevicePathUtilities.o
include $(MAKEROOT)/Makefiles/app.makefile
LIBS = -lCommon
ifeq ($(CYGWIN), CYGWIN)
LIBS += -L/lib/e2fsprogs -luuid
endif
ifeq ($(LINUX), Linux)
LIBS += -luuid
endif

View File

@ -0,0 +1,24 @@
## @file
# Windows makefile for 'DevicePath' module build.
#
# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
# 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 ..\Makefiles\ms.common
APPNAME = DevicePath
LIBS = $(LIB_PATH)\Common.lib
OBJECTS = DevicePath.obj UefiDevicePathLib.obj DevicePathFromText.obj DevicePathUtilities.obj
#CFLAGS = $(CFLAGS) /nodefaultlib:libc.lib
!INCLUDE ..\Makefiles\ms.app

View File

@ -0,0 +1,298 @@
/** @file
Device Path services. The thing to remember is device paths are built out of
nodes. The device path is terminated by an end node that is length
sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)
all over this file.
The only place where multi-instance device paths are supported is in
environment varibles. Multi-instance device paths should never be placed
on a Handle.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
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 "UefiDevicePathLib.h"
/**
Returns the size of a device path in bytes.
This function returns the size, in bytes, of the device path data structure
specified by DevicePath including the end of device path node.
If DevicePath is NULL or invalid, then 0 is returned.
@param DevicePath A pointer to a device path data structure.
@retval 0 If DevicePath is NULL or invalid.
@retval Others The size of a device path in bytes.
**/
UINTN
GetDevicePathSize (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
return UefiDevicePathLibGetDevicePathSize (DevicePath);
}
/**
Creates a new copy of an existing device path.
This function allocates space for a new copy of the device path specified by DevicePath.
If DevicePath is NULL, then NULL is returned. If the memory is successfully
allocated, then the contents of DevicePath are copied to the newly allocated
buffer, and a pointer to that buffer is returned. Otherwise, NULL is returned.
The memory for the new device path is allocated from EFI boot services memory.
It is the responsibility of the caller to free the memory allocated.
@param DevicePath A pointer to a device path data structure.
@retval NULL DevicePath is NULL or invalid.
@retval Others A pointer to the duplicated device path.
**/
EFI_DEVICE_PATH_PROTOCOL *
DuplicateDevicePath (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
return UefiDevicePathLibDuplicateDevicePath (DevicePath);
}
/**
Creates a new device path by appending a second device path to a first device path.
This function creates a new device path by appending a copy of SecondDevicePath
to a copy of FirstDevicePath in a newly allocated buffer. Only the end-of-device-path
device node from SecondDevicePath is retained. The newly created device path is
returned. If FirstDevicePath is NULL, then it is ignored, and a duplicate of
SecondDevicePath is returned. If SecondDevicePath is NULL, then it is ignored,
and a duplicate of FirstDevicePath is returned. If both FirstDevicePath and
SecondDevicePath are NULL, then a copy of an end-of-device-path is returned.
If there is not enough memory for the newly allocated buffer, then NULL is returned.
The memory for the new device path is allocated from EFI boot services memory.
It is the responsibility of the caller to free the memory allocated.
@param FirstDevicePath A pointer to a device path data structure.
@param SecondDevicePath A pointer to a device path data structure.
@retval NULL If there is not enough memory for the newly allocated buffer.
@retval NULL If FirstDevicePath or SecondDevicePath is invalid.
@retval Others A pointer to the new device path if success.
Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.
**/
EFI_DEVICE_PATH_PROTOCOL *
AppendDevicePath (
CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL
CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL
)
{
return UefiDevicePathLibAppendDevicePath (FirstDevicePath, SecondDevicePath);
}
/**
Creates a new path by appending the device node to the device path.
This function creates a new device path by appending a copy of the device node
specified by DevicePathNode to a copy of the device path specified by DevicePath
in an allocated buffer. The end-of-device-path device node is moved after the
end of the appended device node.
If DevicePathNode is NULL then a copy of DevicePath is returned.
If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device
path device node is returned.
If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path
device node is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
@param DevicePath A pointer to a device path data structure.
@param DevicePathNode A pointer to a single device path node.
@retval NULL If there is not enough memory for the new device path.
@retval Others A pointer to the new device path if success.
A copy of DevicePathNode followed by an end-of-device-path node
if both FirstDevicePath and SecondDevicePath are NULL.
A copy of an end-of-device-path node if both FirstDevicePath
and SecondDevicePath are NULL.
**/
EFI_DEVICE_PATH_PROTOCOL *
AppendDevicePathNode (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL
)
{
return UefiDevicePathLibAppendDevicePathNode (DevicePath, DevicePathNode);
}
/**
Creates a new device path by appending the specified device path instance to the specified device
path.
This function creates a new device path by appending a copy of the device path
instance specified by DevicePathInstance to a copy of the device path specified
by DevicePath in a allocated buffer.
The end-of-device-path device node is moved after the end of the appended device
path instance and a new end-of-device-path-instance node is inserted between.
If DevicePath is NULL, then a copy if DevicePathInstance is returned.
If DevicePathInstance is NULL, then NULL is returned.
If DevicePath or DevicePathInstance is invalid, then NULL is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
@param DevicePath A pointer to a device path data structure.
@param DevicePathInstance A pointer to a device path instance.
@return A pointer to the new device path.
**/
EFI_DEVICE_PATH_PROTOCOL *
AppendDevicePathInstance (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL
)
{
return UefiDevicePathLibAppendDevicePathInstance (DevicePath, DevicePathInstance);
}
/**
Creates a copy of the current device path instance and returns a pointer to the next device path
instance.
This function creates a copy of the current device path instance. It also updates
DevicePath to point to the next device path instance in the device path (or NULL
if no more) and updates Size to hold the size of the device path instance copy.
If DevicePath is NULL, then NULL is returned.
If DevicePath points to a invalid device path, then NULL is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
If Size is NULL, then ASSERT().
@param DevicePath On input, this holds the pointer to the current
device path instance. On output, this holds
the pointer to the next device path instance
or NULL if there are no more device path
instances in the device path pointer to a
device path data structure.
@param Size On output, this holds the size of the device
path instance, in bytes or zero, if DevicePath
is NULL.
@return A pointer to the current device path instance.
**/
EFI_DEVICE_PATH_PROTOCOL *
GetNextDevicePathInstance (
EFI_DEVICE_PATH_PROTOCOL **DevicePath,
UINTN *Size
)
{
return UefiDevicePathLibGetNextDevicePathInstance (DevicePath, Size);
}
/**
Creates a device node.
This function creates a new device node in a newly allocated buffer of size
NodeLength and initializes the device path node header with NodeType and NodeSubType.
The new device path node is returned.
If NodeLength is smaller than a device path header, then NULL is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
@param NodeType The device node type for the new device node.
@param NodeSubType The device node sub-type for the new device node.
@param NodeLength The length of the new device node.
@return The new device path.
**/
EFI_DEVICE_PATH_PROTOCOL *
CreateDeviceNode (
UINT8 NodeType,
UINT8 NodeSubType,
UINT16 NodeLength
)
{
return UefiDevicePathLibCreateDeviceNode (NodeType, NodeSubType, NodeLength);
}
/**
Determines if a device path is single or multi-instance.
This function returns TRUE if the device path specified by DevicePath is
multi-instance.
Otherwise, FALSE is returned.
If DevicePath is NULL or invalid, then FALSE is returned.
@param DevicePath A pointer to a device path data structure.
@retval TRUE DevicePath is multi-instance.
@retval FALSE DevicePath is not multi-instance, or DevicePath
is NULL or invalid.
**/
BOOLEAN
IsDevicePathMultiInstance (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
return UefiDevicePathLibIsDevicePathMultiInstance (DevicePath);
}
/**
Convert text to the binary representation of a device node.
@param TextDeviceNode TextDeviceNode points to the text representation of a device
node. Conversion starts with the first character and continues
until the first non-device node character.
@return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
insufficient memory or text unsupported.
**/
EFI_DEVICE_PATH_PROTOCOL *
ConvertTextToDeviceNode (
CONST CHAR16 *TextDeviceNode
)
{
return UefiDevicePathLibConvertTextToDeviceNode (TextDeviceNode);
}
/**
Convert text to the binary representation of a device path.
@param TextDevicePath TextDevicePath points to the text representation of a device
path. Conversion starts with the first character and continues
until the first non-device node character.
@return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
there was insufficient memory.
**/
EFI_DEVICE_PATH_PROTOCOL *
ConvertTextToDevicePath (
CONST CHAR16 *TextDevicePath
)
{
return UefiDevicePathLibConvertTextToDevicePath (TextDevicePath);
}

View File

@ -0,0 +1,452 @@
/** @file
Definition for Device Path library.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
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 _UEFI_DEVICE_PATH_LIB_H_
#define _UEFI_DEVICE_PATH_LIB_H_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#ifdef __GNUC__
#include <unistd.h>
#else
#include <direct.h>
#endif
#include <Common/UefiBaseTypes.h>
#include <Protocol/DevicePath.h>
#include <Protocol/DevicePathUtilities.h>
#include "CommonLib.h"
#include "EfiUtilityMsgs.h"
#define END_DEVICE_PATH_LENGTH (sizeof (EFI_DEVICE_PATH_PROTOCOL))
#define MAX_DEVICE_PATH_NODE_COUNT 1024
#define SIZE_64KB 0x00010000
//
// Private Data structure
//
typedef
EFI_DEVICE_PATH_PROTOCOL *
(*DEVICE_PATH_FROM_TEXT) (
IN CHAR16 *Str
);
typedef struct {
CHAR16 *Str;
UINTN Count;
UINTN Capacity;
} POOL_PRINT;
typedef struct {
CHAR16 *DevicePathNodeText;
DEVICE_PATH_FROM_TEXT Function;
} DEVICE_PATH_FROM_TEXT_TABLE;
typedef struct {
BOOLEAN ClassExist;
UINT8 Class;
BOOLEAN SubClassExist;
UINT8 SubClass;
} USB_CLASS_TEXT;
#define USB_CLASS_AUDIO 1
#define USB_CLASS_CDCCONTROL 2
#define USB_CLASS_HID 3
#define USB_CLASS_IMAGE 6
#define USB_CLASS_PRINTER 7
#define USB_CLASS_MASS_STORAGE 8
#define USB_CLASS_HUB 9
#define USB_CLASS_CDCDATA 10
#define USB_CLASS_SMART_CARD 11
#define USB_CLASS_VIDEO 14
#define USB_CLASS_DIAGNOSTIC 220
#define USB_CLASS_WIRELESS 224
#define USB_CLASS_RESERVE 254
#define USB_SUBCLASS_FW_UPDATE 1
#define USB_SUBCLASS_IRDA_BRIDGE 2
#define USB_SUBCLASS_TEST 3
#define RFC_1700_UDP_PROTOCOL 17
#define RFC_1700_TCP_PROTOCOL 6
#pragma pack(1)
typedef struct {
EFI_DEVICE_PATH_PROTOCOL Header;
EFI_GUID Guid;
UINT8 VendorDefinedData[1];
} VENDOR_DEFINED_HARDWARE_DEVICE_PATH;
typedef struct {
EFI_DEVICE_PATH_PROTOCOL Header;
EFI_GUID Guid;
UINT8 VendorDefinedData[1];
} VENDOR_DEFINED_MESSAGING_DEVICE_PATH;
typedef struct {
EFI_DEVICE_PATH_PROTOCOL Header;
EFI_GUID Guid;
UINT8 VendorDefinedData[1];
} VENDOR_DEFINED_MEDIA_DEVICE_PATH;
typedef struct {
EFI_DEVICE_PATH_PROTOCOL Header;
UINT32 Hid;
UINT32 Uid;
UINT32 Cid;
CHAR8 HidUidCidStr[3];
} ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR;
typedef struct {
EFI_DEVICE_PATH_PROTOCOL Header;
UINT16 NetworkProtocol;
UINT16 LoginOption;
UINT64 Lun;
UINT16 TargetPortalGroupTag;
CHAR8 TargetName[1];
} ISCSI_DEVICE_PATH_WITH_NAME;
typedef struct {
EFI_DEVICE_PATH_PROTOCOL Header;
EFI_GUID Guid;
UINT8 VendorDefinedData[1];
} VENDOR_DEVICE_PATH_WITH_DATA;
#pragma pack()
/**
Returns the size of a device path in bytes.
This function returns the size, in bytes, of the device path data structure
specified by DevicePath including the end of device path node.
If DevicePath is NULL or invalid, then 0 is returned.
@param DevicePath A pointer to a device path data structure.
@retval 0 If DevicePath is NULL or invalid.
@retval Others The size of a device path in bytes.
**/
UINTN
UefiDevicePathLibGetDevicePathSize (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
Creates a new copy of an existing device path.
This function allocates space for a new copy of the device path specified by DevicePath.
If DevicePath is NULL, then NULL is returned. If the memory is successfully
allocated, then the contents of DevicePath are copied to the newly allocated
buffer, and a pointer to that buffer is returned. Otherwise, NULL is returned.
The memory for the new device path is allocated from EFI boot services memory.
It is the responsibility of the caller to free the memory allocated.
@param DevicePath A pointer to a device path data structure.
@retval NULL DevicePath is NULL or invalid.
@retval Others A pointer to the duplicated device path.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibDuplicateDevicePath (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
Creates a new device path by appending a second device path to a first device path.
This function creates a new device path by appending a copy of SecondDevicePath
to a copy of FirstDevicePath in a newly allocated buffer. Only the end-of-device-path
device node from SecondDevicePath is retained. The newly created device path is
returned. If FirstDevicePath is NULL, then it is ignored, and a duplicate of
SecondDevicePath is returned. If SecondDevicePath is NULL, then it is ignored,
and a duplicate of FirstDevicePath is returned. If both FirstDevicePath and
SecondDevicePath are NULL, then a copy of an end-of-device-path is returned.
If there is not enough memory for the newly allocated buffer, then NULL is returned.
The memory for the new device path is allocated from EFI boot services memory.
It is the responsibility of the caller to free the memory allocated.
@param FirstDevicePath A pointer to a device path data structure.
@param SecondDevicePath A pointer to a device path data structure.
@retval NULL If there is not enough memory for the newly allocated buffer.
@retval NULL If FirstDevicePath or SecondDevicePath is invalid.
@retval Others A pointer to the new device path if success.
Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibAppendDevicePath (
CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL
CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL
);
/**
Creates a new path by appending the device node to the device path.
This function creates a new device path by appending a copy of the device node
specified by DevicePathNode to a copy of the device path specified by DevicePath
in an allocated buffer. The end-of-device-path device node is moved after the
end of the appended device node.
If DevicePathNode is NULL then a copy of DevicePath is returned.
If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device
path device node is returned.
If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path
device node is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
@param DevicePath A pointer to a device path data structure.
@param DevicePathNode A pointer to a single device path node.
@retval NULL If there is not enough memory for the new device path.
@retval Others A pointer to the new device path if success.
A copy of DevicePathNode followed by an end-of-device-path node
if both FirstDevicePath and SecondDevicePath are NULL.
A copy of an end-of-device-path node if both FirstDevicePath
and SecondDevicePath are NULL.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibAppendDevicePathNode (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL
);
/**
Creates a new device path by appending the specified device path instance to the specified device
path.
This function creates a new device path by appending a copy of the device path
instance specified by DevicePathInstance to a copy of the device path specified
by DevicePath in a allocated buffer.
The end-of-device-path device node is moved after the end of the appended device
path instance and a new end-of-device-path-instance node is inserted between.
If DevicePath is NULL, then a copy if DevicePathInstance is returned.
If DevicePathInstance is NULL, then NULL is returned.
If DevicePath or DevicePathInstance is invalid, then NULL is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
@param DevicePath A pointer to a device path data structure.
@param DevicePathInstance A pointer to a device path instance.
@return A pointer to the new device path.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibAppendDevicePathInstance (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL
);
/**
Creates a copy of the current device path instance and returns a pointer to the next device path
instance.
This function creates a copy of the current device path instance. It also updates
DevicePath to point to the next device path instance in the device path (or NULL
if no more) and updates Size to hold the size of the device path instance copy.
If DevicePath is NULL, then NULL is returned.
If DevicePath points to a invalid device path, then NULL is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
If Size is NULL, then ASSERT().
@param DevicePath On input, this holds the pointer to the current
device path instance. On output, this holds
the pointer to the next device path instance
or NULL if there are no more device path
instances in the device path pointer to a
device path data structure.
@param Size On output, this holds the size of the device
path instance, in bytes or zero, if DevicePath
is NULL.
@return A pointer to the current device path instance.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibGetNextDevicePathInstance (
EFI_DEVICE_PATH_PROTOCOL **DevicePath,
UINTN *Size
);
/**
Creates a device node.
This function creates a new device node in a newly allocated buffer of size
NodeLength and initializes the device path node header with NodeType and NodeSubType.
The new device path node is returned.
If NodeLength is smaller than a device path header, then NULL is returned.
If there is not enough memory to allocate space for the new device path, then
NULL is returned.
The memory is allocated from EFI boot services memory. It is the responsibility
of the caller to free the memory allocated.
@param NodeType The device node type for the new device node.
@param NodeSubType The device node sub-type for the new device node.
@param NodeLength The length of the new device node.
@return The new device path.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibCreateDeviceNode (
UINT8 NodeType,
UINT8 NodeSubType,
UINT16 NodeLength
);
/**
Determines if a device path is single or multi-instance.
This function returns TRUE if the device path specified by DevicePath is
multi-instance.
Otherwise, FALSE is returned.
If DevicePath is NULL or invalid, then FALSE is returned.
@param DevicePath A pointer to a device path data structure.
@retval TRUE DevicePath is multi-instance.
@retval FALSE DevicePath is not multi-instance, or DevicePath
is NULL or invalid.
**/
BOOLEAN
UefiDevicePathLibIsDevicePathMultiInstance (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
Convert text to the binary representation of a device node.
@param TextDeviceNode TextDeviceNode points to the text representation of a device
node. Conversion starts with the first character and continues
until the first non-device node character.
@return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
insufficient memory or text unsupported.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibConvertTextToDeviceNode (
CONST CHAR16 *TextDeviceNode
);
/**
Convert text to the binary representation of a device path.
@param TextDevicePath TextDevicePath points to the text representation of a device
path. Conversion starts with the first character and continues
until the first non-device node character.
@return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
there was insufficient memory.
**/
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibConvertTextToDevicePath (
CONST CHAR16 *TextDevicePath
);
EFI_DEVICE_PATH_PROTOCOL *
CreateDeviceNode (
UINT8 NodeType,
UINT8 NodeSubType,
UINT16 NodeLength
);
EFI_DEVICE_PATH_PROTOCOL *
CreateDeviceNode (
UINT8 NodeType,
UINT8 NodeSubType,
UINT16 NodeLength
);
BOOLEAN
IsDevicePathMultiInstance (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
EFI_DEVICE_PATH_PROTOCOL *
GetNextDevicePathInstance (
EFI_DEVICE_PATH_PROTOCOL **DevicePath,
UINTN *Size
);
EFI_DEVICE_PATH_PROTOCOL *
AppendDevicePathInstance (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL
);
EFI_DEVICE_PATH_PROTOCOL *
AppendDevicePathNode (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL
);
EFI_DEVICE_PATH_PROTOCOL *
AppendDevicePath (
CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL
CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL
);
EFI_DEVICE_PATH_PROTOCOL *
DuplicateDevicePath (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
UINTN
GetDevicePathSize (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
CHAR16 *
ConvertDeviceNodeToText (
CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
BOOLEAN DisplayOnly,
BOOLEAN AllowShortcuts
);
CHAR16 *
ConvertDevicePathToText (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
BOOLEAN DisplayOnly,
BOOLEAN AllowShortcuts
);
EFI_DEVICE_PATH_PROTOCOL *
ConvertTextToDeviceNode (
CONST CHAR16 *TextDeviceNode
);
EFI_DEVICE_PATH_PROTOCOL *
ConvertTextToDevicePath (
CONST CHAR16 *TextDevicePath
);
#endif

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'EfiLdrImage' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = EfiLdrImage

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'EfiRom' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = EfiRom

View File

@ -67,7 +67,8 @@ APPLICATIONS = \
LzmaCompress \
Split \
TianoCompress \
VolInfo
VolInfo \
DevicePath
SUBDIRS := $(LIBRARIES) $(APPLICATIONS)

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'GenCrc32' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = GenCrc32

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'GenFfs' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = GenFfs

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'GenFv' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = GenFv

View File

@ -1,7 +1,7 @@
/** @file
This file contains the internal functions required to generate a Firmware Volume.
Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
Portions Copyright (c) 2016 HP Development Company, L.P.<BR>
This program and the accompanying materials
@ -34,10 +34,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/FfsSectionAlignmentPadding.h>
#include "WinNtInclude.h"
#include "GenFvInternalLib.h"
#include "FvLib.h"
#include "PeCoffLib.h"
#include "WinNtInclude.h"
#define ARMT_UNCONDITIONAL_JUMP_INSTRUCTION 0xEB000000
#define ARM64_UNCONDITIONAL_JUMP_INSTRUCTION 0x14000000
@ -3532,7 +3532,7 @@ Returns:
//
// Xip module has the same section alignment and file alignment.
//
Error (NULL, 0, 3000, "Invalid", "Section-Alignment and File-Alignment do not match : %s.", FileName);
Error (NULL, 0, 3000, "Invalid", "PE image Section-Alignment and File-Alignment do not match : %s.", FileName);
return EFI_ABORTED;
}
//
@ -3610,7 +3610,7 @@ Returns:
//
// Xip module has the same section alignment and file alignment.
//
Error (NULL, 0, 3000, "Invalid", "Section-Alignment and File-Alignment do not match : %s.", FileName);
Error (NULL, 0, 3000, "Invalid", "PE image Section-Alignment and File-Alignment do not match : %s.", FileName);
return EFI_ABORTED;
}
NewPe32BaseAddress = XipBase + (UINTN) CurrentPe32Section.Pe32Section + CurSecHdrSize - (UINTN)FfsFile;

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'GenFw' module build.
#
# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = GenFw

View File

@ -92,6 +92,7 @@ CHAR8 *mInImageName;
UINT32 mImageTimeStamp = 0;
UINT32 mImageSize = 0;
UINT32 mOutImageType = FW_DUMMY_IMAGE;
BOOLEAN mIsConvertXip = FALSE;
STATIC
@ -665,6 +666,8 @@ PeCoffConvertImageToXip (
free (*FileBuffer);
*FileLength = XipLength;
*FileBuffer = XipFile;
mIsConvertXip = TRUE;
}
UINT8 *
@ -2897,6 +2900,9 @@ Returns:
Index = 0;
for (Index=0; Index < DebugDirectoryEntrySize / sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); Index ++, DebugEntry ++) {
DebugEntry->TimeDateStamp = 0;
if (mIsConvertXip) {
DebugEntry->FileOffset = DebugEntry->RVA;
}
if (ZeroDebugFlag || DebugEntry->Type != EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
memset (FileBuffer + DebugEntry->FileOffset, 0, DebugEntry->SizeOfData);
memset (DebugEntry, 0, sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'GenPage' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = GenPage

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'GenSec' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = GenSec

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'GenVtf' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = GenVtf

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'GnuGenBootSector' module build.
#
# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = GnuGenBootSector

View File

@ -122,6 +122,34 @@
#endif
#ifndef GUID_DEFINED
#define GUID_DEFINED
///
/// 128 bit buffer containing a unique identifier value.
/// Unless otherwise specified, aligned on a 64 bit boundary.
///
typedef struct {
UINT32 Data1;
UINT16 Data2;
UINT16 Data3;
UINT8 Data4[8];
} GUID;
#endif
///
/// 4-byte buffer. An IPv4 internet protocol address.
///
typedef struct {
UINT8 Addr[4];
} IPv4_ADDRESS;
///
/// 16-byte buffer. An IPv6 internet protocol address.
///
typedef struct {
UINT8 Addr[16];
} IPv6_ADDRESS;
//
// Macro that returns the byte offset of a field in a data structure.
//

View File

@ -3,7 +3,7 @@
and DXE phases.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
@ -153,7 +153,7 @@ typedef struct _EFI_CERT_BLOCK_RSA_2048_SHA256 {
typedef struct _WIN_CERTIFICATE_UEFI_GUID {
WIN_CERTIFICATE Hdr;
EFI_GUID CertType;
// UINT8 CertData[ANYSIZE_ARRAY];
UINT8 CertData[1];
} WIN_CERTIFICATE_UEFI_GUID;

View File

@ -0,0 +1,62 @@
/** @file
This file contains the Bluetooth definitions that are consumed by drivers.
These definitions are from Bluetooth Core Specification Version 4.0 June, 2010
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
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 _BLUETOOTH_H_
#define _BLUETOOTH_H_
#pragma pack(1)
///
/// BLUETOOTH_ADDRESS
///
typedef struct {
///
/// 48bit Bluetooth device address.
///
UINT8 Address[6];
} BLUETOOTH_ADDRESS;
///
/// BLUETOOTH_CLASS_OF_DEVICE. See Bluetooth specification for detail.
///
typedef struct {
UINT8 FormatType:2;
UINT8 MinorDeviceClass: 6;
UINT16 MajorDeviceClass: 5;
UINT16 MajorServiceClass:11;
} BLUETOOTH_CLASS_OF_DEVICE;
///
/// BLUETOOTH_LE_ADDRESS
///
typedef struct {
///
/// 48-bit Bluetooth device address
///
UINT8 Address[6];
///
/// 0x00 - Public Device Address
/// 0x01 - Random Device Address
///
UINT8 Type;
} BLUETOOTH_LE_ADDRESS;
#pragma pack()
#define BLUETOOTH_HCI_COMMAND_LOCAL_READABLE_NAME_MAX_SIZE 248
#define BLUETOOTH_HCI_LINK_KEY_SIZE 16
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,294 @@
/** @file
EFI_DEVICE_PATH_UTILITIES_PROTOCOL as defined in UEFI 2.0.
Use to create and manipulate device paths and device nodes.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
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 __DEVICE_PATH_UTILITIES_H__
#define __DEVICE_PATH_UTILITIES_H__
///
/// Device Path Utilities protocol
///
#define EFI_DEVICE_PATH_UTILITIES_GUID \
{ \
0x379be4e, 0xd706, 0x437d, {0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } \
}
/**
Returns the size of the device path, in bytes.
@param DevicePath Points to the start of the EFI device path.
@return Size Size of the specified device path, in bytes, including the end-of-path tag.
@retval 0 DevicePath is NULL
**/
typedef
UINTN
( *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE)(
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
Create a duplicate of the specified path.
@param DevicePath Points to the source EFI device path.
@retval Pointer A pointer to the duplicate device path.
@retval NULL insufficient memory or DevicePath is NULL
**/
typedef
EFI_DEVICE_PATH_PROTOCOL*
( *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH)(
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
Create a new path by appending the second device path to the first.
If Src1 is NULL and Src2 is non-NULL, then a duplicate of Src2 is returned.
If Src1 is non-NULL and Src2 is NULL, then a duplicate of Src1 is returned.
If Src1 and Src2 are both NULL, then a copy of an end-of-device-path is returned.
@param Src1 Points to the first device path.
@param Src2 Points to the second device path.
@retval Pointer A pointer to the newly created device path.
@retval NULL Memory could not be allocated
**/
typedef
EFI_DEVICE_PATH_PROTOCOL*
( *EFI_DEVICE_PATH_UTILS_APPEND_PATH)(
CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
CONST EFI_DEVICE_PATH_PROTOCOL *Src2
);
/**
Creates a new path by appending the device node to the device path.
If DeviceNode is NULL then a copy of DevicePath is returned.
If DevicePath is NULL then a copy of DeviceNode, followed by an end-of-device path device node is returned.
If both DeviceNode and DevicePath are NULL then a copy of an end-of-device-path device node is returned.
@param DevicePath Points to the device path.
@param DeviceNode Points to the device node.
@retval Pointer A pointer to the allocated device node.
@retval NULL There was insufficient memory.
**/
typedef
EFI_DEVICE_PATH_PROTOCOL*
( *EFI_DEVICE_PATH_UTILS_APPEND_NODE)(
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
);
/**
Creates a new path by appending the specified device path instance to the specified device path.
@param DevicePath Points to the device path. If NULL, then ignored.
@param DevicePathInstance Points to the device path instance.
@retval Pointer A pointer to the newly created device path
@retval NULL Memory could not be allocated or DevicePathInstance is NULL.
**/
typedef
EFI_DEVICE_PATH_PROTOCOL*
( *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE)(
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
);
/**
Creates a copy of the current device path instance and returns a pointer to the next device path
instance.
@param DevicePathInstance On input, this holds the pointer to the current device path
instance. On output, this holds the pointer to the next
device path instance or NULL if there are no more device
path instances in the device path.
@param DevicePathInstanceSize On output, this holds the size of the device path instance,
in bytes or zero, if DevicePathInstance is NULL.
If NULL, then the instance size is not output.
@retval Pointer A pointer to the copy of the current device path instance.
@retval NULL DevicePathInstace was NULL on entry or there was insufficient memory.
**/
typedef
EFI_DEVICE_PATH_PROTOCOL*
( *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE)(
EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,
UINTN *DevicePathInstanceSize
);
/**
Creates a device node
@param NodeType NodeType is the device node type (EFI_DEVICE_PATH.Type) for
the new device node.
@param NodeSubType NodeSubType is the device node sub-type
EFI_DEVICE_PATH.SubType) for the new device node.
@param NodeLength NodeLength is the length of the device node
(EFI_DEVICE_PATH.Length) for the new device node.
@retval Pointer A pointer to the newly created device node.
@retval NULL NodeLength is less than
the size of the header or there was insufficient memory.
**/
typedef
EFI_DEVICE_PATH_PROTOCOL*
( *EFI_DEVICE_PATH_UTILS_CREATE_NODE)(
UINT8 NodeType,
UINT8 NodeSubType,
UINT16 NodeLength
);
/**
Returns whether a device path is multi-instance.
@param DevicePath Points to the device path. If NULL, then ignored.
@retval TRUE The device path has more than one instance
@retval FALSE The device path is empty or contains only a single instance.
**/
typedef
BOOLEAN
( *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE)(
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
///
/// This protocol is used to creates and manipulates device paths and device nodes.
///
typedef struct {
EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize;
EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH DuplicateDevicePath;
EFI_DEVICE_PATH_UTILS_APPEND_PATH AppendDevicePath;
EFI_DEVICE_PATH_UTILS_APPEND_NODE AppendDeviceNode;
EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE AppendDevicePathInstance;
EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE GetNextDevicePathInstance;
EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE IsDevicePathMultiInstance;
EFI_DEVICE_PATH_UTILS_CREATE_NODE CreateDeviceNode;
} EFI_DEVICE_PATH_UTILITIES_PROTOCOL;
extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid;
VOID
SetDevicePathEndNode (
VOID *Node
);
BOOLEAN
IsDevicePathValid (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
UINTN MaxSize
);
UINT8
DevicePathType (
CONST VOID *Node
);
UINT8
DevicePathSubType (
CONST VOID *Node
);
UINTN
DevicePathNodeLength (
CONST VOID *Node
);
EFI_DEVICE_PATH_PROTOCOL *
NextDevicePathNode (
CONST VOID *Node
);
BOOLEAN
IsDevicePathEndType (
CONST VOID *Node
);
BOOLEAN
IsDevicePathEnd (
CONST VOID *Node
);
BOOLEAN
IsDevicePathEndInstance (
CONST VOID *Node
);
UINT16
SetDevicePathNodeLength (
VOID *Node,
UINTN Length
);
VOID
SetDevicePathEndNode (
VOID *Node
);
UINTN
UefiDevicePathLibGetDevicePathSize (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibDuplicateDevicePath (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibAppendDevicePath (
CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,
CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath
);
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibAppendDevicePathNode (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode
);
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibAppendDevicePathInstance (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
);
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibGetNextDevicePathInstance (
EFI_DEVICE_PATH_PROTOCOL **DevicePath,
UINTN *Size
);
EFI_DEVICE_PATH_PROTOCOL *
UefiDevicePathLibCreateDeviceNode (
UINT8 NodeType,
UINT8 NodeSubType,
UINT16 NodeLength
);
BOOLEAN
UefiDevicePathLibIsDevicePathMultiInstance (
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
#endif

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'LzmaCompress' module build.
#
# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = LzmaCompress

View File

@ -1,7 +1,7 @@
## @file
# Windows makefile for C tools build.
#
# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -32,7 +32,8 @@ APPLICATIONS = \
Split \
TianoCompress \
VolInfo \
VfrCompile
VfrCompile \
DevicePath
all: libs apps install

View File

@ -6,7 +6,7 @@
# HOST_ARCH = ia64 or IA64 for IA64 build
# HOST_ARCH = Arm or ARM for ARM build
#
# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -15,7 +15,31 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
HOST_ARCH ?= IA32
ifndef HOST_ARCH
#
# If HOST_ARCH is not defined, then we use 'uname -m' to attempt
# try to figure out the appropriate HOST_ARCH.
#
uname_m = $(shell uname -m)
$(info Attempting to detect HOST_ARCH from 'uname -m': $(uname_m))
ifneq (,$(strip $(filter $(uname_m), x86_64 amd64)))
HOST_ARCH=X64
endif
ifeq ($(patsubst i%86,IA32,$(uname_m)),IA32)
HOST_ARCH=IA32
endif
ifneq (,$(findstring aarch64,$(uname_m)))
HOST_ARCH=AARCH64
endif
ifneq (,$(findstring arm,$(uname_m)))
HOST_ARCH=ARM
endif
ifndef HOST_ARCH
$(info Could not detected HOST_ARCH from uname results)
$(error HOST_ARCH is not defined!)
endif
$(info Detected HOST_ARCH of $(HOST_ARCH) using uname.)
endif
CYGWIN:=$(findstring CYGWIN, $(shell uname -s))
LINUX:=$(findstring Linux, $(shell uname -s))
@ -29,18 +53,18 @@ BUILD_LD ?= ld
LINKER ?= $(BUILD_CC)
ifeq ($(HOST_ARCH), IA32)
ARCH_INCLUDE = -I $(MAKEROOT)/Include/Ia32/
endif
ifeq ($(HOST_ARCH), X64)
else ifeq ($(HOST_ARCH), X64)
ARCH_INCLUDE = -I $(MAKEROOT)/Include/X64/
endif
ifeq ($(HOST_ARCH), ARM)
else ifeq ($(HOST_ARCH), ARM)
ARCH_INCLUDE = -I $(MAKEROOT)/Include/Arm/
endif
ifeq ($(HOST_ARCH), AARCH64)
else ifeq ($(HOST_ARCH), AARCH64)
ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/
else
$(error Bad HOST_ARCH)
endif
INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)

View File

@ -42,14 +42,16 @@ BIN_PATH = $(BASE_TOOLS_PATH)\Bin\Win32
LIB_PATH = $(BASE_TOOLS_PATH)\Lib\Win32
SYS_BIN_PATH = $(EDK_TOOLS_PATH)\Bin\Win32
SYS_LIB_PATH = $(EDK_TOOLS_PATH)\Lib\Win32
!ENDIF
!IF "$(HOST_ARCH)"=="X64"
!ELSEIF "$(HOST_ARCH)"=="X64"
ARCH_INCLUDE = $(SOURCE_PATH)\Include\X64
BIN_PATH = $(BASE_TOOLS_PATH)\Bin\Win64
LIB_PATH = $(BASE_TOOLS_PATH)\Lib\Win64
SYS_BIN_PATH = $(EDK_TOOLS_PATH)\Bin\Win64
SYS_LIB_PATH = $(EDK_TOOLS_PATH)\Lib\Win64
!ELSE
!ERROR "Bad HOST_ARCH"
!ENDIF
CC = cl.exe

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'Split' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = Split

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'TianoCompress' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = TianoCompress

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'VfrCompile' module build.
#
# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
# 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,7 +11,6 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = VfrCompile

View File

@ -41,6 +41,7 @@ ANTLR_INFO
#pragma warn -aus /* unused assignment of 'xxx' */
#endif
#pragma clang diagnostic ignored "-Wparentheses-equality"
#ifdef __USE_PROTOS
static void chkToken(char *, char *, char *, int);
@ -3252,7 +3253,7 @@ enum_def(fname)
zzMake0;
{
if ( (LA(1)==ID)&&(isDLGmaxToken(LATEXT(1))) ) {
if (!(isDLGmaxToken(LATEXT(1))) ) {zzfailed_pred(" isDLGmaxToken(LATEXT(1))",0 /* report */, { 0; /* no user action */ } );}
if (!(isDLGmaxToken(LATEXT(1))) ) {zzfailed_pred(" isDLGmaxToken(LATEXT(1))",0 /* report */, { ; /* no user action */ } );}
zzmatch(ID); zzCONSUME;
{
zzBLOCK(zztasp4);

View File

@ -53,6 +53,7 @@
#pragma warn -aus /* unused assignment of 'xxx' */
#endif
#pragma clang diagnostic ignored "-Wparentheses-equality"
#ifdef __USE_PROTOS
static void chkToken(char *, char *, char *, int);

View File

@ -1968,7 +1968,7 @@ ActionNode *p;
(p->pred_fail == NULL ? /* MR23/MR27 */
"0 /* report */" : "1 /* user action */"), /* MR23/MR27 */
(p->pred_fail == NULL ? /* MR23 */
"0; /* no user action */" : p->pred_fail)); /* MR23 */
"; /* no user action */" : p->pred_fail)); /* MR23 */
tabs--;
}
else /* not a predicate */
@ -2618,7 +2618,7 @@ TokNode *p;
(a->pred_fail == NULL ? /* MR23/MR27 */
"0 /* report */" : "1 /* user action */"), /* MR23/MR27 */
(a->pred_fail == NULL ? /* MR23 */
"0; /* no user action */" : a->pred_fail)); /* MR23 */
"; /* no user action */" : a->pred_fail)); /* MR23 */
tabs--;
/* Disabled in MR30 ************************************************************
And moved into genAction

View File

@ -39,6 +39,8 @@ Fix for Borland C++ 4.x & 5.x compiling with ALL warnings enabled
#pragma warn -aus /* unused assignment of 'xxx' */
#endif
#pragma clang diagnostic ignored "-Wparentheses-equality"
int action_no = 0; /* keep track of actions outputted */
int nfa_allocated = 0; /* keeps track of number of nfa nodes */
nfa_node **nfa_array = NULL;/* root of binary tree that stores nfa array */

View File

@ -42,7 +42,9 @@
#pragma warn -aus /* unused assignment of 'xxx' */
#endif
int action_no = 0; /* keep track of actions outputed */
#pragma clang diagnostic ignored "-Wparentheses-equality"
int action_no = 0; /* keep track of actions outputted */
int nfa_allocated = 0; /* keeps track of number of nfa nodes */
nfa_node **nfa_array = NULL;/* root of binary tree that stores nfa array */
nfa_node nfa_model_node; /* model to initialize new nodes */

View File

@ -844,7 +844,7 @@ CFormPkg::DeclarePendingQuestion (
// DisableIf
CIfrDisableIf DIObj;
DIObj.SetLineNo (LineNo);
*InsertOpcodeAddr = DIObj.GetObjBinAddr ();
*InsertOpcodeAddr = DIObj.GetObjBinAddr<CHAR8>();
//TrueOpcode
CIfrTrue TObj (LineNo);
@ -1925,7 +1925,7 @@ CIfrRecordInfoDB::IfrCreateDefaultForQuestion (
Obj = new CIfrObj (pOpHead->OpCode, NULL, pSNode->mBinBufLen, FALSE);
assert (Obj != NULL);
Obj->SetLineNo (pSNode->mLineNo);
ObjBinBuf = Obj->GetObjBinAddr();
ObjBinBuf = Obj->GetObjBinAddr<CHAR8>();
memcpy (ObjBinBuf, pSNode->mIfrBinBuf, (UINTN)pSNode->mBinBufLen);
delete Obj;
pSNode = pSNode->mNext;

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@ class CVfrDLGLexer : public VfrLexer
{
public:
CVfrDLGLexer (DLGFileInput *F) : VfrLexer (F) {};
INT32 errstd (char *Text)
void errstd (const char *Text)
{
printf ("unrecognized input '%s'\n", Text);
}
@ -986,7 +986,7 @@ vfrStatementDefaultStore :
<<
if (gCVfrDefaultStore.DefaultIdRegistered (DefaultId) == FALSE) {
CIfrDefaultStore DSObj;
_PCATCH(gCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), N->getText(), _STOSID(S->getText(), S->getLine()), DefaultId)), D->getLine();
_PCATCH(gCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr<CHAR8>(), N->getText(), _STOSID(S->getText(), S->getLine()), DefaultId)), D->getLine();
DSObj.SetLineNo(D->getLine());
DSObj.SetDefaultName (_STOSID(S->getText(), S->getLine()));
DSObj.SetDefaultId (DefaultId);
@ -1770,7 +1770,7 @@ vfrFormDefinition :
LObj3.SetNumber (0xffff); //add end label for UEFI, label number hardcode 0xffff
}
{CIfrEnd EObj; EObj.SetLineNo (E->getLine()); mLastFormEndAddr = EObj.GetObjBinAddr (); gAdjustOpcodeOffset = EObj.GetObjBinOffset ();}
{CIfrEnd EObj; EObj.SetLineNo (E->getLine()); mLastFormEndAddr = EObj.GetObjBinAddr<CHAR8>(); gAdjustOpcodeOffset = EObj.GetObjBinOffset ();}
>>
";"
;
@ -5675,7 +5675,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
//
CIfrDefaultStore DSObj;
gCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), (CHAR8 *) "Standard Defaults", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_STANDARD);
gCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr<CHAR8>(), (CHAR8 *) "Standard Defaults", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_STANDARD);
DSObj.SetLineNo (LineNo);
DSObj.SetDefaultName (EFI_STRING_ID_INVALID);
DSObj.SetDefaultId (EFI_HII_DEFAULT_CLASS_STANDARD);
@ -5685,7 +5685,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
//
CIfrDefaultStore DSObjMF;
gCVfrDefaultStore.RegisterDefaultStore (DSObjMF.GetObjBinAddr(), (CHAR8 *) "Standard ManuFacturing", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_MANUFACTURING);
gCVfrDefaultStore.RegisterDefaultStore (DSObjMF.GetObjBinAddr<CHAR8>(), (CHAR8 *) "Standard ManuFacturing", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_MANUFACTURING);
DSObjMF.SetLineNo (LineNo);
DSObjMF.SetDefaultName (EFI_STRING_ID_INVALID);
DSObjMF.SetDefaultId (EFI_HII_DEFAULT_CLASS_MANUFACTURING);

View File

@ -1,7 +1,7 @@
## @file
# GNU/Linux makefile for 'VolInfo' module build.
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
HOST_ARCH ?= IA32
MAKEROOT ?= ..
APPNAME = VolInfo

View File

@ -1,7 +1,7 @@
## @file
# Generate AutoGen.h, AutoGen.c and *.depex files
#
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -318,8 +318,8 @@ class WorkspaceAutoGen(AutoGen):
EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile)
# if Progress:
# Progress.Start("\nProcessing meta-data")
if Progress:
Progress.Start("\nProcessing meta-data")
if self.FdfFile:
#
@ -398,89 +398,10 @@ class WorkspaceAutoGen(AutoGen):
for Arch in self.ArchList:
Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]
DecPcds = {}
DecPcdsKey = set()
PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)
if GlobalData.BuildOptionPcd:
for i, pcd in enumerate(GlobalData.BuildOptionPcd):
if type(pcd) is tuple:
continue
(pcdname, pcdvalue) = pcd.split('=')
if not pcdvalue:
EdkLogger.error('build', AUTOGEN_ERROR, "No Value specified for the PCD %s." % (pcdname))
if '.' in pcdname:
(TokenSpaceGuidCName, TokenCName) = pcdname.split('.')
HasTokenSpace = True
else:
TokenCName = pcdname
TokenSpaceGuidCName = ''
HasTokenSpace = False
TokenSpaceGuidCNameList = []
FoundFlag = False
PcdDatumType = ''
NewValue = ''
for package in PGen.PackageList:
Guids = package.Guids
self._GuidDict.update(Guids)
for package in PGen.PackageList:
for key in package.Pcds:
PcdItem = package.Pcds[key]
if HasTokenSpace:
if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName):
PcdDatumType = PcdItem.DatumType
if pcdvalue.startswith('H'):
try:
pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True)
except BadExpression, Value:
if Value.result > 1:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %
(TokenSpaceGuidCName, TokenCName, pcdvalue, Value))
pcdvalue = 'H' + pcdvalue
NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)
FoundFlag = True
else:
if PcdItem.TokenCName == TokenCName:
if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList:
if len (TokenSpaceGuidCNameList) < 1:
TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName)
PcdDatumType = PcdItem.DatumType
TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName
if pcdvalue.startswith('H'):
try:
pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True)
except BadExpression, Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %
(TokenSpaceGuidCName, TokenCName, pcdvalue, Value))
pcdvalue = 'H' + pcdvalue
NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)
FoundFlag = True
else:
EdkLogger.error(
'build',
AUTOGEN_ERROR,
"The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0])
)
GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, NewValue)
if not FoundFlag:
if HasTokenSpace:
EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s.%s is not found in the DEC file." % (TokenSpaceGuidCName, TokenCName))
else:
EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s is not found in the DEC file." % (TokenCName))
for BuildData in PGen.BuildDatabase._CACHE_.values():
if BuildData.Arch != Arch:
continue
if BuildData.MetaFile.Ext == '.dec':
continue
for key in BuildData.Pcds:
PcdItem = BuildData.Pcds[key]
if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName):
PcdItem.DefaultValue = NewValue
if (TokenCName, TokenSpaceGuidCName) in PcdSet:
PcdSet[(TokenCName, TokenSpaceGuidCName)] = NewValue
SourcePcdDict = {'DynamicEx':[], 'PatchableInModule':[],'Dynamic':[],'FixedAtBuild':[]}
BinaryPcdDict = {'DynamicEx':[], 'PatchableInModule':[]}
@ -488,6 +409,7 @@ class WorkspaceAutoGen(AutoGen):
BinaryPcdDict_Keys = BinaryPcdDict.keys()
# generate the SourcePcdDict and BinaryPcdDict
PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)
for BuildData in PGen.BuildDatabase._CACHE_.values():
if BuildData.Arch != Arch:
continue
@ -630,6 +552,8 @@ class WorkspaceAutoGen(AutoGen):
ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]
PkgSet.update(ModuleData.Packages)
Pkgs = list(PkgSet) + list(PGen.PackageList)
DecPcds = {}
DecPcdsKey = set()
for Pkg in Pkgs:
for Pcd in Pkg.Pcds:
DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd]
@ -1245,6 +1169,7 @@ class PlatformAutoGen(AutoGen):
# get the original module/package/platform objects
self.BuildDatabase = Workspace.BuildDatabase
self.DscBuildDataObj = Workspace.Platform
self._GuidDict = Workspace._GuidDict
# flag indicating if the makefile/C-code file has been created or not
self.IsMakeFileCreated = False
@ -1405,9 +1330,8 @@ class PlatformAutoGen(AutoGen):
if len(Sku.VariableName) > 0:
VariableGuidStructure = Sku.VariableGuidValue
VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure)
if Pcd.Phase == "DXE":
for StorageName in Sku.DefaultStoreDict:
VariableInfo.append_variable(var_info(Index,pcdname,StorageName,SkuName, StringToArray(Sku.VariableName),VariableGuid, Sku.VariableAttribute , Sku.HiiDefaultValue,Sku.DefaultStoreDict[StorageName],Pcd.DatumType))
for StorageName in Sku.DefaultStoreDict:
VariableInfo.append_variable(var_info(Index,pcdname,StorageName,SkuName, StringToArray(Sku.VariableName),VariableGuid, Sku.VariableOffset, Sku.VariableAttribute , Sku.HiiDefaultValue,Sku.DefaultStoreDict[StorageName],Pcd.DatumType))
Index += 1
return VariableInfo
@ -1444,17 +1368,6 @@ class PlatformAutoGen(AutoGen):
# This interface should be invoked explicitly when platform action is created.
#
def CollectPlatformDynamicPcds(self):
# Override the platform Pcd's value by build option
if GlobalData.BuildOptionPcd:
for key in self.Platform.Pcds:
PlatformPcd = self.Platform.Pcds[key]
for PcdItem in GlobalData.BuildOptionPcd:
if (PlatformPcd.TokenSpaceGuidCName, PlatformPcd.TokenCName) == (PcdItem[0], PcdItem[1]):
PlatformPcd.DefaultValue = PcdItem[2]
if PlatformPcd.SkuInfoList:
Sku = PlatformPcd.SkuInfoList[PlatformPcd.SkuInfoList.keys()[0]]
Sku.DefaultValue = PcdItem[2]
break
for key in self.Platform.Pcds:
for SinglePcd in GlobalData.MixedPcd:
@ -1747,14 +1660,12 @@ class PlatformAutoGen(AutoGen):
if not FoundFlag :
# just pick the a value to determine whether is unicode string type
SkuValueMap = {}
SkuObjList = DscPcdEntry.SkuInfoList.items()
DefaultSku = DscPcdEntry.SkuInfoList.get('DEFAULT')
if DefaultSku:
PcdValue = DefaultSku.DefaultValue
if PcdValue not in SkuValueMap:
SkuValueMap[PcdValue] = []
VpdFile.Add(DscPcdEntry, 'DEFAULT',Sku.VpdOffset)
SkuValueMap[PcdValue].append(Sku)
for (SkuName,Sku) in DscPcdEntry.SkuInfoList.items():
defaultindex = SkuObjList.index(('DEFAULT',DefaultSku))
SkuObjList[0],SkuObjList[defaultindex] = SkuObjList[defaultindex],SkuObjList[0]
for (SkuName,Sku) in SkuObjList:
Sku.VpdOffset = Sku.VpdOffset.strip()
# Need to iterate DEC pcd information to get the value & datumtype
@ -1975,6 +1886,13 @@ class PlatformAutoGen(AutoGen):
NewOption = self.ToolDefinition["MAKE"]["FLAGS"].strip()
if NewOption != '':
self._BuildCommand += SplitOption(NewOption)
if "MAKE" in self.EdkIIBuildOption:
if "FLAGS" in self.EdkIIBuildOption["MAKE"]:
Flags = self.EdkIIBuildOption["MAKE"]["FLAGS"]
if Flags.startswith('='):
self._BuildCommand = [self._BuildCommand[0]] + [Flags[1:]]
else:
self._BuildCommand += [Flags]
return self._BuildCommand
## Get tool chain definition
@ -2434,11 +2352,6 @@ class PlatformAutoGen(AutoGen):
TokenCName = PcdItem[0]
break
if FromPcd != None:
if GlobalData.BuildOptionPcd:
for pcd in GlobalData.BuildOptionPcd:
if (FromPcd.TokenSpaceGuidCName, FromPcd.TokenCName) == (pcd[0], pcd[1]):
FromPcd.DefaultValue = pcd[2]
break
if ToPcd.Pending and FromPcd.Type not in [None, '']:
ToPcd.Type = FromPcd.Type
elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in [None, ''])\
@ -2466,22 +2379,9 @@ class PlatformAutoGen(AutoGen):
if FromPcd.SkuInfoList not in [None, '', []]:
ToPcd.SkuInfoList = FromPcd.SkuInfoList
# Add Flexible PCD format parse
PcdValue = ToPcd.DefaultValue
if PcdValue:
try:
ToPcd.DefaultValue = ValueExpression(PcdValue)(True)
except WrnExpression, Value:
ToPcd.DefaultValue = Value.result
except BadExpression, Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.DefaultValue, Value),
File=self.MetaFile)
if ToPcd.DefaultValue:
_GuidDict = {}
for Pkg in self.PackageList:
Guids = Pkg.Guids
_GuidDict.update(Guids)
try:
ToPcd.DefaultValue = ValueExpressionEx(ToPcd.DefaultValue, ToPcd.DatumType, _GuidDict)(True)
ToPcd.DefaultValue = ValueExpressionEx(ToPcd.DefaultValue, ToPcd.DatumType, self._GuidDict)(True)
except BadExpression, Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.DefaultValue, Value),
File=self.MetaFile)
@ -2495,7 +2395,7 @@ class PlatformAutoGen(AutoGen):
ToPcd.validlists = FromPcd.validlists
ToPcd.expressions = FromPcd.expressions
if ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:
if FromPcd != None and ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:
EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \
% (ToPcd.TokenSpaceGuidCName, TokenCName))
Value = ToPcd.DefaultValue
@ -2568,6 +2468,19 @@ class PlatformAutoGen(AutoGen):
break
if Flag:
self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module)
# use PCD value to calculate the MaxDatumSize when it is not specified
for Name, Guid in Pcds:
Pcd = Pcds[Name, Guid]
if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]:
Value = Pcd.DefaultValue
if Value in [None, '']:
Pcd.MaxDatumSize = '1'
elif Value[0] == 'L':
Pcd.MaxDatumSize = str((len(Value) - 2) * 2)
elif Value[0] == '{':
Pcd.MaxDatumSize = str(len(Value.split(',')))
else:
Pcd.MaxDatumSize = str(len(Value) - 1)
return Pcds.values()
## Resolve library names to library modules
@ -4149,10 +4062,13 @@ class ModuleAutoGen(AutoGen):
AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']]
OutputDir = self.OutputDir.replace('\\', '/').strip('/')
DebugDir = self.DebugDir.replace('\\', '/').strip('/')
for Item in self.CodaTargetList:
File = Item.Target.Path.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/')
File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/')
if File not in self.OutputFile:
self.OutputFile.append(File)
if os.path.isabs(File):
File = File.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/')
if Item.Target.Ext.lower() == '.aml':
AsBuiltInfDict['binary_item'] += ['ASL|' + File]
elif Item.Target.Ext.lower() == '.acpi':

View File

@ -916,11 +916,8 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName
FixPcdSizeTokenName = '_PCD_SIZE_' + TokenCName
if GlobalData.BuildOptionPcd:
for PcdItem in GlobalData.BuildOptionPcd:
if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]):
Pcd.DefaultValue = PcdItem[2]
break
if Pcd.PcdValueFromComm:
Pcd.DefaultValue = Pcd.PcdValueFromComm
if Pcd.Type in gDynamicExPcd:
TokenNumber = int(Pcd.TokenValue, 0)
@ -1215,12 +1212,8 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
PatchPcdSizeTokenName = '_PCD_PATCHABLE_' + TokenCName +'_SIZE'
PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName
if GlobalData.BuildOptionPcd:
for PcdItem in GlobalData.BuildOptionPcd:
if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]):
Pcd.DefaultValue = PcdItem[2]
break
if Pcd.PcdValueFromComm:
Pcd.DefaultValue = Pcd.PcdValueFromComm
#
# Write PCDs
#

View File

@ -1,7 +1,7 @@
## @file
# Create makefile for MS nmake and GNU make
#
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -798,9 +798,13 @@ cleanlib:
Tool = Flag
break
if Tool:
if 'PATH' not in self._AutoGenObject._BuildOption[Tool]:
EdkLogger.error("build", AUTOGEN_ERROR, "%s_PATH doesn't exist in %s ToolChain and %s Arch." %(Tool, self._AutoGenObject.ToolChain, self._AutoGenObject.Arch), ExtraData="[%s]" % str(self._AutoGenObject))
SingleCommandLength += len(self._AutoGenObject._BuildOption[Tool]['PATH'])
for item in SingleCommandList[1:]:
if FlagDict[Tool]['Macro'] in item:
if 'FLAGS' not in self._AutoGenObject._BuildOption[Tool]:
EdkLogger.error("build", AUTOGEN_ERROR, "%s_FLAGS doesn't exist in %s ToolChain and %s Arch." %(Tool, self._AutoGenObject.ToolChain, self._AutoGenObject.Arch), ExtraData="[%s]" % str(self._AutoGenObject))
Str = self._AutoGenObject._BuildOption[Tool]['FLAGS']
for Option in self._AutoGenObject.BuildOption.keys():
for Attr in self._AutoGenObject.BuildOption[Option]:
@ -1547,18 +1551,15 @@ class TopLevelMakefile(BuildFile):
if GlobalData.gIgnoreSource:
ExtraOption += " --ignore-sources"
if GlobalData.BuildOptionPcd:
for index, option in enumerate(GlobalData.gCommand):
if "--pcd" == option and GlobalData.gCommand[index+1]:
pcdName, pcdValue = GlobalData.gCommand[index+1].split('=')
if pcdValue.startswith('H'):
pcdValue = 'H' + '"' + pcdValue[1:] + '"'
ExtraOption += " --pcd " + pcdName + '=' + pcdValue
elif pcdValue.startswith('L'):
pcdValue = 'L' + '"' + pcdValue[1:] + '"'
ExtraOption += " --pcd " + pcdName + '=' + pcdValue
else:
ExtraOption += " --pcd " + GlobalData.gCommand[index+1]
for pcd in GlobalData.BuildOptionPcd:
if pcd[2]:
pcdname = '.'.join(pcd[0:3])
else:
pcdname = '.'.join(pcd[0:2])
if pcd[3].startswith('{'):
ExtraOption += " --pcd " + pcdname + '=' + 'H' + '"' + pcd[3] + '"'
else:
ExtraOption += " --pcd " + pcdname + '=' + pcd[3]
MakefileName = self._FILE_NAME_[self._FileType]
SubBuildCommandList = []

View File

@ -980,8 +980,6 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
def CreatePcdDataBase(PcdDBData):
delta = {}
basedata = {}
if not PcdDBData:
return ""
for skuname,skuid in PcdDBData:
if len(PcdDBData[(skuname,skuid)][1]) != len(PcdDBData[("DEFAULT","0")][1]):
EdkLogger.ERROR("The size of each sku in one pcd are not same")
@ -1024,6 +1022,19 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase):
def prune_sku(pcd,skuname):
new_pcd = copy.deepcopy(pcd)
new_pcd.SkuInfoList = {skuname:pcd.SkuInfoList[skuname]}
new_pcd.isinit = 'INIT'
if new_pcd.DatumType in ['UINT8','UINT16','UINT32','UINT64']:
for skuobj in pcd.SkuInfoList.values():
if skuobj.DefaultValue:
defaultvalue = int(skuobj.DefaultValue,16) if skuobj.DefaultValue.upper().startswith("0X") else int(skuobj.DefaultValue,10)
if defaultvalue != 0:
new_pcd.isinit = "INIT"
break
elif skuobj.VariableName:
new_pcd.isinit = "INIT"
break
else:
new_pcd.isinit = "UNINIT"
return new_pcd
DynamicPcds = Platform.DynamicPcdList
DynamicPcdSet_Sku = {(SkuName,skuobj.SkuId):[] for pcd in DynamicPcds for (SkuName,skuobj) in pcd.SkuInfoList.items() }
@ -1048,9 +1059,12 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase):
AdditionalAutoGenH, AdditionalAutoGenC = CreateAutoGen(PcdDriverAutoGenData)
else:
AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer,VarCheckTab = CreatePcdDatabasePhaseSpecificAutoGen (Platform,{}, Phase)
final_data = ()
for item in PcdDbBuffer:
final_data += unpack("B",item)
PcdDBData[("DEFAULT","0")] = (PcdDbBuffer, final_data)
PcdDbBuffer = CreatePcdDataBase(PcdDBData)
return AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer
return AdditionalAutoGenH, AdditionalAutoGenC, CreatePcdDataBase(PcdDBData)
## Create PCD database in DXE or PEI phase
#
# @param Platform The platform object
@ -1171,12 +1185,6 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
CName = PcdItem[0]
if GlobalData.BuildOptionPcd:
for PcdItem in GlobalData.BuildOptionPcd:
if (Pcd.TokenSpaceGuidCName, CName) == (PcdItem[0], PcdItem[1]):
Pcd.DefaultValue = PcdItem[2]
break
EdkLogger.debug(EdkLogger.DEBUG_3, "PCD: %s %s (%s : %s)" % (CName, TokenSpaceGuidCName, Pcd.Phase, Phase))
if Pcd.Phase == 'PEI':
@ -1401,8 +1409,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
if Sku.DefaultValue == 'TRUE':
Pcd.InitString = 'INIT'
else:
if int(Sku.DefaultValue, 0) != 0:
Pcd.InitString = 'INIT'
Pcd.InitString = Pcd.isinit
#
# For UNIT64 type PCD's value, ULL should be append to avoid
# warning under linux building environment.
@ -1493,12 +1500,6 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
CName = PcdItem[0]
if GlobalData.BuildOptionPcd:
for PcdItem in GlobalData.BuildOptionPcd:
if (Pcd.TokenSpaceGuidCName, CName) == (PcdItem[0], PcdItem[1]):
Pcd.DefaultValue = PcdItem[2]
break
EdkLogger.debug(EdkLogger.DEBUG_1, "PCD = %s.%s" % (CName, TokenSpaceGuidCName))
EdkLogger.debug(EdkLogger.DEBUG_1, "phase = %s" % Phase)
EdkLogger.debug(EdkLogger.DEBUG_1, "GeneratedTokenNumber = %s" % str(GeneratedTokenNumber))

View File

@ -21,7 +21,7 @@ from Common.VariableAttributes import VariableAttributes
from Common.Misc import *
import collections
var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_attribute,pcd_default_value, default_value, data_type")
var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type")
NvStorageHeaderSize = 28
VariableHeaderSize = 32
@ -76,7 +76,55 @@ class VariableMgr(object):
value_str += ",".join(default_var_bin_strip)
value_str += "}"
return value_str
def combine_variable(self):
indexedvarinfo = collections.OrderedDict()
for item in self.VarInfo:
if (item.skuname,item.defaultstoragename, item.var_name,item.var_guid) not in indexedvarinfo:
indexedvarinfo[(item.skuname,item.defaultstoragename, item.var_name,item.var_guid) ] = []
indexedvarinfo[(item.skuname,item.defaultstoragename, item.var_name,item.var_guid)].append(item)
for key in indexedvarinfo:
sku_var_info_offset_list = indexedvarinfo[key]
if len(sku_var_info_offset_list) == 1:
continue
newvalue = {}
for item in sku_var_info_offset_list:
data_type = item.data_type
value_list = item.default_value.strip("{").strip("}").split(",")
if data_type in ["BOOLEAN","UINT8","UINT16","UINT32","UINT64"]:
if data_type == ["BOOLEAN","UINT8"]:
data_flag = "=B"
elif data_type == "UINT16":
data_flag = "=H"
elif data_type == "UINT32":
data_flag = "=L"
elif data_type == "UINT64":
data_flag = "=Q"
data = value_list[0]
value_list = []
for data_byte in pack(data_flag,int(data,16) if data.upper().startswith('0X') else int(data)):
value_list += [hex(unpack("B",data_byte)[0])]
newvalue[int(item.var_offset,16) if item.var_offset.upper().startswith("0X") else int(item.var_offset)] = value_list
try:
newvaluestr = "{" + ",".join(self.assemble_variable(newvalue)) +"}"
except:
EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset conflict in PCDs: %s \n" % (" and ".join([item.pcdname for item in sku_var_info_offset_list])))
n = sku_var_info_offset_list[0]
indexedvarinfo[key] = [var_info(n.pcdindex,n.pcdname,n.defaultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,newvaluestr , newvaluestr , "VOID*")]
self.VarInfo = [item[0] for item in indexedvarinfo.values()]
def assemble_variable(self, valuelist):
ordered_value = [valuelist[k] for k in sorted(valuelist.keys())]
ordered_offset = sorted(valuelist.keys())
var_value = []
num = 0
for offset in ordered_offset:
if offset < len(var_value):
raise
for _ in xrange(offset - len(var_value)):
var_value.append('0x00')
var_value += ordered_value[num]
num +=1
return var_value
def process_variable_data(self):
var_data = dict()
@ -134,6 +182,7 @@ class VariableMgr(object):
return var_data
def new_process_varinfo(self):
self.combine_variable()
var_data = self.process_variable_data()

View File

@ -2,7 +2,7 @@
# This file include GenVpd class for fix the Vpd type PCD offset, and PcdEntry for describe
# and process each entry of vpd type PCD.
#
# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -35,7 +35,7 @@ _FORMAT_CHAR = {1: 'B',
#
class PcdEntry:
def __init__(self, PcdCName, SkuId,PcdOffset, PcdSize, PcdValue, Lineno=None, FileName=None, PcdUnpackValue=None,
PcdBinOffset=None, PcdBinSize=None):
PcdBinOffset=None, PcdBinSize=None, Alignment=None):
self.PcdCName = PcdCName.strip()
self.SkuId = SkuId.strip()
self.PcdOffset = PcdOffset.strip()
@ -46,6 +46,7 @@ class PcdEntry:
self.PcdUnpackValue = PcdUnpackValue
self.PcdBinOffset = PcdBinOffset
self.PcdBinSize = PcdBinSize
self.Alignment = Alignment
if self.PcdValue == '' :
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
@ -61,7 +62,7 @@ class PcdEntry:
self._GenOffsetValue ()
## Analyze the string value to judge the PCD's datum type euqal to Boolean or not.
## Analyze the string value to judge the PCD's datum type equal to Boolean or not.
#
# @param ValueString PCD's value
# @param Size PCD's size
@ -164,18 +165,18 @@ class PcdEntry:
## Pack VOID* type VPD PCD's value form string to binary type.
#
# The VOID* type of string divided into 3 sub-type:
# 1: L"String", Unicode type string.
# 2: "String", Ascii type string.
# 1: L"String"/L'String', Unicode type string.
# 2: "String"/'String', Ascii type string.
# 3: {bytearray}, only support byte-array.
#
# @param ValueString The Integer type string for pack.
#
def _PackPtrValue(self, ValueString, Size):
if ValueString.startswith('L"'):
if ValueString.startswith('L"') or ValueString.startswith("L'"):
self._PackUnicode(ValueString, Size)
elif ValueString.startswith('{') and ValueString.endswith('}'):
self._PackByteArray(ValueString, Size)
elif ValueString.startswith('"') and ValueString.endswith('"'):
elif (ValueString.startswith('"') and ValueString.endswith('"')) or (ValueString.startswith("'") and ValueString.endswith("'")):
self._PackString(ValueString, Size)
else:
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
@ -183,7 +184,7 @@ class PcdEntry:
## Pack an Ascii PCD value.
#
# An Ascii string for a PCD should be in format as "".
# An Ascii string for a PCD should be in format as ""/''.
#
def _PackString(self, ValueString, Size):
if (Size < 0):
@ -191,11 +192,14 @@ class PcdEntry:
"Invalid parameter Size %s of PCD %s!(File: %s Line: %s)" % (self.PcdBinSize, self.PcdCName, self.FileName, self.Lineno))
if (ValueString == ""):
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter ValueString %s of PCD %s!(File: %s Line: %s)" % (self.PcdUnpackValue, self.PcdCName, self.FileName, self.Lineno))
if (len(ValueString) < 2):
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "For PCD: %s ,ASCII string %s at least contains two!(File: %s Line: %s)" % (self.PcdCName, self.PcdUnpackValue, self.FileName, self.Lineno))
QuotedFlag = True
if ValueString.startswith("'"):
QuotedFlag = False
ValueString = ValueString[1:-1]
if len(ValueString) + 1 > Size:
# No null-terminator in 'string'
if (QuotedFlag and len(ValueString) + 1 > Size) or (not QuotedFlag and len(ValueString) > Size):
EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW,
"PCD value string %s is exceed to size %d(File: %s Line: %s)" % (ValueString, Size, self.FileName, self.Lineno))
try:
@ -258,19 +262,20 @@ class PcdEntry:
## Pack a unicode PCD value into byte array.
#
# A unicode string for a PCD should be in format as L"".
# A unicode string for a PCD should be in format as L""/L''.
#
def _PackUnicode(self, UnicodeString, Size):
if (Size < 0):
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter Size %s of PCD %s!(File: %s Line: %s)" % \
(self.PcdBinSize, self.PcdCName, self.FileName, self.Lineno))
if (len(UnicodeString) < 3):
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "For PCD: %s ,ASCII string %s at least contains two!(File: %s Line: %s)" % \
(self.PcdCName, self.PcdUnpackValue, self.FileName, self.Lineno))
QuotedFlag = True
if UnicodeString.startswith("L'"):
QuotedFlag = False
UnicodeString = UnicodeString[2:-1]
if (len(UnicodeString) + 1) * 2 > Size:
# No null-terminator in L'string'
if (QuotedFlag and (len(UnicodeString) + 1) * 2 > Size) or (not QuotedFlag and len(UnicodeString) * 2 > Size):
EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW,
"The size of unicode string %s is too larger for size %s(File: %s Line: %s)" % \
(UnicodeString, Size, self.FileName, self.Lineno))
@ -434,6 +439,7 @@ class GenVPD :
else:
Alignment = 1
PCD.Alignment = Alignment
if PCD.PcdOffset != '*':
if PCD.PcdOccupySize % Alignment != 0:
if PCD.PcdUnpackValue.startswith("{"):
@ -444,6 +450,7 @@ class GenVPD :
if PCD.PcdOccupySize % Alignment != 0:
PCD.PcdOccupySize = (PCD.PcdOccupySize / Alignment + 1) * Alignment
PackSize = PCD.PcdOccupySize
if PCD._IsBoolean(PCD.PcdValue, PCD.PcdSize):
PCD._PackBooleanValue(PCD.PcdValue)
self.FileLinesList[count] = PCD
@ -518,6 +525,8 @@ class GenVPD :
# The offset start from 0
NowOffset = 0
for Pcd in self.PcdUnknownOffsetList :
if NowOffset % Pcd.Alignment != 0:
NowOffset = (NowOffset/ Pcd.Alignment + 1) * Pcd.Alignment
Pcd.PcdBinOffset = NowOffset
Pcd.PcdOffset = str(hex(Pcd.PcdBinOffset))
NowOffset += Pcd.PcdOccupySize
@ -580,6 +589,8 @@ class GenVPD :
needFixPcdSize = eachUnfixedPcd.PcdOccupySize
# Not been fixed
if eachUnfixedPcd.PcdOffset == '*' :
if LastOffset % eachUnfixedPcd.Alignment != 0:
LastOffset = (LastOffset / eachUnfixedPcd.Alignment + 1) * eachUnfixedPcd.Alignment
# The offset un-fixed pcd can write into this free space
if needFixPcdSize <= (NowOffset - LastOffset) :
# Change the offset value of un-fixed pcd
@ -632,6 +643,9 @@ class GenVPD :
NeedFixPcd = self.PcdUnknownOffsetList[0]
NeedFixPcd.PcdBinOffset = LastPcd.PcdBinOffset + LastPcd.PcdOccupySize
if NeedFixPcd.PcdBinOffset % NeedFixPcd.Alignment != 0:
NeedFixPcd.PcdBinOffset = (NeedFixPcd.PcdBinOffset / NeedFixPcd.Alignment + 1) * NeedFixPcd.Alignment
NeedFixPcd.PcdOffset = str(hex(NeedFixPcd.PcdBinOffset))
# Insert this pcd into fixed offset pcd list's tail.

View File

@ -1,7 +1,7 @@
## @file
# This file is used to parse and evaluate expression in directive or PCD value.
#
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -15,7 +15,7 @@
from Common.GlobalData import *
from CommonDataClass.Exceptions import BadExpression
from CommonDataClass.Exceptions import WrnExpression
from Misc import GuidStringToGuidStructureString, ParseFieldValue
from Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueAnArray
import Common.EdkLogger as EdkLogger
import copy
@ -45,15 +45,28 @@ ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARC
# For example: abc"de\"f"ghi"jkl"mn will be: ['abc', '"de\"f"', 'ghi', '"jkl"', 'mn']
#
def SplitString(String):
# There might be escaped quote: "abc\"def\\\"ghi"
Str = String.replace('\\\\', '//').replace('\\\"', '\\\'')
# There might be escaped quote: "abc\"def\\\"ghi", 'abc\'def\\\'ghi'
Str = String
RetList = []
InQuote = False
InSingleQuote = False
InDoubleQuote = False
Item = ''
for i, ch in enumerate(Str):
if ch == '"':
InQuote = not InQuote
if not InQuote:
if ch == '"' and not InSingleQuote:
if Str[i - 1] != '\\':
InDoubleQuote = not InDoubleQuote
if not InDoubleQuote:
Item += String[i]
RetList.append(Item)
Item = ''
continue
if Item:
RetList.append(Item)
Item = ''
elif ch == "'" and not InDoubleQuote:
if Str[i - 1] != '\\':
InSingleQuote = not InSingleQuote
if not InSingleQuote:
Item += String[i]
RetList.append(Item)
Item = ''
@ -62,12 +75,75 @@ def SplitString(String):
RetList.append(Item)
Item = ''
Item += String[i]
if InQuote:
if InSingleQuote or InDoubleQuote:
raise BadExpression(ERR_STRING_TOKEN % Item)
if Item:
RetList.append(Item)
return RetList
def SplitPcdValueString(String):
# There might be escaped comma in GUID() or DEVICE_PATH() or " "
# or ' ' or L' ' or L" "
Str = String
RetList = []
InParenthesis = 0
InSingleQuote = False
InDoubleQuote = False
Item = ''
for i, ch in enumerate(Str):
if ch == '(':
InParenthesis += 1
if ch == ')':
if InParenthesis:
InParenthesis -= 1
else:
raise BadExpression(ERR_STRING_TOKEN % Item)
if ch == '"' and not InSingleQuote:
if String[i-1] != '\\':
InDoubleQuote = not InDoubleQuote
if ch == "'" and not InDoubleQuote:
if String[i-1] != '\\':
InSingleQuote = not InSingleQuote
if ch == ',':
if InParenthesis or InSingleQuote or InDoubleQuote:
Item += String[i]
continue
elif Item:
RetList.append(Item)
Item = ''
continue
Item += String[i]
if InSingleQuote or InDoubleQuote or InParenthesis:
raise BadExpression(ERR_STRING_TOKEN % Item)
if Item:
RetList.append(Item)
return RetList
def IsValidCString(Str):
ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')
if not ValidString.match(Str):
return False
return True
def BuildOptionValue(PcdValue, GuidDict):
IsArray = False
if PcdValue.startswith('H'):
InputValue = PcdValue[1:]
elif PcdValue.startswith("L'") or PcdValue.startswith("'"):
InputValue = PcdValue
elif PcdValue.startswith('L'):
InputValue = 'L"' + PcdValue[1:] + '"'
else:
InputValue = PcdValue
if IsFieldValueAnArray(InputValue):
IsArray = True
if IsArray:
try:
PcdValue = ValueExpressionEx(InputValue, 'VOID*', GuidDict)(True)
except:
pass
return PcdValue
## ReplaceExprMacro
#
def ReplaceExprMacro(String, Macros, ExceptionList = None):
@ -157,19 +233,9 @@ class ValueExpression(object):
def Eval(Operator, Oprand1, Oprand2 = None):
WrnExp = None
if Operator not in ["in", "not in"] and (type(Oprand1) == type('') or type(Oprand2) == type('')):
if type(Oprand1) == type(''):
if Oprand1[0] in ['"', "'"] or Oprand1.startswith('L"') or Oprand1.startswith("L'")or Oprand1.startswith('UINT'):
Oprand1, Size = ParseFieldValue(Oprand1)
else:
Oprand1,Size = ParseFieldValue('"' + Oprand1 + '"')
if type(Oprand2) == type(''):
if Oprand2[0] in ['"', "'"] or Oprand2.startswith('L"') or Oprand2.startswith("L'") or Oprand2.startswith('UINT'):
Oprand2, Size = ParseFieldValue(Oprand2)
else:
Oprand2, Size = ParseFieldValue('"' + Oprand2 + '"')
if type(Oprand1) == type('') or type(Oprand2) == type(''):
raise BadExpression(ERR_STRING_EXPR % Operator)
if Operator not in ["==", "!=", ">=", "<=", ">", "<", "in", "not in"] and \
(type(Oprand1) == type('') or type(Oprand2) == type('')):
raise BadExpression(ERR_STRING_EXPR % Operator)
if Operator in ['in', 'not in']:
if type(Oprand1) != type(''):
Oprand1 = IntToStr(Oprand1)
@ -251,9 +317,6 @@ class ValueExpression(object):
self._Expr = Expression
self._NoProcess = True
return
if Expression.strip().startswith('{') and Expression.strip().endswith('}'):
self._Expr = Expression
self._NoProcess = True
self._Expr = ReplaceExprMacro(Expression.strip(),
SymbolTable,
@ -293,13 +356,13 @@ class ValueExpression(object):
self._Token = self._Expr
if self.__IsNumberToken():
return self._Expr
Token = ''
try:
Token = self._GetToken()
if type(Token) == type('') and Token.startswith('{') and Token.endswith('}') and self._Idx >= self._Len:
return self._Expr
except BadExpression:
pass
if type(Token) == type('') and Token.startswith('{') and Token.endswith('}') and self._Idx >= self._Len:
return self._Expr
self._Idx = 0
self._Token = ''
@ -454,14 +517,23 @@ class ValueExpression(object):
Radix = 10
if self._Token.lower()[0:2] == '0x' and len(self._Token) > 2:
Radix = 16
if self._Token.startswith('"') or self._Token.startswith("'")\
or self._Token.startswith("L'") or self._Token.startswith('L"'):
if self._Token.startswith('"') or self._Token.startswith('L"'):
Flag = 0
for Index in range(len(self._Token)):
if self._Token[Index] in ['"', "'"]:
if self._Token[Index] in ['"']:
if self._Token[Index - 1] == '\\':
continue
Flag += 1
if Flag == 2:
self._Token = ParseFieldValue(self._Token)[0]
if Flag == 2 and self._Token.endswith('"'):
return True
if self._Token.startswith("'") or self._Token.startswith("L'"):
Flag = 0
for Index in range(len(self._Token)):
if self._Token[Index] in ["'"]:
if self._Token[Index - 1] == '\\':
continue
Flag += 1
if Flag == 2 and self._Token.endswith("'"):
return True
try:
self._Token = int(self._Token, Radix)
@ -507,16 +579,25 @@ class ValueExpression(object):
self._Idx += 1
# Replace escape \\\", \"
Expr = self._Expr[self._Idx:].replace('\\\\', '//').replace('\\\"', '\\\'')
for Ch in Expr:
self._Idx += 1
if Ch == '"' or Ch == "'":
break
self._Token = self._LiteralToken = self._Expr[Idx:self._Idx]
if self._Token.startswith('"') and not self._Token.endswith('"'):
raise BadExpression(ERR_STRING_TOKEN % self._Token)
if self._Token.startswith("'") and not self._Token.endswith("'"):
raise BadExpression(ERR_STRING_TOKEN % self._Token)
if self._Expr[Idx] == '"':
Expr = self._Expr[self._Idx:].replace('\\\\', '//').replace('\\\"', '\\\'')
for Ch in Expr:
self._Idx += 1
if Ch == '"':
break
self._Token = self._LiteralToken = self._Expr[Idx:self._Idx]
if not self._Token.endswith('"'):
raise BadExpression(ERR_STRING_TOKEN % self._Token)
#Replace escape \\\', \'
elif self._Expr[Idx] == "'":
Expr = self._Expr[self._Idx:].replace('\\\\', '//').replace("\\\'", "\\\"")
for Ch in Expr:
self._Idx += 1
if Ch == "'":
break
self._Token = self._LiteralToken = self._Expr[Idx:self._Idx]
if not self._Token.endswith("'"):
raise BadExpression(ERR_STRING_TOKEN % self._Token)
self._Token = self._Token[1:-1]
return self._Token
@ -593,11 +674,10 @@ class ValueExpression(object):
if self.HexPattern.match(self._LiteralToken):
Token = self._LiteralToken[2:]
Token = Token.lstrip('0')
if not Token:
self._LiteralToken = '0x0'
else:
self._LiteralToken = '0x' + Token.lower()
self._LiteralToken = '0x' + Token
return True
return False
@ -617,24 +697,16 @@ class ValueExpression(object):
self._Idx += 1
UStr = self.__GetString()
self._Token = 'L"' + UStr + '"'
self._Token, Size = ParseFieldValue(self._Token)
return self._Token
elif Expr.startswith("L'"):
# Skip L
self._Idx += 1
UStr = self.__GetString()
self._Token = "L'" + UStr + "'"
self._Token, Size = ParseFieldValue(self._Token)
return self._Token
elif Expr.startswith('"'):
UStr = self.__GetString()
self._Token = '"' + UStr + '"'
self._Token, Size = ParseFieldValue(self._Token)
return self._Token
elif Expr.startswith("'"):
UStr = self.__GetString()
self._Token = "'" + UStr + "'"
self._Token, Size = ParseFieldValue(self._Token)
return self._Token
elif Expr.startswith('UINT'):
Re = re.compile('(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
@ -734,110 +806,137 @@ class ValueExpressionEx(ValueExpression):
PcdValue = self.PcdValue
try:
PcdValue = ValueExpression.__call__(self, RealValue, Depth)
if self.PcdType == 'VOID*' and (PcdValue.startswith("'") or PcdValue.startswith("L'")):
PcdValue, Size = ParseFieldValue(PcdValue)
PcdValueList = []
for I in range(Size):
PcdValueList.append('0x%02X'%(PcdValue & 0xff))
PcdValue = PcdValue >> 8
PcdValue = '{' + ','.join(PcdValueList) + '}'
elif self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN'] and (PcdValue.startswith("'") or \
PcdValue.startswith('"') or PcdValue.startswith("L'") or PcdValue.startswith('L"') or PcdValue.startswith('{')):
raise BadExpression
except WrnExpression, Value:
PcdValue = Value.result
if PcdValue == 'True':
PcdValue = '1'
if PcdValue == 'False':
PcdValue = '0'
if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
PcdValue = PcdValue.strip()
if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'):
PcdValue = PcdValue[1:-1].split(',')
if type(PcdValue) == type([]):
TmpValue = 0
Size = 0
for Item in PcdValue:
if Item.startswith('UINT16'):
ItemSize = 2
elif Item.startswith('UINT32'):
ItemSize = 4
elif Item.startswith('UINT64'):
ItemSize = 8
else:
ItemSize = 0
Item = ValueExpressionEx(Item, self.PcdType, self._Symb)(True)
if ItemSize == 0:
ItemValue, ItemSize = ParseFieldValue(Item)
else:
ItemValue = ParseFieldValue(Item)[0]
if type(ItemValue) == type(''):
ItemValue = int(ItemValue, 16) if ItemValue.startswith('0x') else int(ItemValue)
TmpValue = (ItemValue << (Size * 8)) | TmpValue
Size = Size + ItemSize
else:
TmpValue, Size = ParseFieldValue(PcdValue)
if type(TmpValue) == type(''):
TmpValue = int(TmpValue)
else:
PcdValue = '0x%0{}X'.format(Size) % (TmpValue)
if TmpValue < 0:
raise BadExpression('Type %s PCD Value is negative' % self.PcdType)
if self.PcdType == 'UINT8' and Size > 1:
raise BadExpression('Type %s PCD Value Size is Larger than 1 byte' % self.PcdType)
if self.PcdType == 'UINT16' and Size > 2:
raise BadExpression('Type %s PCD Value Size is Larger than 2 byte' % self.PcdType)
if self.PcdType == 'UINT32' and Size > 4:
raise BadExpression('Type %s PCD Value Size is Larger than 4 byte' % self.PcdType)
if self.PcdType == 'UINT64' and Size > 8:
raise BadExpression('Type %s PCD Value Size is Larger than 8 byte' % self.PcdType)
if self.PcdType in ['VOID*']:
try:
TmpValue = long(PcdValue)
TmpList = []
if TmpValue.bit_length() == 0:
PcdValue = '{0x00}'
else:
for I in range((TmpValue.bit_length() + 7) / 8):
TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff))
PcdValue = '{' + ', '.join(TmpList) + '}'
except:
if PcdValue.strip().startswith('{'):
PcdValue = PcdValue.strip()[1:-1].strip()
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('}'):
PcdValue = SplitPcdValueString(PcdValue[1:-1])
if type(PcdValue) == type([]):
TmpValue = 0
Size = 0
ValueStr = ''
TokenSpaceGuidName = ''
if PcdValue.startswith('GUID') and PcdValue.endswith(')'):
try:
TokenSpaceGuidName = re.search('GUID\((\w+)\)', PcdValue).group(1)
except:
pass
if TokenSpaceGuidName and TokenSpaceGuidName in self._Symb:
PcdValue = 'GUID(' + self._Symb[TokenSpaceGuidName] + ')'
elif TokenSpaceGuidName:
raise BadExpression('%s not found in DEC file' % TokenSpaceGuidName)
ValueType = ''
for Item in PcdValue:
Item = Item.strip()
if Item.startswith('UINT8'):
ItemSize = 1
ValueType = 'UINT8'
elif Item.startswith('UINT16'):
ItemSize = 2
ValueType = 'UINT16'
elif Item.startswith('UINT32'):
ItemSize = 4
ValueType = 'UINT32'
elif Item.startswith('UINT64'):
ItemSize = 8
ValueType = 'UINT64'
elif Item.startswith('"') or Item.startswith("'") or Item.startswith('L'):
ItemSize = 0
ValueType = 'VOID*'
else:
ItemSize = 0
ValueType = 'UINT8'
Item = ValueExpressionEx(Item, ValueType, self._Symb)(True)
ListItem, Size = ParseFieldValue(PcdValue)
elif PcdValue.startswith('DEVICE_PATH') and PcdValue.endswith(')'):
ListItem, Size = ParseFieldValue(PcdValue)
else:
ListItem = PcdValue.split(',')
if ItemSize == 0:
try:
tmpValue = int(Item, 16) if Item.upper().startswith('0X') else int(Item, 0)
if tmpValue > 255:
raise BadExpression("Byte array number %s should less than 0xFF." % Item)
except BadExpression, Value:
raise BadExpression(Value)
except ValueError:
pass
ItemValue, ItemSize = ParseFieldValue(Item)
else:
ItemValue = ParseFieldValue(Item)[0]
if type(ListItem) == type(0) or type(ListItem) == type(0L):
for Index in range(0, Size):
ValueStr += '0x%02X' % (int(ListItem) & 255)
ListItem >>= 8
ValueStr += ', '
PcdValue = '{' + ValueStr[:-2] + '}'
elif type(ListItem) == type(''):
if ListItem.startswith('{') and ListItem.endswith('}'):
PcdValue = ListItem
if type(ItemValue) == type(''):
ItemValue = int(ItemValue, 16) if ItemValue.startswith('0x') else int(ItemValue)
TmpValue = (ItemValue << (Size * 8)) | TmpValue
Size = Size + ItemSize
else:
try:
TmpValue, Size = ParseFieldValue(PcdValue)
except BadExpression, Value:
raise BadExpression("Type: %s, Value: %s, %s" % (self.PcdType, PcdValue, Value))
if type(TmpValue) == type(''):
try:
TmpValue = int(TmpValue)
except:
raise BadExpression(Value)
else:
PcdValue = '0x%0{}X'.format(Size) % (TmpValue)
if TmpValue < 0:
raise BadExpression('Type %s PCD Value is negative' % self.PcdType)
if self.PcdType == 'UINT8' and Size > 1:
raise BadExpression('Type %s PCD Value Size is Larger than 1 byte' % self.PcdType)
if self.PcdType == 'UINT16' and Size > 2:
raise BadExpression('Type %s PCD Value Size is Larger than 2 byte' % self.PcdType)
if self.PcdType == 'UINT32' and Size > 4:
raise BadExpression('Type %s PCD Value Size is Larger than 4 byte' % self.PcdType)
if self.PcdType == 'UINT64' and Size > 8:
raise BadExpression('Type %s PCD Value Size is Larger than 8 byte' % self.PcdType)
else:
try:
TmpValue = long(PcdValue)
TmpList = []
if TmpValue.bit_length() == 0:
PcdValue = '{0x00}'
else:
for I in range((TmpValue.bit_length() + 7) / 8):
TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff))
PcdValue = '{' + ', '.join(TmpList) + '}'
except:
if PcdValue.strip().startswith('{'):
PcdValueList = SplitPcdValueString(PcdValue.strip()[1:-1])
LabelDict = {}
NewPcdValueList = []
ReLabel = re.compile('LABEL\((\w+)\)')
ReOffset = re.compile('OFFSET_OF\((\w+)\)')
for Index, Item in enumerate(ListItem):
LabelOffset = 0
for Index, Item in enumerate(PcdValueList):
# compute byte offset of every LABEL
LabelList = ReLabel.findall(Item)
Item = ReLabel.sub('', Item)
Item = Item.strip()
if LabelList:
for Label in LabelList:
if not IsValidCString(Label):
raise BadExpression('%s is not a valid c variable name' % Label)
if Label not in LabelDict.keys():
LabelDict[Label] = str(LabelOffset)
if Item.startswith('UINT8'):
LabelOffset = LabelOffset + 1
elif Item.startswith('UINT16'):
LabelOffset = LabelOffset + 2
elif Item.startswith('UINT32'):
LabelOffset = LabelOffset + 4
elif Item.startswith('UINT64'):
LabelOffset = LabelOffset + 8
else:
try:
ItemValue, ItemSize = ParseFieldValue(Item)
LabelOffset = LabelOffset + ItemSize
except:
LabelOffset = LabelOffset + 1
for Index, Item in enumerate(PcdValueList):
# for LABEL parse
Item = Item.strip()
try:
LabelList = ReLabel.findall(Item)
for Label in LabelList:
if Label not in LabelDict.keys():
LabelDict[Label] = str(Index)
Item = ReLabel.sub('', Item)
except:
pass
@ -847,32 +946,79 @@ class ValueExpressionEx(ValueExpression):
pass
for Offset in OffsetList:
if Offset in LabelDict.keys():
Re = re.compile('OFFSET_OF\(%s\)'% Offset)
Re = re.compile('OFFSET_OF\(%s\)' % Offset)
Item = Re.sub(LabelDict[Offset], Item)
else:
raise BadExpression('%s not defined before use' % Offset)
if Item.startswith('UINT16'):
ItemSize = 2
elif Item.startswith('UINT32'):
ItemSize = 4
elif Item.startswith('UINT64'):
ItemSize = 8
raise BadExpression('%s not defined' % Offset)
NewPcdValueList.append(Item)
AllPcdValueList = []
for Item in NewPcdValueList:
Size = 0
ValueStr = ''
TokenSpaceGuidName = ''
if Item.startswith('GUID') and Item.endswith(')'):
try:
TokenSpaceGuidName = re.search('GUID\((\w+)\)', Item).group(1)
except:
pass
if TokenSpaceGuidName and TokenSpaceGuidName in self._Symb:
Item = 'GUID(' + self._Symb[TokenSpaceGuidName] + ')'
elif TokenSpaceGuidName:
raise BadExpression('%s not found in DEC file' % TokenSpaceGuidName)
Item, Size = ParseFieldValue(Item)
for Index in range(0, Size):
ValueStr = '0x%02X' % (int(Item) & 255)
Item >>= 8
AllPcdValueList.append(ValueStr)
continue
elif Item.startswith('DEVICE_PATH') and Item.endswith(')'):
Item, Size = ParseFieldValue(Item)
AllPcdValueList.append(Item[1:-1])
continue
else:
ItemSize = 0
TmpValue = ValueExpressionEx(Item, self.PcdType, self._Symb)(True)
Item = '0x%x' % TmpValue if type(TmpValue) != type('') else TmpValue
if ItemSize == 0:
ItemValue, ItemSize = ParseFieldValue(Item)
else:
ItemValue = ParseFieldValue(Item)[0]
for I in range(0, ItemSize):
ValueStr += '0x%02X' % (int(ItemValue) & 255)
ItemValue >>= 8
ValueStr += ', '
Size += ItemSize
ValueType = ""
if Item.startswith('UINT8'):
ItemSize = 1
ValueType = "UINT8"
elif Item.startswith('UINT16'):
ItemSize = 2
ValueType = "UINT16"
elif Item.startswith('UINT32'):
ItemSize = 4
ValueType = "UINT32"
elif Item.startswith('UINT64'):
ItemSize = 8
ValueType = "UINT64"
else:
ItemSize = 0
if ValueType:
TmpValue = ValueExpressionEx(Item, ValueType, self._Symb)(True)
else:
TmpValue = ValueExpressionEx(Item, self.PcdType, self._Symb)(True)
Item = '0x%x' % TmpValue if type(TmpValue) != type('') else TmpValue
if ItemSize == 0:
ItemValue, ItemSize = ParseFieldValue(Item)
if not (Item.startswith('"') or Item.startswith('L') or Item.startswith('{')) and ItemSize > 1:
raise BadExpression("Byte array number %s should less than 0xFF." % Item)
else:
ItemValue = ParseFieldValue(Item)[0]
for I in range(0, ItemSize):
ValueStr = '0x%02X' % (int(ItemValue) & 255)
ItemValue >>= 8
AllPcdValueList.append(ValueStr)
Size += ItemSize
if Size > 0:
PcdValue = '{' + ValueStr[:-2] + '}'
PcdValue = '{' + ','.join(AllPcdValueList) + '}'
else:
raise BadExpression("Type: %s, Value: %s, %s"%(self.PcdType, PcdValue, Value))
if PcdValue == 'True':
PcdValue = '1'
if PcdValue == 'False':
PcdValue = '0'
if RealValue:
return PcdValue

View File

@ -1,7 +1,7 @@
## @file
# Common routines used by all tools
#
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
@ -38,7 +38,7 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
import uuid
from CommonDataClass.Exceptions import BadExpression
import subprocess
## Regular expression used to find out place holders in string template
gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
@ -1441,23 +1441,44 @@ def ParseConsoleLog(Filename):
Opr.close()
Opw.close()
def IsFieldValueAnArray (Value):
Value = Value.strip()
if Value.startswith('GUID') and Value.endswith(')'):
return True
if Value.startswith('L"') and Value.endswith('"') and len(list(Value[2:-1])) > 1:
return True
if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1:
return True
if Value[0] == '{' and Value[-1] == '}':
return True
if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:
return True
if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:
return True
return False
def AnalyzePcdExpression(Setting):
Setting = Setting.strip()
# There might be escaped quote in a string: \", \\\"
Data = Setting.replace('\\\\', '//').replace('\\\"', '\\\'')
# There might be escaped quote in a string: \", \\\" , \', \\\'
Data = Setting
# There might be '|' in string and in ( ... | ... ), replace it with '-'
NewStr = ''
InStr = False
InSingleQuoteStr = False
InDoubleQuoteStr = False
Pair = 0
for ch in Data:
if ch == '"':
InStr = not InStr
elif ch == '(' and not InStr:
for Index, ch in enumerate(Data):
if ch == '"' and not InSingleQuoteStr:
if Data[Index - 1] != '\\':
InDoubleQuoteStr = not InDoubleQuoteStr
elif ch == "'" and not InDoubleQuoteStr:
if Data[Index - 1] != '\\':
InSingleQuoteStr = not InSingleQuoteStr
elif ch == '(' and not (InSingleQuoteStr or InDoubleQuoteStr):
Pair += 1
elif ch == ')' and not InStr:
elif ch == ')' and not (InSingleQuoteStr or InDoubleQuoteStr):
Pair -= 1
if (Pair > 0 or InStr) and ch == TAB_VALUE_SPLIT:
if (Pair > 0 or InSingleQuoteStr or InDoubleQuoteStr) and ch == TAB_VALUE_SPLIT:
NewStr += '-'
else:
NewStr += ch
@ -1474,7 +1495,37 @@ def AnalyzePcdExpression(Setting):
return FieldList
def ParseDevPathValue (Value):
pass
DevPathList = [ "Path","HardwarePath","Pci","PcCard","MemoryMapped","VenHw","Ctrl","BMC","AcpiPath","Acpi","PciRoot",
"PcieRoot","Floppy","Keyboard","Serial","ParallelPort","AcpiEx","AcpiExp","AcpiAdr","Msg","Ata","Scsi",
"Fibre","FibreEx","I1394","USB","I2O","Infiniband","VenMsg","VenPcAnsi","VenVt100","VenVt100Plus",
"VenUtf8","UartFlowCtrl","SAS","SasEx","NVMe","UFS","SD","eMMC","DebugPort","MAC","IPv4","IPv6","Uart",
"UsbClass","UsbAudio","UsbCDCControl","UsbHID","UsbImage","UsbPrinter","UsbMassStorage","UsbHub",
"UsbCDCData","UsbSmartCard","UsbVideo","UsbDiagnostic","UsbWireless","UsbDeviceFirmwareUpdate",
"UsbIrdaBridge","UsbTestAndMeasurement","UsbWwid","Unit","iSCSI","Vlan","Uri","Bluetooth","Wi-Fi",
"MediaPath","HD","CDROM","VenMedia","Media","Fv","FvFile","Offset","RamDisk","VirtualDisk","VirtualCD",
"PersistentVirtualDisk","PersistentVirtualCD","BbsPath","BBS","Sata" ]
if '\\' in Value:
Value.replace('\\', '/').replace(' ', '')
for Item in Value.split('/'):
Key = Item.strip().split('(')[0]
if Key not in DevPathList:
pass
Cmd = 'DevicePath ' + '"' + Value + '"'
try:
p = subprocess.Popen(Cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
out, err = p.communicate()
except Exception, X:
raise BadExpression("DevicePath: %s" % (str(X)) )
finally:
subprocess._cleanup()
p.stdout.close()
p.stderr.close()
if err:
raise BadExpression("DevicePath: %s" % str(err))
Size = len(out.split())
out = ','.join(out.split())
return '{' + out + '}', Size
def ParseFieldValue (Value):
if type(Value) == type(0):
@ -1505,16 +1556,10 @@ def ParseFieldValue (Value):
if Value.startswith('GUID') and Value.endswith(')'):
Value = Value.split('(', 1)[1][:-1].strip()
if Value[0] == '{' and Value[-1] == '}':
Value = Value[1:-1].strip()
Value = Value.split('{', 1)
Value = ['%02x' % int(Item, 16) for Item in (Value[0] + Value[1][:-1]).split(',')]
if len(Value[0]) != 8:
Value[0] = '%08X' % int(Value[0], 16)
if len(Value[1]) != 4:
Value[1] = '%04X' % int(Value[1], 16)
if len(Value[2]) != 4:
Value[2] = '%04X' % int(Value[2], 16)
Value = '-'.join(Value[0:3]) + '-' + ''.join(Value[3:5]) + '-' + ''.join(Value[5:11])
TmpValue = GuidStructureStringToGuidString(Value)
if len(TmpValue) == 0:
raise BadExpression("Invalid GUID value string %s" % Value)
Value = TmpValue
if Value[0] == '"' and Value[-1] == '"':
Value = Value[1:-1]
try:
@ -1525,7 +1570,13 @@ def ParseFieldValue (Value):
return Value, 16
if Value.startswith('L"') and Value.endswith('"'):
# Unicode String
List = list(Value[2:-1])
# translate escape character
Value = Value[1:]
try:
Value = eval(Value)
except:
Value = Value[1:-1]
List = list(Value)
List.reverse()
Value = 0
for Char in List:
@ -1533,7 +1584,12 @@ def ParseFieldValue (Value):
return Value, (len(List) + 1) * 2
if Value.startswith('"') and Value.endswith('"'):
# ASCII String
List = list(Value[1:-1])
# translate escape character
try:
Value = eval(Value)
except:
Value = Value[1:-1]
List = list(Value)
List.reverse()
Value = 0
for Char in List:
@ -1541,7 +1597,15 @@ def ParseFieldValue (Value):
return Value, len(List) + 1
if Value.startswith("L'") and Value.endswith("'"):
# Unicode Character Constant
List = list(Value[2:-1])
# translate escape character
Value = Value[1:]
try:
Value = eval(Value)
except:
Value = Value[1:-1]
List = list(Value)
if len(List) == 0:
raise BadExpression('Length %s is %s' % (Value, len(List)))
List.reverse()
Value = 0
for Char in List:
@ -1549,7 +1613,14 @@ def ParseFieldValue (Value):
return Value, len(List) * 2
if Value.startswith("'") and Value.endswith("'"):
# Character constant
List = list(Value[1:-1])
# translate escape character
try:
Value = eval(Value)
except:
Value = Value[1:-1]
List = list(Value)
if len(List) == 0:
raise BadExpression('Length %s is %s' % (Value, len(List)))
List.reverse()
Value = 0
for Char in List:
@ -1569,7 +1640,8 @@ def ParseFieldValue (Value):
Value = (Value << 8) | ((ItemValue >> 8 * I) & 0xff)
return Value, RetSize
if Value.startswith('DEVICE_PATH(') and Value.endswith(')'):
Value = Value.split('"')[1]
Value = Value.replace("DEVICE_PATH(", '').rstrip(')')
Value = Value.strip().strip('"')
return ParseDevPathValue(Value)
if Value.lower().startswith('0x'):
Value = int(Value, 16)
@ -1648,14 +1720,6 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
Type = DataType
if len(FieldList) > 2:
Size = FieldList[2]
else:
if Type == 'VOID*':
if Value.startswith("L"):
Size = str((len(Value)- 3 + 1) * 2)
elif Value.startswith("{"):
Size = str(len(Value.split(",")))
else:
Size = str(len(Value) -2 + 1 )
if DataType == "":
IsValid = (len(FieldList) <= 1)
else:
@ -1788,10 +1852,10 @@ def CheckPcdDatum(Type, Value):
if Type == "VOID*":
ValueRe = re.compile(r'\s*L?\".*\"\s*$')
if not (((Value.startswith('L"') or Value.startswith('"')) and Value.endswith('"'))
or (Value.startswith('{') and Value.endswith('}'))
or (Value.startswith('{') and Value.endswith('}')) or (Value.startswith("L'") or Value.startswith("'") and Value.endswith("'"))
):
return False, "Invalid value [%s] of type [%s]; must be in the form of {...} for array"\
", or \"...\" for string, or L\"...\" for unicode string" % (Value, Type)
", \"...\" or \'...\' for string, L\"...\" or L\'...\' for unicode string" % (Value, Type)
elif ValueRe.match(Value):
# Check the chars in UnicodeString or CString is printable
if Value.startswith("L"):
@ -2210,6 +2274,10 @@ class SkuClass():
GlobalData.gSkuids = (self.SkuIdSet)
if 'COMMON' in GlobalData.gSkuids:
GlobalData.gSkuids.remove('COMMON')
if self.SkuUsageType == self.SINGLE:
if len(GlobalData.gSkuids) != 1:
if 'DEFAULT' in GlobalData.gSkuids:
GlobalData.gSkuids.remove('DEFAULT')
if GlobalData.gSkuids:
GlobalData.gSkuids.sort()
@ -2221,6 +2289,8 @@ class SkuClass():
return self.__SkuInherit.get(skuname,"DEFAULT")
def GetSkuChain(self,sku):
if sku == "DEFAULT":
return ["DEFAULT"]
skulist = [sku]
nextsku = sku
while 1:
@ -2315,31 +2385,6 @@ def PackRegistryFormatGuid(Guid):
int(Guid[4][-2:], 16)
)
def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Value):
if PcdDatumType == 'VOID*':
if Value.startswith('L'):
if not Value[1]:
EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')
Value = Value[0] + '"' + Value[1:] + '"'
elif Value.startswith('H'):
if not Value[1]:
EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')
Value = Value[1:]
else:
if not Value[0]:
EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')
Value = '"' + Value + '"'
IsValid, Cause = CheckPcdDatum(PcdDatumType, Value)
if not IsValid:
EdkLogger.error("build", FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName))
if PcdDatumType == 'BOOLEAN':
Value = Value.upper()
if Value == 'TRUE' or Value == '1':
Value = '1'
elif Value == 'FALSE' or Value == '0':
Value = '0'
return Value
## Get the integer value from string like "14U" or integer like 2
#
# @param Input The object that may be either a integer value or a string

View File

@ -45,26 +45,32 @@ def GetSplitValueList(String, SplitTag=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
ValueList = []
Last = 0
Escaped = False
InString = False
InSingleQuoteString = False
InDoubleQuoteString = False
InParenthesis = 0
for Index in range(0, len(String)):
Char = String[Index]
if not Escaped:
# Found a splitter not in a string, split it
if not InString and InParenthesis == 0 and Char == SplitTag:
if (not InSingleQuoteString or not InDoubleQuoteString) and InParenthesis == 0 and Char == SplitTag:
ValueList.append(String[Last:Index].strip())
Last = Index + 1
if MaxSplit > 0 and len(ValueList) >= MaxSplit:
break
if Char == '\\' and InString:
if Char == '\\' and (InSingleQuoteString or InDoubleQuoteString):
Escaped = True
elif Char == '"':
if not InString:
InString = True
elif Char == '"' and not InSingleQuoteString:
if not InDoubleQuoteString:
InDoubleQuoteString = True
else:
InString = False
InDoubleQuoteString = False
elif Char == "'" and not InDoubleQuoteString:
if not InSingleQuoteString:
InSingleQuoteString = True
else:
InSingleQuoteString = False
elif Char == '(':
InParenthesis = InParenthesis + 1
elif Char == ')':
@ -345,14 +351,17 @@ def CleanString(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyle
#
# remove comments, but we should escape comment character in string
#
InString = False
InDoubleQuoteString = False
InSingleQuoteString = False
CommentInString = False
for Index in range(0, len(Line)):
if Line[Index] == '"':
InString = not InString
elif Line[Index] == CommentCharacter and InString :
if Line[Index] == '"' and not InSingleQuoteString:
InDoubleQuoteString = not InDoubleQuoteString
elif Line[Index] == "'" and not InDoubleQuoteString:
InSingleQuoteString = not InSingleQuoteString
elif Line[Index] == CommentCharacter and (InSingleQuoteString or InDoubleQuoteString):
CommentInString = True
elif Line[Index] == CommentCharacter and not InString :
elif Line[Index] == CommentCharacter and not (InSingleQuoteString or InDoubleQuoteString):
Line = Line[0: Index]
break
@ -402,15 +411,18 @@ def CleanString2(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyl
#
# separate comments and statements, but we should escape comment character in string
#
InString = False
InDoubleQuoteString = False
InSingleQuoteString = False
CommentInString = False
Comment = ''
for Index in range(0, len(Line)):
if Line[Index] == '"':
InString = not InString
elif Line[Index] == CommentCharacter and InString:
if Line[Index] == '"' and not InSingleQuoteString:
InDoubleQuoteString = not InDoubleQuoteString
elif Line[Index] == "'" and not InDoubleQuoteString:
InSingleQuoteString = not InSingleQuoteString
elif Line[Index] == CommentCharacter and (InDoubleQuoteString or InSingleQuoteString):
CommentInString = True
elif Line[Index] == CommentCharacter and not InString:
elif Line[Index] == CommentCharacter and not (InDoubleQuoteString or InSingleQuoteString):
Comment = Line[Index:].strip()
Line = Line[0:Index].strip()
break
@ -805,34 +817,34 @@ def GetHelpTextList(HelpTextClassList):
def StringToArray(String):
if isinstance(String, unicode):
if len(unicode) == 0:
return "{0x00, 0x00}"
return "{%s, 0x00, 0x00}" % ", ".join(["0x%02x, 0x00" % ord(C) for C in String])
return "{0x00,0x00}"
return "{%s,0x00,0x00}" % ",".join(["0x%02x,0x00" % ord(C) for C in String])
elif String.startswith('L"'):
if String == "L\"\"":
return "{0x00, 0x00}"
return "{0x00,0x00}"
else:
return "{%s, 0x00, 0x00}" % ", ".join(["0x%02x, 0x00" % ord(C) for C in String[2:-1]])
return "{%s,0x00,0x00}" % ",".join(["0x%02x,0x00" % ord(C) for C in String[2:-1]])
elif String.startswith('"'):
if String == "\"\"":
return "{0x00,0x00}"
else:
StringLen = len(String[1:-1])
if StringLen % 2:
return "{%s, 0x00}" % ", ".join(["0x%02x" % ord(C) for C in String[1:-1]])
return "{%s,0x00}" % ",".join(["0x%02x" % ord(C) for C in String[1:-1]])
else:
return "{%s, 0x00,0x00}" % ", ".join(["0x%02x" % ord(C) for C in String[1:-1]])
return "{%s,0x00,0x00}" % ",".join(["0x%02x" % ord(C) for C in String[1:-1]])
elif String.startswith('{'):
StringLen = len(String.split(","))
if StringLen % 2:
return "{%s, 0x00}" % ", ".join([ C for C in String[1:-1].split(',')])
return "{%s,0x00}" % ",".join([ C.strip() for C in String[1:-1].split(',')])
else:
return "{%s}" % ", ".join([ C for C in String[1:-1].split(',')])
return "{%s}" % ",".join([ C.strip() for C in String[1:-1].split(',')])
else:
if len(String.split()) % 2:
return '{%s, 0}' % ', '.join(String.split())
return '{%s,0}' % ','.join(String.split())
else:
return '{%s, 0,0}' % ', '.join(String.split())
return '{%s,0,0}' % ','.join(String.split())
def StringArrayLength(String):
if isinstance(String, unicode):

View File

@ -98,15 +98,8 @@ class CParser(Parser):
Parser.__init__(self, input)
self.ruleMemo = {}
self.function_definition_stack = []
self.postfix_expression_stack = []
self.function_definition_stack = []
self.postfix_expression_stack = []
def printTokenInfo(self, line, offset, tokenText):
print str(line)+ ',' + str(offset) + ':' + str(tokenText)

View File

@ -98,15 +98,8 @@ class CParser(Parser):
Parser.__init__(self, input)
self.ruleMemo = {}
self.function_definition_stack = []
self.postfix_expression_stack = []
self.function_definition_stack = []
self.postfix_expression_stack = []
def printTokenInfo(self, line, offset, tokenText):
print str(line)+ ',' + str(offset) + ':' + str(tokenText)

View File

@ -60,15 +60,24 @@ class CompressSection (CompressSectionClassObject) :
self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
SectFiles = tuple()
SectAlign = []
Index = 0
MaxAlign = None
for Sect in self.SectionList:
Index = Index + 1
SecIndex = '%s.%d' %(SecNum, Index)
ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile)
if AlignValue != None:
if MaxAlign == None:
MaxAlign = AlignValue
if GenFdsGlobalVariable.GetAlignment (AlignValue) > GenFdsGlobalVariable.GetAlignment (MaxAlign):
MaxAlign = AlignValue
if ReturnSectList != []:
if AlignValue == None:
AlignValue = "1"
for FileData in ReturnSectList:
SectFiles += (FileData,)
SectAlign.append(AlignValue)
OutputFile = OutputPath + \
os.sep + \
@ -77,8 +86,10 @@ class CompressSection (CompressSectionClassObject) :
SecNum + \
Ffs.SectionSuffix['COMPRESS']
OutputFile = os.path.normpath(OutputFile)
DummyFile = OutputFile + '.dummy'
GenFdsGlobalVariable.GenerateSection(DummyFile, SectFiles, InputAlign=SectAlign, IsMakefile=IsMakefile)
GenFdsGlobalVariable.GenerateSection(OutputFile, SectFiles, Section.Section.SectionType['COMPRESS'],
GenFdsGlobalVariable.GenerateSection(OutputFile, [DummyFile], Section.Section.SectionType['COMPRESS'],
CompressionType=self.CompTypeDict[self.CompType], IsMakefile=IsMakefile)
OutputFileList = []
OutputFileList.append(OutputFile)

View File

@ -1,7 +1,7 @@
## @file
# parse FDF file
#
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.<BR>
#
# This program and the accompanying materials
@ -925,6 +925,13 @@ class FdfParser:
MacroDict.update(GlobalData.gGlobalDefines)
MacroDict.update(GlobalData.gCommandLineDefines)
if GlobalData.BuildOptionPcd:
for Item in GlobalData.BuildOptionPcd:
if type(Item) is tuple:
continue
PcdName, TmpValue = Item.split("=")
TmpValue = BuildOptionValue(TmpValue, {})
MacroDict[PcdName.strip()] = TmpValue
# Highest priority
return MacroDict
@ -2486,6 +2493,8 @@ class FdfParser:
if not self.__GetNextToken():
raise Warning("expected INF file path", self.FileName, self.CurrentLineNumber)
ffsInf.InfFileName = self.__Token
if not ffsInf.InfFileName.endswith('.inf'):
raise Warning("expected .inf file path", self.FileName, self.CurrentLineNumber)
ffsInf.CurrentLineNum = self.CurrentLineNumber
ffsInf.CurrentLineContent = self.__CurrentLine()

View File

@ -1,7 +1,7 @@
## @file
# process FFS generation from INF statement
#
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2014-2016 Hewlett-Packard Development Company, L.P.<BR>
#
# This program and the accompanying materials
@ -46,6 +46,7 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
import Common.GlobalData as GlobalData
from DepexSection import DepexSection
from Common.Misc import SaveFileOnChange
from Common.Expression import *
## generate FFS from INF
#
@ -237,6 +238,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
InfPcds = Inf.Pcds
Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
FdfPcdDict = GenFdsGlobalVariable.FdfParser.Profile.PcdDict
PlatformPcds = Platform.Pcds
# Workaround here: both build and GenFds tool convert the workspace path to lower case
# But INF file path in FDF and DSC file may have real case characters.
@ -272,15 +274,31 @@ class FfsInfStatement(FfsInfStatementClassObject):
if GlobalData.BuildOptionPcd:
for pcd in GlobalData.BuildOptionPcd:
if PcdKey == (pcd[1], pcd[0]):
DefaultValue = pcd[2]
if pcd[2]:
continue
DefaultValue = pcd[3]
BuildOptionOverride = True
break
if not DscOverride and not FdfOverride and not BuildOptionOverride:
continue
# Support Flexible PCD format
if DefaultValue:
try:
DefaultValue = ValueExpressionEx(DefaultValue, Pcd.DatumType, Platform._GuidDict)(True)
except BadExpression:
EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] Value "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValue), File=self.InfFileName)
if Pcd.InfDefaultValue:
try:
Pcd.InfDefaultValue = ValueExpressionEx(Pcd.InfDefaultValue, Pcd.DatumType, Platform._GuidDict)(True)
except BadExpression:
EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] Value "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DefaultValue),File=self.InfFileName)
# Check value, if value are equal, no need to patch
if Pcd.DatumType == "VOID*":
if Pcd.DefaultValue == DefaultValue or DefaultValue in [None, '']:
if Pcd.InfDefaultValue == DefaultValue or DefaultValue in [None, '']:
continue
# Get the string size from FDF or DSC
if DefaultValue[0] == 'L':
@ -294,15 +312,15 @@ class FfsInfStatement(FfsInfStatementClassObject):
Pcd.MaxDatumSize = PatchPcd.MaxDatumSize
# If no defined the maximum size in DSC, try to get current size from INF
if Pcd.MaxDatumSize in ['', None]:
Pcd.MaxDatumSize = str(len(Pcd.DefaultValue.split(',')))
Pcd.MaxDatumSize = str(len(Pcd.InfDefaultValue.split(',')))
else:
Base1 = Base2 = 10
if Pcd.DefaultValue.upper().startswith('0X'):
if Pcd.InfDefaultValue.upper().startswith('0X'):
Base1 = 16
if DefaultValue.upper().startswith('0X'):
Base2 = 16
try:
PcdValueInImg = int(Pcd.DefaultValue, Base1)
PcdValueInImg = int(Pcd.InfDefaultValue, Base1)
PcdValueInDscOrFdf = int(DefaultValue, Base2)
if PcdValueInImg == PcdValueInDscOrFdf:
continue

View File

@ -1,7 +1,7 @@
## @file
# process FV generation
#
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -179,7 +179,7 @@ class FV (FvClassObject):
if FvChildAddr != []:
# Update Ffs again
for FfsFile in self.FfsList :
FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress, IsMakefile=Flag)
FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress, IsMakefile=Flag, FvName=self.UiFvName)
if GenFdsGlobalVariable.LargeFileInFvFlags[-1]:
FFSGuid = GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID;

View File

@ -1,7 +1,7 @@
## @file
# generate flash image
#
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -38,8 +38,6 @@ from Common.Misc import DirCache, PathClass
from Common.Misc import SaveFileOnChange
from Common.Misc import ClearDuplicatedInf
from Common.Misc import GuidStructureStringToGuidString
from Common.Misc import CheckPcdDatum
from Common.Misc import BuildOptionPcdValueFormat
from Common.BuildVersion import gBUILD_VERSION
from Common.MultipleWorkspace import MultipleWorkspace as mws
import FfsFileStatement
@ -144,6 +142,7 @@ def main():
else:
EdkLogger.error("GenFds", OPTION_MISSING, "Missing active platform")
GlobalData.BuildOptionPcd = Options.OptionPcd if Options.OptionPcd else {}
GenFdsGlobalVariable.ActivePlatform = PathClass(NormPath(ActivePlatform))
if (Options.ConfDirectory):
@ -164,6 +163,8 @@ def main():
# Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf
ConfDirectoryPath = mws.join(GenFdsGlobalVariable.WorkSpaceDir, 'Conf')
GenFdsGlobalVariable.ConfDir = ConfDirectoryPath
if not GlobalData.gConfDirectory:
GlobalData.gConfDirectory = GenFdsGlobalVariable.ConfDir
BuildConfigurationFile = os.path.normpath(os.path.join(ConfDirectoryPath, "target.txt"))
if os.path.isfile(BuildConfigurationFile) == True:
TargetTxt = TargetTxtClassObject.TargetTxtClassObject()
@ -302,9 +303,7 @@ def main():
if ArchList != None:
GenFdsGlobalVariable.ArchList = ArchList
if Options.OptionPcd:
GlobalData.BuildOptionPcd = Options.OptionPcd
CheckBuildOptionPcd()
# Dsc Build Data will handle Pcd Settings from CommandLine.
"""Modify images from build output if the feature of loading driver at fixed address is on."""
if GenFdsGlobalVariable.FixedLoadAddress:
@ -368,53 +367,6 @@ def SingleCheckCallback(option, opt_str, value, parser):
else:
parser.error("Option %s only allows one instance in command line!" % option)
def CheckBuildOptionPcd():
for Arch in GenFdsGlobalVariable.ArchList:
PkgList = GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag)
for i, pcd in enumerate(GlobalData.BuildOptionPcd):
if type(pcd) is tuple:
continue
(pcdname, pcdvalue) = pcd.split('=')
if not pcdvalue:
EdkLogger.error('GenFds', OPTION_MISSING, "No Value specified for the PCD %s." % (pcdname))
if '.' in pcdname:
(TokenSpaceGuidCName, TokenCName) = pcdname.split('.')
HasTokenSpace = True
else:
TokenCName = pcdname
TokenSpaceGuidCName = ''
HasTokenSpace = False
TokenSpaceGuidCNameList = []
FoundFlag = False
PcdDatumType = ''
NewValue = ''
for package in PkgList:
for key in package.Pcds:
PcdItem = package.Pcds[key]
if HasTokenSpace:
if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName):
PcdDatumType = PcdItem.DatumType
NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)
FoundFlag = True
else:
if PcdItem.TokenCName == TokenCName:
if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList:
if len (TokenSpaceGuidCNameList) < 1:
TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName)
PcdDatumType = PcdItem.DatumType
TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName
NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)
FoundFlag = True
else:
EdkLogger.error(
'GenFds',
PCD_VALIDATION_INFO_ERROR,
"The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0])
)
GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, NewValue)
## FindExtendTool()
#
# Find location of tools to process data

View File

@ -1,7 +1,7 @@
## @file
# Global variables for GenFds
#
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -500,7 +500,7 @@ class GenFdsGlobalVariable:
if IsMakefile:
if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:
GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())
elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)):
elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")
if (os.path.getsize(Output) >= GenFdsGlobalVariable.LARGE_FILE_SIZE and
@ -552,7 +552,7 @@ class GenFdsGlobalVariable:
GenFdsGlobalVariable.SecCmdList = []
GenFdsGlobalVariable.CopyList = []
else:
if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)):
if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
return
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FFS")

View File

@ -161,10 +161,11 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
#
# Patch {0x1, 0x2, ...} byte by byte
#
ValueList = ValueString[1 : len(ValueString) - 1].split(', ')
ValueList = ValueString[1 : len(ValueString) - 1].split(',')
Index = 0
try:
for ByteString in ValueList:
ByteString = ByteString.strip()
if ByteString.upper().startswith('0X'):
ByteValue = int(ByteString, 16)
else:

View File

@ -4,7 +4,7 @@
# {0xa7717414, 0xc616, 0x4977, {0x94, 0x20, 0x84, 0x47, 0x12, 0xa7, 0x35, 0xbf}}
# This tool has been tested with OpenSSL 1.0.1e 11 Feb 2013
#
# Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -176,7 +176,7 @@ if __name__ == '__main__':
#
# Sign the input file using the specified private key and capture signature from STDOUT
#
Process = subprocess.Popen('%s sha256 -sign "%s"' % (OpenSslCommand, args.PrivateKeyFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Process = subprocess.Popen('%s dgst -sha256 -sign "%s"' % (OpenSslCommand, args.PrivateKeyFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Signature = Process.communicate(input=FullInputFileBuffer)[0]
if Process.returncode <> 0:
sys.exit(Process.returncode)
@ -225,7 +225,7 @@ if __name__ == '__main__':
#
# Verify signature
#
Process = subprocess.Popen('%s sha256 -prverify "%s" -signature %s' % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Process = subprocess.Popen('%s dgst -sha256 -prverify "%s" -signature %s' % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Process.communicate(input=FullInputFileBuffer)
if Process.returncode <> 0:
print 'ERROR: Verification failed'

View File

@ -65,8 +65,10 @@ class PcdClassObject(object):
self.validlists = validlists
self.expressions = expressions
self.DscDefaultValue = None
self.DscRawValue = None
if IsDsc:
self.DscDefaultValue = Value
self.PcdValueFromComm = ""
## Convert the class to a string
#
@ -109,9 +111,14 @@ class PcdClassObject(object):
return hash((self.TokenCName, self.TokenSpaceGuidCName))
class StructurePcd(PcdClassObject):
def __init__(self, StructuredPcdIncludeFile="", Packages=None, Name=None, Guid=None, Type=None, DatumType=None, Value=None, Token=None, MaxDatumSize=None, SkuInfoList={}, IsOverrided=False, GuidValue=None, validateranges=[], validlists=[], expressions=[],default_store = TAB_DEFAULT_STORES_DEFAULT):
def __init__(self, StructuredPcdIncludeFile=None, Packages=None, Name=None, Guid=None, Type=None, DatumType=None, Value=None, Token=None, MaxDatumSize=None, SkuInfoList=None, IsOverrided=False, GuidValue=None, validateranges=None, validlists=None, expressions=None,default_store = TAB_DEFAULT_STORES_DEFAULT):
if SkuInfoList is None: SkuInfoList={}
if validateranges is None: validateranges=[]
if validlists is None: validlists=[]
if expressions is None : expressions=[]
if Packages is None : Packages = []
super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validateranges, validlists, expressions)
self.StructuredPcdIncludeFile = StructuredPcdIncludeFile
self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is None else StructuredPcdIncludeFile
self.PackageDecs = Packages
self.DefaultStoreName = [default_store]
self.DefaultValues = collections.OrderedDict({})
@ -119,6 +126,11 @@ class StructurePcd(PcdClassObject):
self.SkuOverrideValues = collections.OrderedDict({})
self.FlexibleFieldName = None
self.StructName = None
self.PcdDefineLineNo = 0
self.PkgPath = ""
self.DefaultValueFromDec = ""
self.ValueChain = dict()
self.PcdFieldValueFromComm = collections.OrderedDict({})
def __repr__(self):
return self.TypeName
@ -128,6 +140,8 @@ class StructurePcd(PcdClassObject):
self.DefaultValues[FieldName] = [Value.strip(), FileName, LineNo]
return self.DefaultValues[FieldName]
def SetDecDefaultValue(self,DefaultValue):
self.DefaultValueFromDec = DefaultValue
def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreName, FileName="", LineNo=0):
if SkuName not in self.SkuOverrideValues:
self.SkuOverrideValues[SkuName] = collections.OrderedDict({})
@ -162,15 +176,22 @@ class StructurePcd(PcdClassObject):
self.validateranges = PcdObject.validateranges if PcdObject.validateranges else self.validateranges
self.validlists = PcdObject.validlists if PcdObject.validlists else self.validlists
self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions
self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue
self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm
if type(PcdObject) is StructurePcd:
self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile
self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs
self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues
self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode
self.DefaultFromDSC=None
self.DefaultValueFromDec = PcdObject.DefaultValueFromDec if PcdObject.DefaultValueFromDec else self.DefaultValueFromDec
self.SkuOverrideValues = PcdObject.SkuOverrideValues if PcdObject.SkuOverrideValues else self.SkuOverrideValues
self.FlexibleFieldName = PcdObject.FlexibleFieldName if PcdObject.FlexibleFieldName else self.FlexibleFieldName
self.StructName = PcdObject.DatumType if PcdObject.DatumType else self.StructName
self.PcdDefineLineNo = PcdObject.PcdDefineLineNo if PcdObject.PcdDefineLineNo else self.PcdDefineLineNo
self.PkgPath = PcdObject.PkgPath if PcdObject.PkgPath else self.PkgPath
self.ValueChain = PcdObject.ValueChain if PcdObject.ValueChain else self.ValueChain
self.PcdFieldValueFromComm = PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm
## LibraryClassObject
#
@ -437,4 +458,3 @@ class PlatformBuildClassObject(object):
#
def __hash__(self):
return hash(self.MetaFile)

View File

@ -1,7 +1,7 @@
## @file
# This file is used to create a database used by build tool
#
# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -15,6 +15,7 @@ from Common.String import *
from Common.DataType import *
from Common.Misc import *
from types import *
from collections import OrderedDict
from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject
@ -95,6 +96,7 @@ class DecBuildData(PackageBuildClassObject):
self._Ppis = None
self._Guids = None
self._Includes = None
self._CommonIncludes = None
self._LibraryClasses = None
self._Pcds = None
self.__Macros = None
@ -296,7 +298,8 @@ class DecBuildData(PackageBuildClassObject):
## Retrieve public include paths declared in this package
def _GetInclude(self):
if self._Includes == None:
if self._Includes == None or self._CommonIncludes is None:
self._CommonIncludes = []
self._Includes = []
self._PrivateIncludes = []
PublicInclues = []
@ -324,7 +327,8 @@ class DecBuildData(PackageBuildClassObject):
PublicInclues.append(File)
if File in self._PrivateIncludes:
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo)
if Record[3] == "COMMON":
self._CommonIncludes.append(File)
return self._Includes
## Retrieve library class declarations (not used in build at present)
@ -364,7 +368,7 @@ class DecBuildData(PackageBuildClassObject):
def ProcessStructurePcd(self, StructurePcdRawDataSet):
s_pcd_set = dict()
s_pcd_set = OrderedDict()
for s_pcd,LineNo in StructurePcdRawDataSet:
if s_pcd.TokenSpaceGuidCName not in s_pcd_set:
s_pcd_set[s_pcd.TokenSpaceGuidCName] = []
@ -376,17 +380,22 @@ class DecBuildData(PackageBuildClassObject):
struct_pcd = StructurePcd()
for item,LineNo in s_pcd_set[pcdname]:
if "<HeaderFiles>" in item.TokenCName:
struct_pcd.StructuredPcdIncludeFile = item.DefaultValue
struct_pcd.StructuredPcdIncludeFile.append(item.DefaultValue)
elif "<Packages>" in item.TokenCName:
dep_pkgs.append(item.DefaultValue)
elif item.DatumType == item.TokenCName:
struct_pcd.copy(item)
struct_pcd.TokenValue = struct_pcd.TokenValue.strip("{").strip()
struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName = pcdname.split(".")
struct_pcd.PcdDefineLineNo = LineNo
struct_pcd.PkgPath = self.MetaFile.File
struct_pcd.SetDecDefaultValue(item.DefaultValue)
else:
struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo)
struct_pcd.PackageDecs = dep_pkgs
if not struct_pcd.StructuredPcdIncludeFile:
EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName,self.MetaFile.File,LineNo ))
str_pcd_set.append(struct_pcd)
@ -447,6 +456,11 @@ class DecBuildData(PackageBuildClassObject):
Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd
return Pcds
@property
def CommonIncludes(self):
if self._CommonIncludes is None:
self.Includes
return self._CommonIncludes
_Macros = property(_GetMacros)

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More