Date   

Re: [Patch V3] UefiCpuPkg/CpuExceptionHandlerLib: Fix split lock

Laszlo Ersek
 

On 09/18/19 00:49, John E Lofgren wrote:
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2150
V3 changes:
change to mov instruction (non locking instuction) instead
of xchg to simplify design.
I think something's wrong -- the v3 update described above isn't
actually implemented in the patch (it continues using XCHG, rather than
MOV).

Thanks
Laszlo


V2 changes:
Add xchg 16 bit instructions to handle sgdt and sidt base
63:48 bits and 47:32 bits.
Add comment to explain why xchg 64bit isnt being used

Split lock happens when a locking instruction is used on mis-aligned data
that crosses two cachelines. If close source platform enables Alignment Check
Exception(#AC), They can hit a double fault due to split lock being in
CpuExceptionHandlerLib.

sigt and sgdt saves 10 bytes to memory, 8 bytes is base and 2 bytes is limit.
The data is mis-aligned, can cross two cacheline, and a xchg
instruction(locking instuction) is being utilize.

Signed-off-by: John E Lofgren <john.e.lofgren@intel.com>
---
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
index 4db1a09f28..7b7642b290 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -180,21 +180,29 @@ HasErrorCode:
push qword [rbp + 24]

;; UINT64 Gdtr[2], Idtr[2];
+ ; sidt and sgdt saves 10 bytes to memory, 8 bytes = base and 2 bytes = limit.
+ ; To avoid #AC split lock when separating base and limit into their
+ ; own separate 64 bit memory, we can’t use 64 bit xchg since base [63:48] bits
+ ; may cross the cache line.
xor rax, rax
push rax
push rax
sidt [rsp]
- xchg rax, [rsp + 2]
- xchg rax, [rsp]
- xchg rax, [rsp + 8]
+ xchg eax, [rsp + 2]
+ xchg eax, [rsp]
+ xchg eax, [rsp + 8]
+ xchg ax, [rsp + 6]
+ xchg ax, [rsp + 4]

xor rax, rax
push rax
push rax
sgdt [rsp]
- xchg rax, [rsp + 2]
- xchg rax, [rsp]
- xchg rax, [rsp + 8]
+ xchg eax, [rsp + 2]
+ xchg eax, [rsp]
+ xchg eax, [rsp + 8]
+ xchg ax, [rsp + 6]
+ xchg ax, [rsp + 4]

;; UINT64 Ldtr, Tr;
xor rax, rax


[PATCH v2 1/1] uefi-sct/SctPkg AdapterInfo SetInformation may return unsupported

Tom Zhao
 

If AdapterInfo.SetInformation() is unsupported, it will return
EFI_UNSUPPORTED. Do not fail the test in this case.

Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Eric Jin <eric.jin@intel.com>
Signed-off-by: Tom Zhao <tzhao@solarflare.com>
---

Notes:
v2:
- Change commit message to be closer to similar issues.

uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestConformance.c | 4 ++--
uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestFunction.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git
a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestConformance.c
b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestConformance.c
index fb42398e4a97..3dc048db5333 100644
---
a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestConformance.c
+++
b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestConformance.c
@@ -556,8 +556,8 @@ BBTestSetInformationConformanceTestCheckpoint2 (
NULL,
InformationBlockSize
);
- - if ( Status != EFI_INVALID_PARAMETER && Status !=
EFI_WRITE_PROTECTED) {
+
+ if ( Status != EFI_INVALID_PARAMETER && Status !=
EFI_WRITE_PROTECTED && Status != EFI_UNSUPPORTED) {
AssertionType = EFI_TEST_ASSERTION_FAILED;
} else {
AssertionType = EFI_TEST_ASSERTION_PASSED;
diff --git
a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestFunction.c
b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestFunction.c
index 334bb9edc493..4b054b0ef7d8 100644
---
a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestFunction.c
+++
b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestFunction.c
@@ -372,11 +372,11 @@ BBTestSetInformationFunctionTestCheckpoint1 (
InformationBlockSize1
);
- if (Status == EFI_SUCCESS || Status == EFI_WRITE_PROTECTED)
- AssertionType = EFI_TEST_ASSERTION_PASSED; + if (Status ==
EFI_SUCCESS || Status == EFI_WRITE_PROTECTED || Status == EFI_UNSUPPORTED)
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
else
- AssertionType = EFI_TEST_ASSERTION_FAILED; - +
AssertionType = EFI_TEST_ASSERTION_FAILED;
+
StandardLib->RecordAssertion (
StandardLib,
AssertionType,
--
2.21.0


Re: [PATCH V3 1/3] MdeModulePkg: Extend the support keyboard type of Terminal console

Laszlo Ersek
 

On 09/18/19 07:33, Zhichao Gao wrote:
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2186

A common terminal console software Putty support various types of
keyboard type, such as normal mode, Linux mode, Xterm R6, Vt400,
VT100+ and SCO. Refer to the link:
https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter4.html#config-funkeys

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
---
MdeModulePkg/Include/Guid/TtyTerm.h | 13 +++++++++++++
MdeModulePkg/MdeModulePkg.dec | 4 ++++
2 files changed, 17 insertions(+)

diff --git a/MdeModulePkg/Include/Guid/TtyTerm.h b/MdeModulePkg/Include/Guid/TtyTerm.h
index 8333344b9d..471a651d4d 100644
--- a/MdeModulePkg/Include/Guid/TtyTerm.h
+++ b/MdeModulePkg/Include/Guid/TtyTerm.h
@@ -4,6 +4,7 @@ provide support for modern *nix terminals.


Copyright (c) 2015 Linaro Ltd.
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -14,6 +15,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_TTY_TERM_GUID \
{0x7d916d80, 0x5bb1, 0x458c, {0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94 } }

+#define EDKII_LINUX_TERM_GUID \
+ {0xe4364a7f, 0xf825, 0x430e, {0x9d, 0x3a, 0x9c, 0x9b, 0xe6, 0x81, 0x7c, 0xa5 } }
+
+#define EDKII_XTERM_R6_GUID \
+ {0xfbfca56b, 0xbb36, 0x4b78, {0xaa, 0xab, 0xbe, 0x1b, 0x97, 0xec, 0x7c, 0xcb } }
+
+#define EDKII_VT400_GUID \
+ {0x8e46dddd, 0x3d49, 0x4a9d, {0xb8, 0x75, 0x3c, 0x08, 0x6f, 0x6a, 0xa2, 0xbd } }
+
+#define EDKII_SCO_TERM_GUID \
+ {0xfc7dd6e0, 0x813c, 0x434d, {0xb4, 0xda, 0x3b, 0xd6, 0x49, 0xe9, 0xe1, 0x5a } }
+
extern EFI_GUID gEfiTtyTermGuid;

#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 17beb45235..7f72c122fc 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -342,6 +342,10 @@

## Include/Guid/TtyTerm.h
gEfiTtyTermGuid = { 0x7d916d80, 0x5bb1, 0x458c, {0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94 }}
+ gEdkiiLinuxTermGuid = { 0xe4364a7f, 0xf825, 0x430e, {0x9d, 0x3a, 0x9c, 0x9b, 0xe6, 0x81, 0x7c, 0xa5 }}
+ gEdkiiXtermR6Guid = { 0xfbfca56b, 0xbb36, 0x4b78, {0xaa, 0xab, 0xbe, 0x1b, 0x97, 0xec, 0x7c, 0xcb }}
+ gEdkiiVT400Guid = { 0x8e46dddd, 0x3d49, 0x4a9d, {0xb8, 0x75, 0x3c, 0x08, 0x6f, 0x6a, 0xa2, 0xbd }}
+ gEdkiiSCOTermGuid = { 0xfc7dd6e0, 0x813c, 0x434d, {0xb4, 0xda, 0x3b, 0xd6, 0x49, 0xe9, 0xe1, 0x5a }}

## Include/Guid/HiiBootMaintenanceFormset.h
gEfiIfrBootMaintenanceGuid = { 0xb2dedc91, 0xd59f, 0x48d2, { 0x89, 0x8a, 0x12, 0x49, 0xc, 0x74, 0xa4, 0xe0 }}
thank you, the new names look helpful.

Acked-by: Laszlo Ersek <lersek@redhat.com>

Thanks
Laszlo


Re: [PATCH 01/35] DO NOT APPLY: edk2: turn standard handle types into pointers to non-VOID

Laszlo Ersek
 

On 09/17/19 22:22, Andrew Fish wrote:


On Sep 17, 2019, at 1:06 PM, Ni, Ray <ray.ni@intel.com> wrote:

Laszlo,
Thank you very much for this work.
They are quite helpful to detect potential issues.

But without this specific patch being checked in, future break will still happen.
I don't want it to be checked in ASAP because I know that there are quite a lot of close source code that may get build break due to this change.
Besides that, what prevent you make the decision to check in the changes?
Ray,

I was thinking the same thing. Could we make this an optional feature via a #define? We could always default to the Spec Behavior, and new projects could opt into the stricter version.

#ifndef STRICTER_UEFI_TYPES
typedef VOID *EFI_PEI_FV_HANDLE;
#else
struct EFI_PEI_FV_OBJECT;
typedef struct EFI_PEI_FV_OBJECT *EFI_PEI_FV_HANDLE;
#endif
Technically, this would work well.

However, if we wanted to allow new projects to #define
STRICTER_UEFI_TYPES as their normal mode of operation (and not just for
a sanity check in CI), then we'd have to update the UEFI spec too.

Otherwise, code that is technically spec-conformant (albeit semantically
nonsensical), like I mentioned up-thread, would no longer compile:

EFI_HANDLE Foobar;
UINT64 Val;

Foobar = &Val;

Thanks
Laszlo


Re: [PATCH 01/35] DO NOT APPLY: edk2: turn standard handle types into pointers to non-VOID

Laszlo Ersek
 

On 09/17/19 22:06, Ni, Ray wrote:
Laszlo,
Thank you very much for this work.
They are quite helpful to detect potential issues.

But without this specific patch being checked in, future break will still happen.
Yes, I agree; that's quite likely.

I don't want it to be checked in ASAP because I know that there are quite a lot of close source code that may get build break due to this change.
Besides that, what prevent you make the decision to check in the changes?
There are two concerns:


(1) Applying this patch would cause edk2 to diverge from the UEFI / PI /
Shell specifications.

For example, consider the following 3rd party code:

EFI_HANDLE Foobar;
UINT64 Val;

Foobar = &Val;

*Semantically*, this code is wrong. However, given the publicly
specified EFI_HANDLE typedef in the UEFI spec, the code is *technically*
correct.

If we changed the EFI_HANDLE typedef in edk2, as follows:

struct EFI_OBJECT;
typedef struct EFI_OBJECT *EFI_HANDLE;

Then the assignment to Foobar above, in the 3rd party code, would become
a C language constraint violation -- and for constraint violations, C
compilers are required to emit diagnostics.

In brief, it would build-break 3rd party code that currently conforms to
the UEFI spec.


(2) Some of the changes in the patch are not optimal with regard to
"data hiding".

An example for good data hiding is the example above: "struct
EFI_OBJECT" being an incomplete type, without any details shared in the
public header.

However, in the patch we have bad data hiding too:

- typedef LIST_ENTRY *EFI_FONT_HANDLE
- typedef UINT8 *EFI_S3_BOOT_SCRIPT_POSITION
- typedef EFI_FILE_PROTOCOL *SHELL_FILE_HANDLE;

These typedefs, while they serve the purposes of the present patch set,
expose too much information (= the actual implementation) about the types.

For solving this data hiding problem, we'd have to (a) introduce
intermittent structure types (similar to EFI_OBJECT), and then (b) we'd
have to rework the rest of the implementation for that. Using
EFI_FONT_HANDLE as example:

(a) introduce the intermittent (opaque) structure type:

struct EFI_FONT_OBJECT;
typedef struct EFI_FONT_OBJECT *EFI_FONT_HANDLE;

(b) rework the implementation:

struct EFI_FONT_OBJECT {
LIST_ENTRY Entry;
};

typedef struct _HII_GLOBAL_FONT_INFO {
UINTN Signature;
struct EFI_FONT_OBJECT FontObject;
HII_FONT_PACKAGE_INSTANCE *FontPackage;
UINTN FontInfoSize;
EFI_FONT_INFO *FontInfo;
} HII_GLOBAL_FONT_INFO;

and then every reference to "HII_GLOBAL_FONT_INFO.Entry" would have to
be updated to "HII_GLOBAL_FONT_INFO.FontObject.Entry".

It's likely doable, but it would take a lot of work.


If we wanted to continue using this patch for sanity-checking edk2, then
one option would be to bracket the changes with #ifdef's. That is, make
the "type separation" dependent on a new feature test macro.

Normally, the feature test macro would not be defined (as it breaks UEFI
spec conformance, see above). But in CI, one set of the builds would
define the macro, for sanity checking edk2 itself.

Thanks
Laszlo



Thanks,
Ray


-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Laszlo Ersek
Sent: Tuesday, September 17, 2019 12:49 PM
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: Achin Gupta <achin.gupta@arm.com>; Andrew Fish <afish@apple.com>; Anthony Perard <anthony.perard@citrix.com>;
Ard Biesheuvel <ard.biesheuvel@linaro.org>; You, Benjamin <benjamin.you@intel.com>; Zhang, Chao B
<chao.b.zhang@intel.com>; Bi, Dandan <dandan.bi@intel.com>; David Woodhouse <dwmw2@infradead.org>; Dong, Eric
<eric.dong@intel.com>; Dong, Guo <guo.dong@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Carsey, Jaben
<jaben.carsey@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Yao, Jiewen
<jiewen.yao@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>; Julien Grall <julien.grall@arm.com>; Leif Lindholm
<leif.lindholm@linaro.org>; Gao, Liming <liming.gao@intel.com>; Ma, Maurice <maurice.ma@intel.com>; Kinney, Michael
D <michael.d.kinney@intel.com>; Ni, Ray <ray.ni@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Supreeth Venkatesh
<supreeth.venkatesh@arm.com>; Gao, Zhichao <zhichao.gao@intel.com>
Subject: [edk2-devel] [PATCH 01/35] DO NOT APPLY: edk2: turn standard handle types into pointers to non-VOID

Unfortunately, the UEFI / PI / Shell specs define a number of handle types
as pointers to VOID. This is a design mistake; those types should have
been pointers to incomplete union or structure types. Any
pointer-to-object type converts implicitly to, and from, pointer-to-void,
which prevents compilers from catching at least the following two types of
mistakes:

- mixing up one handle type with another (for example, EFI_HANDLE with
EFI_EVENT),

- getting the depth of indirection wrong (for example, mixing up
(EFI_HANDLE*) with EFI_HANDLE).

In order to root out such mistakes in the edk2 codebase, introduce
incomplete structure types with unique tags, such as:

struct EFI_FOOBAR_OBJECT;
typedef struct EFI_FOOBAR_OBJECT *EFI_FOOBAR_HANDLE;

replacing the spec mandated

typedef VOID *EFI_FOOBAR_HANDLE;

(For some types, such as:

- EFI_ACPI_HANDLE,
- EFI_EVENT,
- EFI_FONT_HANDLE,
- EFI_HANDLE,
- EFI_HII_HANDLE,
- EFI_S3_BOOT_SCRIPT_POSITION,
- SHELL_FILE_HANDLE,

we connect the actual complete type (the internal, implementation-specific
type) to the typedef. Some of these also demonstrate how the code could
have looked in practice if the specs had used proper opaque (=incomplete)
types.)

Then, unleash "build" on the package DSC files. This causes the compiler
to warn about incompatible pointer assignments, and to stop the build.

The rest of the series addresses the resultant warnings. Each patch
belongs in one of two categories:

- semantic cleanups (no functional / behavioral changes),
- actual bugfixes.

As the subject line of this patch states, this specific patch is *not*
meant to be applied. It is just a "what if" patch that temporarily
isolates the standard types from each other, the way the specs should
have, so that the compiler have more information to work with.

Cc: Achin Gupta <achin.gupta@arm.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jian Wang <jian.j.wang@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
MdePkg/Include/Pi/PiPeiCis.h | 6 ++++--
MdePkg/Include/Protocol/AcpiSystemDescriptionTable.h | 3 ++-
MdePkg/Include/Protocol/Bis.h | 3 ++-
MdePkg/Include/Protocol/Eap.h | 3 ++-
MdePkg/Include/Protocol/HiiFont.h | 3 +--
MdePkg/Include/Protocol/MmMp.h | 3 ++-
MdePkg/Include/Protocol/S3SaveState.h | 2 +-
MdePkg/Include/Protocol/Shell.h | 3 ++-
MdePkg/Include/Protocol/UserManager.h | 9 ++++++---
MdePkg/Include/Uefi/UefiBaseType.h | 6 ++++--
MdePkg/Include/Uefi/UefiInternalFormRepresentation.h | 3 ++-
MdeModulePkg/Core/Dxe/Event/Event.h | 2 +-
MdeModulePkg/Core/Dxe/Hand/Handle.h | 2 +-
MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 2 +-
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.h | 2 +-
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h | 2 +-
StandaloneMmPkg/Core/StandaloneMmCore.h | 2 +-
17 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/MdePkg/Include/Pi/PiPeiCis.h b/MdePkg/Include/Pi/PiPeiCis.h
index d9d4ed7d413a..3e9e82b62ae9 100644
--- a/MdePkg/Include/Pi/PiPeiCis.h
+++ b/MdePkg/Include/Pi/PiPeiCis.h
@@ -18,12 +18,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
///
/// The handles of EFI FV.
///
-typedef VOID *EFI_PEI_FV_HANDLE;
+struct EFI_PEI_FV_OBJECT;
+typedef struct EFI_PEI_FV_OBJECT *EFI_PEI_FV_HANDLE;

///
/// The handles of EFI FFS.
///
-typedef VOID *EFI_PEI_FILE_HANDLE;
+struct EFI_PEI_FILE_OBJECT;
+typedef struct EFI_PEI_FILE_OBJECT *EFI_PEI_FILE_HANDLE;

///
/// Declare the forward reference data structure for EFI_PEI_SERVICE.
diff --git a/MdePkg/Include/Protocol/AcpiSystemDescriptionTable.h
b/MdePkg/Include/Protocol/AcpiSystemDescriptionTable.h
index a8e0b24c6c8d..8a1863f3e03d 100644
--- a/MdePkg/Include/Protocol/AcpiSystemDescriptionTable.h
+++ b/MdePkg/Include/Protocol/AcpiSystemDescriptionTable.h
@@ -16,7 +16,8 @@
{ 0xeb97088e, 0xcfdf, 0x49c6, { 0xbe, 0x4b, 0xd9, 0x6, 0xa5, 0xb2, 0xe, 0x86 }}

typedef UINT32 EFI_ACPI_TABLE_VERSION;
-typedef VOID *EFI_ACPI_HANDLE;
+struct EFI_ACPI_OBJECT;
+typedef struct EFI_ACPI_OBJECT *EFI_ACPI_HANDLE;

#define EFI_ACPI_TABLE_VERSION_NONE (1 << 0)
#define EFI_ACPI_TABLE_VERSION_1_0B (1 << 1)
diff --git a/MdePkg/Include/Protocol/Bis.h b/MdePkg/Include/Protocol/Bis.h
index 2be6718f4bc2..8eca94512d03 100644
--- a/MdePkg/Include/Protocol/Bis.h
+++ b/MdePkg/Include/Protocol/Bis.h
@@ -37,7 +37,8 @@ typedef struct _EFI_BIS_PROTOCOL EFI_BIS_PROTOCOL;
//
// Basic types
//
-typedef VOID *BIS_APPLICATION_HANDLE;
+struct BIS_APPLICATION_OBJECT;
+typedef struct BIS_APPLICATION_OBJECT *BIS_APPLICATION_HANDLE;
typedef UINT16 BIS_ALG_ID;
typedef UINT32 BIS_CERT_ID;

diff --git a/MdePkg/Include/Protocol/Eap.h b/MdePkg/Include/Protocol/Eap.h
index 203d0f40b0dd..06584ef409d0 100644
--- a/MdePkg/Include/Protocol/Eap.h
+++ b/MdePkg/Include/Protocol/Eap.h
@@ -28,7 +28,8 @@ typedef struct _EFI_EAP_PROTOCOL EFI_EAP_PROTOCOL;
/// Type for the identification number assigned to the Port by the
/// System in which the Port resides.
///
-typedef VOID * EFI_PORT_HANDLE;
+struct EFI_PORT_OBJECT;
+typedef struct EFI_PORT_OBJECT *EFI_PORT_HANDLE;

///
/// EAP Authentication Method Type (RFC 3748)
diff --git a/MdePkg/Include/Protocol/HiiFont.h b/MdePkg/Include/Protocol/HiiFont.h
index 1f2e321ea4e2..450cad9ada70 100644
--- a/MdePkg/Include/Protocol/HiiFont.h
+++ b/MdePkg/Include/Protocol/HiiFont.h
@@ -19,8 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
{ 0xe9ca4775, 0x8657, 0x47fc, { 0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x8, 0x43, 0x24 } }

typedef struct _EFI_HII_FONT_PROTOCOL EFI_HII_FONT_PROTOCOL;
-
-typedef VOID *EFI_FONT_HANDLE;
+typedef LIST_ENTRY *EFI_FONT_HANDLE;

///
/// EFI_HII_OUT_FLAGS.
diff --git a/MdePkg/Include/Protocol/MmMp.h b/MdePkg/Include/Protocol/MmMp.h
index beace1386cbe..cd4e0db47e08 100644
--- a/MdePkg/Include/Protocol/MmMp.h
+++ b/MdePkg/Include/Protocol/MmMp.h
@@ -36,7 +36,8 @@
//
// Completion token
//
-typedef VOID* MM_COMPLETION;
+struct MM_COMPLETION_OBJECT;
+typedef struct MM_COMPLETION_OBJECT* MM_COMPLETION;

typedef struct {
MM_COMPLETION Completion;
diff --git a/MdePkg/Include/Protocol/S3SaveState.h b/MdePkg/Include/Protocol/S3SaveState.h
index c1b8f8b9e08d..235c36be6737 100644
--- a/MdePkg/Include/Protocol/S3SaveState.h
+++ b/MdePkg/Include/Protocol/S3SaveState.h
@@ -21,7 +21,7 @@
{ 0xe857caf6, 0xc046, 0x45dc, { 0xbe, 0x3f, 0xee, 0x7, 0x65, 0xfb, 0xa8, 0x87 }}


-typedef VOID *EFI_S3_BOOT_SCRIPT_POSITION;
+typedef UINT8 *EFI_S3_BOOT_SCRIPT_POSITION;

typedef struct _EFI_S3_SAVE_STATE_PROTOCOL EFI_S3_SAVE_STATE_PROTOCOL;

diff --git a/MdePkg/Include/Protocol/Shell.h b/MdePkg/Include/Protocol/Shell.h
index cfb7878228c5..bf791792b4f2 100644
--- a/MdePkg/Include/Protocol/Shell.h
+++ b/MdePkg/Include/Protocol/Shell.h
@@ -11,12 +11,13 @@
#define __EFI_SHELL_PROTOCOL_H__

#include <Guid/FileInfo.h>
+#include <Protocol/SimpleFileSystem.h>

#define EFI_SHELL_PROTOCOL_GUID \
{ \
0x6302d008, 0x7f9b, 0x4f30, { 0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e } \
}
-typedef VOID *SHELL_FILE_HANDLE;
+typedef EFI_FILE_PROTOCOL *SHELL_FILE_HANDLE;

typedef enum {
///
diff --git a/MdePkg/Include/Protocol/UserManager.h b/MdePkg/Include/Protocol/UserManager.h
index 26ac4955f1ec..9abfcffbeebf 100644
--- a/MdePkg/Include/Protocol/UserManager.h
+++ b/MdePkg/Include/Protocol/UserManager.h
@@ -24,8 +24,10 @@
0xbaf1e6de, 0x209e, 0x4adb, { 0x8d, 0x96, 0xfd, 0x8b, 0x71, 0xf3, 0xf6, 0x83 } \
}

-typedef VOID *EFI_USER_PROFILE_HANDLE;
-typedef VOID *EFI_USER_INFO_HANDLE;
+struct EFI_USER_PROFILE_OBJECT;
+typedef struct EFI_USER_PROFILE_OBJECT *EFI_USER_PROFILE_HANDLE;
+struct EFI_USER_INFO_OBJECT;
+typedef struct EFI_USER_INFO_OBJECT *EFI_USER_INFO_HANDLE;

///
/// The attributes of the user profile information.
@@ -157,7 +159,8 @@ typedef CHAR16 *EFI_USER_INFO_CREDENTIAL_PROVIDER_NAME;
/// Biometric Exchange Formats Framework) specification.
///
#define EFI_USER_INFO_CBEFF_RECORD 0x0B
-typedef VOID *EFI_USER_INFO_CBEFF;
+struct EFI_USER_INFO_CBEFF_OBJECT;
+typedef struct EFI_USER_INFO_CBEFF_OBJECT *EFI_USER_INFO_CBEFF;
///
/// Indicates how close of a match the fingerprint must be in order to be considered a match.
///
diff --git a/MdePkg/Include/Uefi/UefiBaseType.h b/MdePkg/Include/Uefi/UefiBaseType.h
index a62f13dd064f..be5831991b52 100644
--- a/MdePkg/Include/Uefi/UefiBaseType.h
+++ b/MdePkg/Include/Uefi/UefiBaseType.h
@@ -28,11 +28,13 @@ typedef RETURN_STATUS EFI_STATUS;
///
/// A collection of related interfaces.
///
-typedef VOID *EFI_HANDLE;
+struct EFI_OBJECT;
+typedef struct EFI_OBJECT *EFI_HANDLE;
///
/// Handle to an event structure.
///
-typedef VOID *EFI_EVENT;
+struct EFI_EVENT_OBJECT;
+typedef struct EFI_EVENT_OBJECT *EFI_EVENT;
///
/// Task priority level.
///
diff --git a/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h
b/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h
index 4a1346a599d0..93bf9e9e0f13 100644
--- a/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h
+++ b/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h
@@ -20,7 +20,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
///
/// The following types are currently defined:
///
-typedef VOID* EFI_HII_HANDLE;
+struct EFI_HII_OBJECT;
+typedef struct EFI_HII_OBJECT* EFI_HII_HANDLE;
typedef CHAR16* EFI_STRING;
typedef UINT16 EFI_IMAGE_ID;
typedef UINT16 EFI_QUESTION_ID;
diff --git a/MdeModulePkg/Core/Dxe/Event/Event.h b/MdeModulePkg/Core/Dxe/Event/Event.h
index 8141c5003eec..42590cb1dd09 100644
--- a/MdeModulePkg/Core/Dxe/Event/Event.h
+++ b/MdeModulePkg/Core/Dxe/Event/Event.h
@@ -37,7 +37,7 @@ typedef struct {
} TIMER_EVENT_INFO;

#define EVENT_SIGNATURE SIGNATURE_32('e','v','n','t')
-typedef struct {
+typedef struct EFI_EVENT_OBJECT {
UINTN Signature;
UINT32 Type;
UINT32 SignalCount;
diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.h b/MdeModulePkg/Core/Dxe/Hand/Handle.h
index 83eb2b9f3afe..1f1ab3274e8a 100644
--- a/MdeModulePkg/Core/Dxe/Hand/Handle.h
+++ b/MdeModulePkg/Core/Dxe/Hand/Handle.h
@@ -15,7 +15,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
///
/// IHANDLE - contains a list of protocol handles
///
-typedef struct {
+typedef struct EFI_OBJECT {
UINTN Signature;
/// All handles list of IHANDLE
LIST_ENTRY AllHandles;
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
index 0908e7f4e9e7..c55da58d465e 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
@@ -145,7 +145,7 @@ typedef struct {
///
/// IHANDLE - contains a list of protocol handles
///
-typedef struct {
+typedef struct EFI_OBJECT {
UINTN Signature;
/// All handles list of IHANDLE
LIST_ENTRY AllHandles;
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.h
b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.h
index 50d4c96edb63..bfebbb1f8182 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.h
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.h
@@ -88,7 +88,7 @@ struct _EFI_AML_NODE_LIST {
// This buffer should not be freed.
// Size is the total size of this ACPI node buffer.
//
-typedef struct {
+typedef struct EFI_ACPI_OBJECT {
UINT32 Signature;
UINT8 *Buffer;
UINTN Size;
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
index 4a3feab94df5..48972d0fcad6 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
@@ -274,7 +274,7 @@ typedef struct _HII_DATABASE_PACKAGE_LIST_INSTANCE {

#define HII_HANDLE_SIGNATURE SIGNATURE_32 ('h','i','h','l')

-typedef struct {
+typedef struct EFI_HII_OBJECT {
UINTN Signature;
LIST_ENTRY Handle;
UINTN Key;
diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.h b/StandaloneMmPkg/Core/StandaloneMmCore.h
index 4d0eed273f50..dcf91bc5e916 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.h
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.h
@@ -105,7 +105,7 @@ typedef struct {
///
/// IHANDLE - contains a list of protocol handles
///
-typedef struct {
+typedef struct EFI_OBJECT {
UINTN Signature;
/// All handles list of IHANDLE
LIST_ENTRY AllHandles;
--
2.19.1.3.g30247aa5d201



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#47388): https://edk2.groups.io/g/devel/message/47388
Mute This Topic: https://groups.io/mt/34180199/1712937
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [ray.ni@intel.com]
-=-=-=-=-=-=


[PATCH v3] BaseTools/LzmaCompress: Add two switches

Zhang, Shenglei
 

From: "Zhang, Shenglei" <shenglei.zhang@intel.com>

As is requested in the BZ 2077, add two switches to support setting
compression mode and dictionary size.
(https://bugzilla.tianocore.org/show_bug.cgi?id=2077)

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
v2: 1.Update DictionarySize to mDictionarySize.
2.Update CompressionMode to mCompressionMode.
3.Use CLzmaEncProps *props as the input parameter of the
function Encode.

v3: Remove the component "mDictionarySize >= 0" in the if judgement.line 303
This is to fix the build failure under Mac OS. Beacuse the type of
mDictionarySize is UINT64, which is always >= 0.


.../Source/C/LzmaCompress/LzmaCompress.c | 43 +++++++++++++++----
BaseTools/Source/C/LzmaCompress/GNUmakefile | 4 +-
BaseTools/Source/C/LzmaCompress/Makefile | 4 +-
3 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
index a3607f9b2084..328ecfa930da 100644
--- a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
+++ b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
@@ -5,7 +5,7 @@
LzmaUtil.c -- Test application for LZMA compression
2018-04-30 : Igor Pavlov : Public domain

- Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -23,6 +23,7 @@
#include "Sdk/C/LzmaEnc.h"
#include "Sdk/C/Bra.h"
#include "CommonLib.h"
+#include "ParseInf.h"

#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)

@@ -36,10 +37,14 @@ const char *kCantReadMessage = "Can not read input file";
const char *kCantWriteMessage = "Can not write output file";
const char *kCantAllocateMessage = "Can not allocate memory";
const char *kDataErrorMessage = "Data error";
+const char *kInvalidParamValMessage = "Invalid parameter value";

static Bool mQuietMode = False;
static CONVERTER_TYPE mConType = NoConverter;

+UINT64 mDictionarySize = 31;
+UINT64 mCompressionMode = 2;
+
#define UTILITY_NAME "LzmaCompress"
#define UTILITY_MAJOR_VERSION 0
#define UTILITY_MINOR_VERSION 2
@@ -58,6 +63,8 @@ void PrintHelp(char *buffer)
" -v, --verbose: increase output messages\n"
" -q, --quiet: reduce output messages\n"
" --debug [0-9]: set debug level\n"
+ " -a: set compression mode 0 = fast, 1 = normal, default: 1 (normal)\n"
+ " d: sets Dictionary size - [0, 30], default: 23 (8MB)\n"
" --version: display the program version and exit\n"
" -h, --help: display this help text\n"
);
@@ -87,7 +94,7 @@ void PrintVersion(char *buffer)
sprintf (buffer, "%s Version %d.%d %s ", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
}

-static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize)
+static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize, CLzmaEncProps *props)
{
SRes res;
size_t inSize = (size_t)fileSize;
@@ -95,10 +102,6 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file
Byte *outBuffer = 0;
Byte *filteredStream = 0;
size_t outSize;
- CLzmaEncProps props;
-
- LzmaEncProps_Init(&props);
- LzmaEncProps_Normalize(&props);

if (inSize != 0) {
inBuffer = (Byte *)MyAlloc(inSize);
@@ -151,7 +154,7 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file

res = LzmaEncode(outBuffer + LZMA_HEADER_SIZE, &outSizeProcessed,
mConType != NoConverter ? filteredStream : inBuffer, inSize,
- &props, outBuffer, &outPropsSize, 0,
+ props, outBuffer, &outPropsSize, 0,
NULL, &g_Alloc, &g_Alloc);

if (res != SZ_OK)
@@ -246,6 +249,12 @@ int main2(int numArgs, const char *args[], char *rs)
const char *outputFile = "file.tmp";
int param;
UInt64 fileSize;
+ CLzmaEncProps *props;
+
+ props = (CLzmaEncProps *)AllocateZeroPool(sizeof(CLzmaEncProps));
+
+ LzmaEncProps_Init(props);
+ LzmaEncProps_Normalize(props);

FileSeqInStream_CreateVTable(&inStream);
File_Construct(&inStream.file);
@@ -280,6 +289,24 @@ int main2(int numArgs, const char *args[], char *rs)
// parameter compatibility with other build tools.
//
param++;
+ } else if (strcmp(args[param], "-a") == 0) {
+ AsciiStringToUint64(args[param + 1],FALSE,&mCompressionMode);
+ if ((mCompressionMode == 0)||(mCompressionMode == 1)){
+ props->algo = (int)mCompressionMode;
+ param++;
+ continue;
+ } else {
+ return PrintError(rs, kInvalidParamValMessage);
+ }
+ } else if (strcmp(args[param], "d") == 0) {
+ AsciiStringToUint64(args[param + 1],FALSE,&mDictionarySize);
+ if (mDictionarySize <= 30){
+ props->dictSize = (UINT32)mDictionarySize;
+ param++;
+ continue;
+ } else {
+ return PrintError(rs, kInvalidParamValMessage);
+ }
} else if (
strcmp(args[param], "-h") == 0 ||
strcmp(args[param], "--help") == 0
@@ -335,7 +362,7 @@ int main2(int numArgs, const char *args[], char *rs)
if (!mQuietMode) {
printf("Encoding\n");
}
- res = Encode(&outStream.vt, &inStream.vt, fileSize);
+ res = Encode(&outStream.vt, &inStream.vt, fileSize, props);
}
else
{
diff --git a/BaseTools/Source/C/LzmaCompress/GNUmakefile b/BaseTools/Source/C/LzmaCompress/GNUmakefile
index 533f0a59a0af..c837e7782373 100644
--- a/BaseTools/Source/C/LzmaCompress/GNUmakefile
+++ b/BaseTools/Source/C/LzmaCompress/GNUmakefile
@@ -1,13 +1,15 @@
## @file
# GNU/Linux makefile for 'LzmaCompress' module build.
#
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
MAKEROOT ?= ..

APPNAME = LzmaCompress

+LIBS = -lCommon
+
SDK_C = Sdk/C

OBJECTS = \
diff --git a/BaseTools/Source/C/LzmaCompress/Makefile b/BaseTools/Source/C/LzmaCompress/Makefile
index 12be48de2940..055f5d3ac3ca 100644
--- a/BaseTools/Source/C/LzmaCompress/Makefile
+++ b/BaseTools/Source/C/LzmaCompress/Makefile
@@ -1,14 +1,14 @@
## @file
# Windows makefile for 'LzmaCompress' module build.
#
-# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
!INCLUDE ..\Makefiles\ms.common

APPNAME = LzmaCompress

-#LIBS = $(LIB_PATH)\Common.lib
+LIBS = $(LIB_PATH)\Common.lib

SDK_C = Sdk\C

--
2.18.0.windows.1


[Patch] EmulatorPkg/TimerLib: Add missing GetTimeInNanoSecond function

Liming Gao
 

From: mjohn4 <michael.johnson@intel.com>

Add GetTimeInNanoSecond, already declared in the TimerLib API,
to EmulatorPkg implementations of TimerLib.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Johnson, Michael <michael.johnson@intel.com>
---
.../Library/DxeCoreTimerLib/DxeCoreTimerLib.c | 45 ++++++++++++++++++++-
EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c | 45 ++++++++++++++++++++-
EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c | 47 +++++++++++++++++++++-
3 files changed, 134 insertions(+), 3 deletions(-)

diff --git a/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c b/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c
index c331cbba9c..ab0de143c4 100644
--- a/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c
+++ b/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c
@@ -1,12 +1,13 @@
/** @file
A non-functional instance of the Timer Library.

- Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include <PiPei.h>
+#include <Library/BaseLib.h>
#include <Library/TimerLib.h>
#include <Library/DebugLib.h>
#include <Library/EmuThunkLib.h>
@@ -119,4 +120,46 @@ GetPerformanceCounterProperties (
return gEmuThunk->QueryPerformanceFrequency ();
}

+/**
+ Converts elapsed ticks of performance counter to time in nanoseconds.
+
+ This function converts the elapsed ticks of running performance counter to
+ time value in unit of nanoseconds.
+
+ @param Ticks The number of elapsed ticks of running performance counter.
+
+ @return The elapsed time in nanoseconds.
+
+**/
+UINT64
+EFIAPI
+GetTimeInNanoSecond (
+ IN UINT64 Ticks
+ )
+{
+ UINT64 Frequency;
+ UINT64 NanoSeconds;
+ UINT64 Remainder;
+ INTN Shift;
+
+ Frequency = GetPerformanceCounterProperties (NULL, NULL);
+
+ //
+ // Ticks
+ // Time = --------- x 1,000,000,000
+ // Frequency
+ //
+ NanoSeconds = MultU64x32 (DivU64x64Remainder (Ticks, Frequency, &Remainder), 1000000000u);
+
+ //
+ // Ensure (Remainder * 1,000,000,000) will not overflow 64-bit.
+ // Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34,
+ // i.e. highest bit set in Remainder should <= 33.
+ //
+ Shift = MAX (0, HighBitSet64 (Remainder) - 33);
+ Remainder = RShiftU64 (Remainder, (UINTN) Shift);
+ Frequency = RShiftU64 (Frequency, (UINTN) Shift);
+ NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);

+ return NanoSeconds;
+}
diff --git a/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c b/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c
index 14cae4214c..1bbc9e0162 100644
--- a/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c
+++ b/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c
@@ -1,7 +1,7 @@
/** @file
A non-functional instance of the Timer Library.

- Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -198,3 +198,46 @@ DxeTimerLibConstructor (
return EFI_SUCCESS;
}

+/**
+ Converts elapsed ticks of performance counter to time in nanoseconds.
+
+ This function converts the elapsed ticks of running performance counter to
+ time value in unit of nanoseconds.
+
+ @param Ticks The number of elapsed ticks of running performance counter.
+
+ @return The elapsed time in nanoseconds.
+
+**/
+UINT64
+EFIAPI
+GetTimeInNanoSecond (
+ IN UINT64 Ticks
+ )
+{
+ UINT64 Frequency;
+ UINT64 NanoSeconds;
+ UINT64 Remainder;
+ INTN Shift;
+
+ Frequency = GetPerformanceCounterProperties (NULL, NULL);
+
+ //
+ // Ticks
+ // Time = --------- x 1,000,000,000
+ // Frequency
+ //
+ NanoSeconds = MultU64x32 (DivU64x64Remainder (Ticks, Frequency, &Remainder), 1000000000u);
+
+ //
+ // Ensure (Remainder * 1,000,000,000) will not overflow 64-bit.
+ // Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34,
+ // i.e. highest bit set in Remainder should <= 33.
+ //
+ Shift = MAX (0, HighBitSet64 (Remainder) - 33);
+ Remainder = RShiftU64 (Remainder, (UINTN) Shift);
+ Frequency = RShiftU64 (Frequency, (UINTN) Shift);
+ NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
+
+ return NanoSeconds;
+}
diff --git a/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c b/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c
index cce46fb366..132abb2c04 100644
--- a/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c
+++ b/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c
@@ -1,12 +1,13 @@
/** @file
A non-functional instance of the Timer Library.

- Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include <PiPei.h>
+#include <Library/BaseLib.h>
#include <Library/TimerLib.h>
#include <Library/DebugLib.h>
#include <Library/PeiServicesLib.h>
@@ -166,3 +167,47 @@ GetPerformanceCounterProperties (

return 0;
}
+
+/**
+ Converts elapsed ticks of performance counter to time in nanoseconds.
+
+ This function converts the elapsed ticks of running performance counter to
+ time value in unit of nanoseconds.
+
+ @param Ticks The number of elapsed ticks of running performance counter.
+
+ @return The elapsed time in nanoseconds.
+
+**/
+UINT64
+EFIAPI
+GetTimeInNanoSecond (
+ IN UINT64 Ticks
+ )
+{
+ UINT64 Frequency;
+ UINT64 NanoSeconds;
+ UINT64 Remainder;
+ INTN Shift;
+
+ Frequency = GetPerformanceCounterProperties (NULL, NULL);
+
+ //
+ // Ticks
+ // Time = --------- x 1,000,000,000
+ // Frequency
+ //
+ NanoSeconds = MultU64x32 (DivU64x64Remainder (Ticks, Frequency, &Remainder), 1000000000u);
+
+ //
+ // Ensure (Remainder * 1,000,000,000) will not overflow 64-bit.
+ // Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34,
+ // i.e. highest bit set in Remainder should <= 33.
+ //
+ Shift = MAX (0, HighBitSet64 (Remainder) - 33);
+ Remainder = RShiftU64 (Remainder, (UINTN) Shift);
+ Frequency = RShiftU64 (Frequency, (UINTN) Shift);
+ NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
+
+ return NanoSeconds;
+}
--
2.13.0.windows.1


Re: [PATCH v2 0/2] *** Add VS2019 Support ***

Liming Gao
 

That's good. I have no other comment. Reviewed-by: Liming Gao <liming.gao@intel.com>

-----Original Message-----
From: Cheng, Ching JenX
Sent: Wednesday, September 18, 2019 9:51 AM
To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
Subject: RE: [edk2-devel] [PATCH v2 0/2] *** Add VS2019 Support ***

Hi Liming,

The VS2017 is still working fine with this changes,
I have verified it with VS2019, VS2017 and VS2015 build,

Thanks,
Allen

-----Original Message-----
From: Gao, Liming
Sent: Tuesday, September 17, 2019 10:57 PM
To: devel@edk2.groups.io; Cheng, Ching JenX
<ching.jenx.cheng@intel.com>
Subject: RE: [edk2-devel] [PATCH v2 0/2] *** Add VS2019 Support ***

Ching:
The change is good. With this change, have you verified VS2017 tool chain?
I want to make sure there is no impact on VS2017.

Thanks
Liming
-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Cheng, Ching JenX
Sent: Tuesday, September 17, 2019 11:23 AM
To: devel@edk2.groups.io; Cheng, Ching JenX
<ching.jenx.cheng@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 0/2] *** Add VS2019 Support ***

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

In order to support VS2019 on EDK2, the following patches was modified
def and batch files 1. Add VS2019 x86/64 definitions on tools_def.template
2. Add VS2019 support on toolsetup batches, and add version check with
command vswhere
Because VS2019 and VS2017 using the same vswhere to get the
InstallationPath

v2: In 01/02, add ARM/AARCH64/EBC Definitions, Combine VS2017_HOST
and
VS2019_HOST to VS_HOST

Ching JenX Cheng (2):
Add VS2019 Toolchain def
Add VS2019 Support on ToolSetup Batches

BaseTools/Conf/tools_def.template | 220
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++-------------------
BaseTools/get_vsvars.bat | 37
++++++++++++++++++++++++++++++-------
BaseTools/set_vsprefix_envs.bat | 70
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++-----
BaseTools/toolsetup.bat | 16 +++++++++++++---
edksetup.bat | 6 ++++--
5 files changed, 313 insertions(+), 36 deletions(-)

--
2.21.0.windows.1






Re: [PATCH v2 1/1] BaseTools: Add more parameter checking for CopyFileOnChange()

Bob Feng
 

Reviewed-by: Bob Feng <bob.c.feng@intel.com>

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Steven Shi
Sent: Wednesday, September 18, 2019 11:21 AM
To: devel@edk2.groups.io
Cc: Gao, Liming <liming.gao@intel.com>; Feng, Bob C <bob.c.feng@intel.com>
Subject: [edk2-devel] [PATCH v2 1/1] BaseTools: Add more parameter checking for CopyFileOnChange()

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

The current CopyFileOnChange() method in Misc.py does not accept the input SrcFile parameter as a dir, but the method does not check the SrcFile is dir or not. This patch is to add more input parameter type checking and error message output for method CopyFileOnChange.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Steven Shi <steven.shi@intel.com>
---
BaseTools/Source/Python/Common/Misc.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 714eb840ea..a488536cb4 100755
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -536,7 +536,8 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None):
SrcFile = LongFilePath(SrcFile)
Dst = LongFilePath(Dst)

- if not os.path.exists(SrcFile):
+ if os.path.isdir(SrcFile):
+ EdkLogger.error(None, FILE_COPY_FAILURE,
+ ExtraData='CopyFileOnChange SrcFile is a dir, not a file: %s' %
+ SrcFile)
return False

if os.path.isdir(Dst):
--
2.17.1.windows.2


[PATCH] MdePkg: Changes in comments

Gris87
 

Simple changes for comments...

Signed-off-by: Gris87 <Gris87@yandex.ru>
---
MdePkg/Include/Protocol/AbsolutePointer.h | 12 ++++++------
MdePkg/Include/Protocol/SimplePointer.h | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/MdePkg/Include/Protocol/AbsolutePointer.h b/MdePkg/Include/P=
rotocol/AbsolutePointer.h
index 77d34ae5bd..90c9664dbd 100644
--- a/MdePkg/Include/Protocol/AbsolutePointer.h
+++ b/MdePkg/Include/Protocol/AbsolutePointer.h
@@ -33,14 +33,14 @@ typedef struct _EFI_ABSOLUTE_POINTER_PROTOCOL EFI_ABS=
OLUTE_POINTER_PROTOCOL;
**/
typedef struct {
UINT64 AbsoluteMinX; ///< The Absolute Minimum of the device on the x-=
axis
- UINT64 AbsoluteMinY; ///< The Absolute Minimum of the device on the y =
axis.
+ UINT64 AbsoluteMinY; ///< The Absolute Minimum of the device on the y-=
axis
UINT64 AbsoluteMinZ; ///< The Absolute Minimum of the device on the z-=
axis
UINT64 AbsoluteMaxX; ///< The Absolute Maximum of the device on the x-=
axis. If 0, and the
- ///< AbsoluteMinX is 0, then the pointer device d=
oes not support a xaxis
- UINT64 AbsoluteMaxY; ///< The Absolute Maximum of the device on the y =
-axis. If 0, and the
- ///< AbsoluteMinX is 0, then the pointer device d=
oes not support a yaxis.
- UINT64 AbsoluteMaxZ; ///< The Absolute Maximum of the device on the z-=
axis. If 0 , and the
- ///< AbsoluteMinX is 0, then the pointer device d=
oes not support a zaxis
+ ///< AbsoluteMinX is 0, then the pointer device d=
oes not support a x-axis
+ UINT64 AbsoluteMaxY; ///< The Absolute Maximum of the device on the y-=
axis. If 0, and the
+ ///< AbsoluteMinY is 0, then the pointer device d=
oes not support a y-axis
+ UINT64 AbsoluteMaxZ; ///< The Absolute Maximum of the device on the z-=
axis. If 0, and the
+ ///< AbsoluteMinZ is 0, then the pointer device d=
oes not support a z-axis
UINT32 Attributes; ///< The following bits are set as needed (or'd t=
ogether) to indicate the
///< capabilities of the device supported. The re=
maining bits are undefined
///< and should be 0
diff --git a/MdePkg/Include/Protocol/SimplePointer.h b/MdePkg/Include/Pro=
tocol/SimplePointer.h
index 2f5a940ff9..a63028cb80 100644
--- a/MdePkg/Include/Protocol/SimplePointer.h
+++ b/MdePkg/Include/Protocol/SimplePointer.h
@@ -54,12 +54,12 @@ typedef struct {
UINT64 ResolutionX;
///
/// The resolution of the pointer device on the y-axis in counts/mm.
- /// If 0, then the pointer device does not support an x-axis.
+ /// If 0, then the pointer device does not support an y-axis.
///
UINT64 ResolutionY;
///
/// The resolution of the pointer device on the z-axis in counts/mm.
- /// If 0, then the pointer device does not support an x-axis.
+ /// If 0, then the pointer device does not support an z-axis.
///
UINT64 ResolutionZ;
///
--=20
2.19.1


[edk2-test][Patch] uefi-sct/SctPkg: Fix invalid attribute combination

xianhui liu <xianhuix.liu@...>
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1942
avoid using EFI_VARIABLE_RUNTIME_ACCESS without
EFI_VARIABLE_BOOTSERVICE_ACCESS in AttrArray.

Cc: Oleksiy <oleksiyy@ami.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Eric Jin <eric.jin@intel.com>
Signed-off-by: xianhui liu <xianhuix.liu@intel.com>
---
.../BlackBoxTest/AuthVariableServicesBBTestConformance.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/AuthVariableServicesBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/AuthVariableServicesBBTestConformance.c
index a1d1c4c3..23b00e35 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/AuthVariableServicesBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/AuthVariableServicesBBTestConformance.c
@@ -1,7 +1,7 @@
/** @file

Copyright 2006 - 2012 Unified EFI, Inc.<BR>
- Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2019, 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
@@ -160,19 +160,16 @@ AuthVariableDERConfTest (
// For 1 attribute.
//
EFI_VARIABLE_NON_VOLATILE,
- EFI_VARIABLE_RUNTIME_ACCESS,
EFI_VARIABLE_BOOTSERVICE_ACCESS,
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS,

//
// For 2 attributes.
//
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS,

EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS,

EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS,

@@ -180,7 +177,6 @@ AuthVariableDERConfTest (
// For 3 attributes.
//
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS,
EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS,

--
2.14.1.windows.1


Re: [PATCH v4] MinPlatformPkg/TestPointCheckLib: Add check for pointers

Chiu, Chasel
 

Some minor comments for coding style in below inline, you can correct them when pushing the commit.
With those coding style issues fixed, Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Zhang,
Shenglei
Sent: Wednesday, September 18, 2019 2:34 PM
To: devel@edk2.groups.io
Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
<chasel.chiu@intel.com>; Desimone, Nathaniel L
<nathaniel.l.desimone@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [edk2-devel] [PATCH v4] MinPlatformPkg/TestPointCheckLib: Add
check for pointers

In DxeCheckBootVariable.c, add check for BootOrder and Variable that
return EFI_NOT_FOUND when they are NULL.
In DxeCheckGcd.c, add check for GcdIoMap to ensure it not NULL when
allocating memory to what it points to.

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---

v2: Update copyright

v3: Fix the coding style.

v4: Update the logic in DxeCheckBootVariable.c.
We directly return when BootOrder/Variable == NULL, in previous
versions.

.../Test/Library/TestPointCheckLib/DxeCheckBootVariable.c | 6 +++---
.../Test/Library/TestPointCheckLib/DxeCheckGcd.c | 8 +++++---
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB
ootVariable.c
b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB
ootVariable.c
index 85bd5b3d..06a40505 100644
---
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB
ootVariable.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh
+++ eckBootVariable.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>

Please add space before and after '-' like below:
2017 - 2019


SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -130,7 +130,7 @@ TestPointCheckLoadOptionVariable (
for (ListIndex = 0; ListIndex <
sizeof(mLoadOptionVariableList)/sizeof(mLoadOptionVariableList[0]);
ListIndex++) {
UnicodeSPrint (BootOrderName, sizeof(BootOrderName), L"%sOrder",
mLoadOptionVariableList[ListIndex]);
Status = GetVariable2 (BootOrderName, &gEfiGlobalVariableGuid,
(VOID **)&BootOrder, &OrderSize);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR(Status)||(BootOrder == NULL)) {

Add space before and after '||' like below:
if (EFI_ERROR(Status) || (BootOrder == NULL)) {


continue;
}
for (Index = 0; Index < OrderSize/sizeof(CHAR16); Index++) { @@ -222,7
+222,7 @@ TestPointCheckKeyOptionVariable (
for (Index = 0; ; Index++) {
UnicodeSPrint (KeyOptionName, sizeof(KeyOptionName), L"%s%04x",
mKeyOptionVariableList[ListIndex], Index);
Status = GetVariable2 (KeyOptionName, &gEfiGlobalVariableGuid,
&Variable, &Size);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR(Status)&&(Variable != NULL)) {

Add space before and after '&&' like below:
if (!EFI_ERROR(Status) && (Variable != NULL)) {


DumpKeyOption (KeyOptionName, Variable, Size);
} else {
break;
diff --git
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG
cd.c
b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG
cd.c
index 82709d44..28ca8382 100644
---
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG
cd.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh
+++ eckGcd.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -241,11 +241,13 @@ TestPointDumpGcd (
}
}
if (GcdMemoryMap != NULL) {
- *GcdIoMap = AllocateCopyPool (NumberOfDescriptors *
sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ if (GcdIoMap != NULL) {
+ *GcdIoMap = AllocateCopyPool (NumberOfDescriptors *
sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ }
*GcdIoMapNumberOfDescriptors = NumberOfDescriptors;
}
}
-
+
if (DumpPrint) {
DEBUG ((DEBUG_INFO, "==== TestPointDumpGcd - Exit\n"));
}
--
2.18.0.windows.1



[PATCH v4] MinPlatformPkg/TestPointCheckLib: Add check for pointers

Zhang, Shenglei
 

In DxeCheckBootVariable.c, add check for BootOrder and Variable
that return EFI_NOT_FOUND when they are NULL.
In DxeCheckGcd.c, add check for GcdIoMap to ensure it not NULL
when allocating memory to what it points to.

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---

v2: Update copyright

v3: Fix the coding style.

v4: Update the logic in DxeCheckBootVariable.c.
We directly return when BootOrder/Variable == NULL, in previous versions.

.../Test/Library/TestPointCheckLib/DxeCheckBootVariable.c | 6 +++---
.../Test/Library/TestPointCheckLib/DxeCheckGcd.c | 8 +++++---
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c
index 85bd5b3d..06a40505 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -130,7 +130,7 @@ TestPointCheckLoadOptionVariable (
for (ListIndex = 0; ListIndex < sizeof(mLoadOptionVariableList)/sizeof(mLoadOptionVariableList[0]); ListIndex++) {
UnicodeSPrint (BootOrderName, sizeof(BootOrderName), L"%sOrder", mLoadOptionVariableList[ListIndex]);
Status = GetVariable2 (BootOrderName, &gEfiGlobalVariableGuid, (VOID **)&BootOrder, &OrderSize);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR(Status)||(BootOrder == NULL)) {
continue;
}
for (Index = 0; Index < OrderSize/sizeof(CHAR16); Index++) {
@@ -222,7 +222,7 @@ TestPointCheckKeyOptionVariable (
for (Index = 0; ; Index++) {
UnicodeSPrint (KeyOptionName, sizeof(KeyOptionName), L"%s%04x", mKeyOptionVariableList[ListIndex], Index);
Status = GetVariable2 (KeyOptionName, &gEfiGlobalVariableGuid, &Variable, &Size);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR(Status)&&(Variable != NULL)) {
DumpKeyOption (KeyOptionName, Variable, Size);
} else {
break;
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c
index 82709d44..28ca8382 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -241,11 +241,13 @@ TestPointDumpGcd (
}
}
if (GcdMemoryMap != NULL) {
- *GcdIoMap = AllocateCopyPool (NumberOfDescriptors * sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ if (GcdIoMap != NULL) {
+ *GcdIoMap = AllocateCopyPool (NumberOfDescriptors * sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ }
*GcdIoMapNumberOfDescriptors = NumberOfDescriptors;
}
}
-
+
if (DumpPrint) {
DEBUG ((DEBUG_INFO, "==== TestPointDumpGcd - Exit\n"));
}
--
2.18.0.windows.1


Re: [PATCH v3] MinPlatformPkg/TestPointCheckLib: Add check for pointers

Chiu, Chasel
 

Feedbacks in below inline.

Thanks!
Chasel

-----Original Message-----
From: Zhang, Shenglei <shenglei.zhang@intel.com>
Sent: Wednesday, September 18, 2019 9:54 AM
To: devel@edk2.groups.io
Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
<chasel.chiu@intel.com>; Desimone, Nathaniel L
<nathaniel.l.desimone@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [PATCH v3] MinPlatformPkg/TestPointCheckLib: Add check for
pointers

In DxeCheckBootVariable.c, add check for BootOrder and Variable that
return EFI_NOT_FOUND when they are NULL.
In DxeCheckGcd.c, add check for GcdIoMap to ensure it not NULL when
allocating memory to what it points to.

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---

v2: Update copyright

v3: Fix the coding style.

.../Test/Library/TestPointCheckLib/DxeCheckBootVariable.c | 8 +++++++-
.../Test/Library/TestPointCheckLib/DxeCheckGcd.c | 8 +++++---
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB
ootVariable.c
b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB
ootVariable.c
index 85bd5b3d..f658beb7 100644
---
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB
ootVariable.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh
+++ eckBootVariable.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -130,6 +130,9 @@ TestPointCheckLoadOptionVariable (
for (ListIndex = 0; ListIndex <
sizeof(mLoadOptionVariableList)/sizeof(mLoadOptionVariableList[0]);
ListIndex++) {
UnicodeSPrint (BootOrderName, sizeof(BootOrderName), L"%sOrder",
mLoadOptionVariableList[ListIndex]);
Status = GetVariable2 (BootOrderName, &gEfiGlobalVariableGuid,
(VOID **)&BootOrder, &OrderSize);
+ if(BootOrder == NULL) {
+ return EFI_NOT_FOUND;
+ }
I think we should continue the loop when BootOrder == NULL, we should not just return.
Suggest to combine the condition check in following line:

If (EFI_ERROR(Status) || (BootOrder == NULL)) {
continue;
}






if (EFI_ERROR(Status)) {
continue;
}
@@ -222,6 +225,9 @@ TestPointCheckKeyOptionVariable (
for (Index = 0; ; Index++) {
UnicodeSPrint (KeyOptionName, sizeof(KeyOptionName), L"%s%04x",
mKeyOptionVariableList[ListIndex], Index);
Status = GetVariable2 (KeyOptionName, &gEfiGlobalVariableGuid,
&Variable, &Size);
+ if(Variable == NULL) {
+ return EFI_NOT_FOUND;
+ }

Same here, I think we should not return directly.
Combine the check in following line:

If (!EFI_ERROR(Status) && (Variable != NULL)) {
DumpKeyOption (...);
else {
...





if (!EFI_ERROR(Status)) {
DumpKeyOption (KeyOptionName, Variable, Size);
} else {
diff --git
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG
cd.c
b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG
cd.c
index 82709d44..28ca8382 100644
---
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG
cd.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh
+++ eckGcd.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -241,11 +241,13 @@ TestPointDumpGcd (
}
}
if (GcdMemoryMap != NULL) {
- *GcdIoMap = AllocateCopyPool (NumberOfDescriptors *
sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ if (GcdIoMap != NULL) {
+ *GcdIoMap = AllocateCopyPool (NumberOfDescriptors *
sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ }
*GcdIoMapNumberOfDescriptors = NumberOfDescriptors;
}
}
-
+
if (DumpPrint) {
DEBUG ((DEBUG_INFO, "==== TestPointDumpGcd - Exit\n"));
}
--
2.18.0.windows.1


[PATCH V3 3/3] MdeModulePkg/BM_UI: Add the new terminal types to related menu

Gao, Zhichao
 

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

Add the new introduced terminal types to related setup menu to change
the terminal type from setup. Most platforms would have its own
configure setup menu and they need to change it to support these.
The new introduced terminal types are Linux, XtermR6, VT400 and SCO.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
---
.../BootMaintenanceManager.h | 12 ++++---
.../BootMaintenanceManagerStrings.uni | 10 +++++-
.../ConsoleOption.c | 35 ++++++-------------
.../BootMaintenanceManagerUiLib/Data.c | 16 ++++++---
4 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
index ea3cdce794..67847d8bf3 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
@@ -1,7 +1,7 @@
/** @file
Header file for boot maintenance module.

-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -92,7 +92,11 @@ typedef enum _TYPE_OF_TERMINAL {
TerminalTypeVt100,
TerminalTypeVt100Plus,
TerminalTypeVtUtf8,
- TerminalTypeTtyTerm
+ TerminalTypeTtyTerm,
+ TerminalTypeLinux,
+ TerminalTypeXtermR6,
+ TerminalTypeVt400,
+ TerminalTypeSCO
} TYPE_OF_TERMINAL;

//
@@ -1301,12 +1305,12 @@ extern BM_MENU_OPTION ConsoleOutMenu;
extern BM_MENU_OPTION ConsoleErrMenu;
extern BM_MENU_OPTION DriverMenu;
extern BM_MENU_OPTION TerminalMenu;
-extern UINT16 TerminalType[5];
+extern UINT16 TerminalType[9];
extern COM_ATTR BaudRateList[19];
extern COM_ATTR DataBitsList[4];
extern COM_ATTR ParityList[5];
extern COM_ATTR StopBitsList[3];
-extern EFI_GUID TerminalTypeGuid[5];
+extern EFI_GUID TerminalTypeGuid[9];
extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath[];
extern UINT16 mFlowControlType[2];
extern UINT32 mFlowControlValue[2];
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerStrings.uni b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerStrings.uni
index 2e67d27bd0..3d47473e6c 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerStrings.uni
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerStrings.uni
@@ -1,7 +1,7 @@
///** @file
// String definitions for Boot Maintenance Utility.
//
-// Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
//**/
@@ -233,6 +233,14 @@
#language fr-FR "VT_UTF8"
#string STR_COM_TYPE_4 #language en-US "TTY_TERM"
#language fr-FR "TTY_TERM"
+#string STR_COM_TYPE_5 #language en-US "LINUX"
+ #language fr-FR "LINUX"
+#string STR_COM_TYPE_6 #language en-US "XTERM_R6"
+ #language fr-FR "XTERM_R6"
+#string STR_COM_TYPE_7 #language en-US "VT_400"
+ #language fr-FR "VT_400"
+#string STR_COM_TYPE_8 #language en-US "SCO"
+ #language fr-FR "SCO"
#string STR_RESET #language en-US "Reset System"
#language fr-FR "Reset System"
#string STR_FORM_GOTO_MAIN #language en-US "Go Back To Main Page"
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
index 7a53b58771..b0641c5ee9 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
@@ -897,6 +897,7 @@ IsTerminalDevicePath (
VENDOR_DEVICE_PATH *Vendor;
UART_DEVICE_PATH *Uart;
ACPI_HID_DEVICE_PATH *Acpi;
+ UINTN Index;

IsTerminal = FALSE;

@@ -929,37 +930,21 @@ IsTerminalDevicePath (
}

//
- // There are four kinds of Terminal types
+ // There are 9 kinds of Terminal types
// check to see whether this devicepath
// is one of that type
//
- if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[0])) {
- *Termi = TerminalTypePcAnsi;
- IsTerminal = TRUE;
- } else {
- if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[1])) {
- *Termi = TerminalTypeVt100;
- IsTerminal = TRUE;
- } else {
- if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[2])) {
- *Termi = TerminalTypeVt100Plus;
- IsTerminal = TRUE;
- } else {
- if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[3])) {
- *Termi = TerminalTypeVtUtf8;
- IsTerminal = TRUE;
- } else {
- if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[4])) {
- *Termi = TerminalTypeTtyTerm;
- IsTerminal = TRUE;
- } else {
- IsTerminal = FALSE;
- }
- }
- }
+ for (Index = 0; Index < ARRAY_SIZE (TerminalTypeGuid); Index++) {
+ if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[Index])) {
+ *Termi = Index;
+ IsTerminal = TRUE;
}
}

+ if (Index == ARRAY_SIZE (TerminalTypeGuid)) {
+ IsTerminal = FALSE;
+ }
+
if (!IsTerminal) {
return FALSE;
}
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c
index b9d86b09d8..21c4ef3d55 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c
@@ -1,7 +1,7 @@
/** @file
Define some data used for Boot Maint

-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -16,12 +16,16 @@ EFI_IFR_GUID_LABEL *mEndLabel = NULL;
///
/// Terminal type string token storage
///
-UINT16 TerminalType[] = {
+UINT16 TerminalType[9] = {
STRING_TOKEN(STR_COM_TYPE_0),
STRING_TOKEN(STR_COM_TYPE_1),
STRING_TOKEN(STR_COM_TYPE_2),
STRING_TOKEN(STR_COM_TYPE_3),
STRING_TOKEN(STR_COM_TYPE_4),
+ STRING_TOKEN(STR_COM_TYPE_5),
+ STRING_TOKEN(STR_COM_TYPE_6),
+ STRING_TOKEN(STR_COM_TYPE_7),
+ STRING_TOKEN(STR_COM_TYPE_8),
};

///
@@ -248,10 +252,14 @@ COM_ATTR StopBitsList[3] = {
///
/// Guid for messaging path, used in Serial port setting.
///
-EFI_GUID TerminalTypeGuid[] = {
+EFI_GUID TerminalTypeGuid[9] = {
DEVICE_PATH_MESSAGING_PC_ANSI,
DEVICE_PATH_MESSAGING_VT_100,
DEVICE_PATH_MESSAGING_VT_100_PLUS,
DEVICE_PATH_MESSAGING_VT_UTF8,
- EFI_TTY_TERM_GUID
+ EFI_TTY_TERM_GUID,
+ EDKII_LINUX_TERM_GUID,
+ EDKII_XTERM_R6_GUID,
+ EDKII_VT400_GUID,
+ EDKII_SCO_TERM_GUID
};
--
2.21.0.windows.1


[PATCH V3 2/3] MdeModulePkg/TerminalDxe: Extend the terminal console support types

Gao, Zhichao
 

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

Extend the support types of terminal console driver. New added types
are Linux, XtermR6, VT400 and SCO.

Refer to
https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter4.html#config-funkeys

Add the missing VT100+ function keys map.

Add F1-F12 function keys map for Linux, XtermR6, VT400 and SCO.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
---
.../Universal/Console/TerminalDxe/Terminal.c | 17 +-
.../Universal/Console/TerminalDxe/Terminal.h | 37 ++-
.../Console/TerminalDxe/TerminalConIn.c | 282 ++++++++++++++++--
.../Console/TerminalDxe/TerminalConOut.c | 4 +
.../Console/TerminalDxe/TerminalDxe.inf | 6 +-
5 files changed, 320 insertions(+), 26 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index c76b2c5100..fd26e4dafe 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -2,7 +2,7 @@
Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and
Simple Text Output Protocol upon Serial IO Protocol.

-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -28,7 +28,11 @@ EFI_GUID *mTerminalType[] = {
&gEfiVT100Guid,
&gEfiVT100PlusGuid,
&gEfiVTUTF8Guid,
- &gEfiTtyTermGuid
+ &gEfiTtyTermGuid,
+ &gEdkiiLinuxTermGuid,
+ &gEdkiiXtermR6Guid,
+ &gEdkiiVT400Guid,
+ &gEdkiiSCOTermGuid
};


@@ -37,7 +41,11 @@ CHAR16 *mSerialConsoleNames[] = {
L"VT-100 Serial Console",
L"VT-100+ Serial Console",
L"VT-UTF8 Serial Console",
- L"Tty Terminal Serial Console"
+ L"Tty Terminal Serial Console",
+ L"Linux Terminal Serial Console",
+ L"Xterm R6 Serial Console",
+ L"VT-400 Serial Console",
+ L"SCO Terminal Serial Console"
};

TERMINAL_DEV mTerminalDevTemplate = {
@@ -187,7 +195,8 @@ TerminalDriverBindingSupported (

}
//
- // only supports PC ANSI, VT100, VT100+, VT-UTF8, and TtyTerm terminal types
+ // only supports PC ANSI, VT100, VT100+, VT-UTF8, TtyTerm
+ // Linux, XtermR6, VT400 and SCO terminal types
//
if (TerminalTypeFromGuid (&Node->Guid) == ARRAY_SIZE (mTerminalType)) {
return EFI_UNSUPPORTED;
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index b2f0901fc1..d683aa792f 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -1,7 +1,7 @@
/** @file
Header file for Terminal driver.

-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -81,7 +81,11 @@ typedef enum {
TerminalTypeVt100,
TerminalTypeVt100Plus,
TerminalTypeVtUtf8,
- TerminalTypeTtyTerm
+ TerminalTypeTtyTerm,
+ TerminalTypeLinux,
+ TerminalTypeXtermR6,
+ TerminalTypeVt400,
+ TerminalTypeSCO
} TERMINAL_TYPE;

typedef struct {
@@ -126,7 +130,9 @@ typedef struct {
#define INPUT_STATE_LEFTOPENBRACKET 0x04
#define INPUT_STATE_O 0x08
#define INPUT_STATE_2 0x10
-#define INPUT_STATE_LEFTOPENBRACKET_2 0x20
+#define INPUT_STATE_LEFTOPENBRACKET_TTY 0x20
+#define INPUT_STATE_1 0x40
+#define INPUT_STATE_LEFTOPENBRACKET_2ND 0x80

#define RESET_STATE_DEFAULT 0x00
#define RESET_STATE_ESC_R 0x01
@@ -848,7 +854,8 @@ TerminalRemoveConsoleDevVariable (
/**
Build termial device path according to terminal type.

- @param TerminalType The terminal type is PC ANSI, VT100, VT100+ or VT-UTF8.
+ @param TerminalType The terminal type is PC ANSI, VT100, VT100+, VT-UTF8, TTY-Term,
+ Linux, XtermR6, VT400 and SCO.
@param ParentDevicePath Parent device path.
@param TerminalDevicePath Returned terminal device path, if building successfully.

@@ -1209,6 +1216,28 @@ AnsiRawDataToUnicode (
| F12 | 0x16 | | ESC @ | |
+=========+======+===========+==========+==========+

+Putty function key map:
+ +=========+======+===========+=============+=============+=============+=========+
+ | | EFI | | | | | |
+ | | Scan | | | Normal | | |
+ | KEY | Code | VT100+ | Xterm R6 | VT400 | Linux | SCO |
+ +=========+======+===========+=============+=============+=============+=========+
+ | F1 | 0x0B | ESC O P | ESC O P | ESC [ 1 1 ~ | ESC [ [ A | ESC [ M |
+ | F2 | 0x0C | ESC O Q | ESC O Q | ESC [ 1 2 ~ | ESC [ [ B | ESC [ N |
+ | F3 | 0x0D | ESC O R | ESC O R | ESC [ 1 3 ~ | ESC [ [ C | ESC [ O |
+ | F4 | 0x0E | ESC O S | ESC O S | ESC [ 1 4 ~ | ESC [ [ D | ESC [ P |
+ | F5 | 0x0F | ESC O T | ESC [ 1 5 ~ | ESC [ 1 5 ~ | ESC [ [ E | ESC [ Q |
+ | F6 | 0x10 | ESC O U | ESC [ 1 7 ~ | ESC [ 1 7 ~ | ESC [ 1 7 ~ | ESC [ R |
+ | F7 | 0x11 | ESC O V | ESC [ 1 8 ~ | ESC [ 1 8 ~ | ESC [ 1 8 ~ | ESC [ S |
+ | F8 | 0x12 | ESC O W | ESC [ 1 9 ~ | ESC [ 1 9 ~ | ESC [ 1 9 ~ | ESC [ T |
+ | F9 | 0x13 | ESC O X | ESC [ 2 0 ~ | ESC [ 2 0 ~ | ESC [ 2 0 ~ | ESC [ U |
+ | F10 | 0x14 | ESC O Y | ESC [ 2 1 ~ | ESC [ 2 1 ~ | ESC [ 2 1 ~ | ESC [ V |
+ | Escape | 0x17 | ESC | ESC | ESC | ESC | ESC |
+ | F11 | 0x15 | ESC O Z | ESC [ 2 3 ~ | ESC [ 2 3 ~ | ESC [ 2 3 ~ | ESC [ W |
+ | F12 | 0x16 | ESC O [ | ESC [ 2 4 ~ | ESC [ 2 4 ~ | ESC [ 2 4 ~ | ESC [ X |
+ +=========+======+===========+=============+=============+=============+=========+
+
+
Special Mappings
================
ESC R ESC r ESC R = Reset System
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 4ede416774..ac31f27984 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -2,7 +2,7 @@
Implementation for EFI_SIMPLE_TEXT_INPUT_PROTOCOL protocol.

(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -453,6 +453,10 @@ TranslateRawDataToEfiKey (
case TerminalTypeVt100:
case TerminalTypeVt100Plus:
case TerminalTypeTtyTerm:
+ case TerminalTypeLinux:
+ case TerminalTypeXtermR6:
+ case TerminalTypeVt400:
+ case TerminalTypeSCO:
AnsiRawDataToUnicode (TerminalDevice);
UnicodeToEfiKey (TerminalDevice);
break;
@@ -1319,6 +1323,27 @@ UnicodeToEfiKeyFlushState (
| F12 | 0x16 | | ESC @ | |
+=========+======+===========+==========+==========+

+Putty function key map:
+ +=========+======+===========+=============+=============+=============+=========+
+ | | EFI | | | | | |
+ | | Scan | | | Normal | | |
+ | KEY | Code | VT100+ | Xterm R6 | VT400 | Linux | SCO |
+ +=========+======+===========+=============+=============+=============+=========+
+ | F1 | 0x0B | ESC O P | ESC O P | ESC [ 1 1 ~ | ESC [ [ A | ESC [ M |
+ | F2 | 0x0C | ESC O Q | ESC O Q | ESC [ 1 2 ~ | ESC [ [ B | ESC [ N |
+ | F3 | 0x0D | ESC O R | ESC O R | ESC [ 1 3 ~ | ESC [ [ C | ESC [ O |
+ | F4 | 0x0E | ESC O S | ESC O S | ESC [ 1 4 ~ | ESC [ [ D | ESC [ P |
+ | F5 | 0x0F | ESC O T | ESC [ 1 5 ~ | ESC [ 1 5 ~ | ESC [ [ E | ESC [ Q |
+ | F6 | 0x10 | ESC O U | ESC [ 1 7 ~ | ESC [ 1 7 ~ | ESC [ 1 7 ~ | ESC [ R |
+ | F7 | 0x11 | ESC O V | ESC [ 1 8 ~ | ESC [ 1 8 ~ | ESC [ 1 8 ~ | ESC [ S |
+ | F8 | 0x12 | ESC O W | ESC [ 1 9 ~ | ESC [ 1 9 ~ | ESC [ 1 9 ~ | ESC [ T |
+ | F9 | 0x13 | ESC O X | ESC [ 2 0 ~ | ESC [ 2 0 ~ | ESC [ 2 0 ~ | ESC [ U |
+ | F10 | 0x14 | ESC O Y | ESC [ 2 1 ~ | ESC [ 2 1 ~ | ESC [ 2 1 ~ | ESC [ V |
+ | Escape | 0x17 | ESC | ESC | ESC | ESC | ESC |
+ | F11 | 0x15 | ESC O Z | ESC [ 2 3 ~ | ESC [ 2 3 ~ | ESC [ 2 3 ~ | ESC [ W |
+ | F12 | 0x16 | ESC O [ | ESC [ 2 4 ~ | ESC [ 2 4 ~ | ESC [ 2 4 ~ | ESC [ X |
+ +=========+======+===========+=============+=============+=============+=========+
+
Special Mappings
================
ESC R ESC r ESC R = Reset System
@@ -1378,7 +1403,9 @@ UnicodeToEfiKey (
}

if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == TerminalTypeVt100 ||
- TerminalDevice->TerminalType == TerminalTypeTtyTerm)) {
+ TerminalDevice->TerminalType == TerminalTypeTtyTerm ||
+ TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt100Plus)) {
TerminalDevice->InputState |= INPUT_STATE_O;
TerminalDevice->ResetState = RESET_STATE_DEFAULT;
continue;
@@ -1548,6 +1575,60 @@ UnicodeToEfiKey (
Key.ScanCode = SCAN_END;
break;
}
+ } else if (TerminalDevice->TerminalType == TerminalTypeVt100Plus) {
+ switch (UnicodeChar) {
+ case 'P':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case 'Q':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case 'R':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case 'S':
+ Key.ScanCode = SCAN_F4;
+ break;
+ case 'T':
+ Key.ScanCode = SCAN_F5;
+ break;
+ case 'U':
+ Key.ScanCode = SCAN_F6;
+ break;
+ case 'V':
+ Key.ScanCode = SCAN_F7;
+ break;
+ case 'W':
+ Key.ScanCode = SCAN_F8;
+ break;
+ case 'X':
+ Key.ScanCode = SCAN_F9;
+ break;
+ case 'Y':
+ Key.ScanCode = SCAN_F10;
+ break;
+ case 'Z':
+ Key.ScanCode = SCAN_F11;
+ break;
+ case '[':
+ Key.ScanCode = SCAN_F12;
+ break;
+ }
+ } else if (TerminalDevice->TerminalType == TerminalTypeXtermR6) {
+ switch (UnicodeChar) {
+ case 'P':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case 'Q':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case 'R':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case 'S':
+ Key.ScanCode = SCAN_F4;
+ break;
+ }
}

if (Key.ScanCode != SCAN_NULL) {
@@ -1564,15 +1645,34 @@ UnicodeToEfiKey (

case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET:

+ if (UnicodeChar == '1' && (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt400 ||
+ TerminalDevice->TerminalType == TerminalTypeLinux)) {
+ TerminalDevice->InputState |= INPUT_STATE_1;
+ continue;
+ }
+
+ if (UnicodeChar == '2' && (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt400 ||
+ TerminalDevice->TerminalType == TerminalTypeLinux)) {
+ TerminalDevice->InputState |= INPUT_STATE_2;
+ continue;
+ }
+
+ if (UnicodeChar == LEFTOPENBRACKET && TerminalDevice->TerminalType == TerminalTypeLinux) {
+ TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_2ND;
+ continue;
+ }
+
TerminalDevice->ResetState = RESET_STATE_DEFAULT;

Key.ScanCode = SCAN_NULL;

if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
TerminalDevice->TerminalType == TerminalTypeVt100 ||
- TerminalDevice->TerminalType == TerminalTypeVt100Plus ||
- TerminalDevice->TerminalType == TerminalTypeVtUtf8 ||
- TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
+ TerminalDevice->TerminalType == TerminalTypeVtUtf8 ||
+ TerminalDevice->TerminalType == TerminalTypeTtyTerm ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
switch (UnicodeChar) {
case 'A':
Key.ScanCode = SCAN_UP;
@@ -1614,12 +1714,15 @@ UnicodeToEfiKey (
case 'X':
if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
Key.ScanCode = SCAN_DELETE;
+ } else if (TerminalDevice->TerminalType == TerminalTypeSCO) {
+ Key.ScanCode = SCAN_F12;
}
break;
case 'P':
if (TerminalDevice->TerminalType == TerminalTypeVt100) {
Key.ScanCode = SCAN_DELETE;
- } else if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ } else if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F4;
}
break;
@@ -1629,7 +1732,8 @@ UnicodeToEfiKey (
}
break;
case 'V':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F10;
}
break;
@@ -1644,7 +1748,8 @@ UnicodeToEfiKey (
}
break;
case 'U':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F9;
}
break;
@@ -1654,40 +1759,52 @@ UnicodeToEfiKey (
}
break;
case 'M':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F1;
}
break;
case 'N':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F2;
}
break;
case 'O':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F3;
}
break;
case 'Q':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F5;
}
break;
case 'R':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F6;
}
break;
case 'S':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F7;
}
break;
case 'T':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F8;
}
break;
+ case 'W':
+ if (TerminalDevice->TerminalType == TerminalTypeSCO) {
+ Key.ScanCode = SCAN_F11;
+ }
+ break;
default :
break;
}
@@ -1704,10 +1821,105 @@ UnicodeToEfiKey (
UnicodeChar <= '9') {
TerminalDevice->TtyEscapeStr[0] = UnicodeChar;
TerminalDevice->TtyEscapeIndex = 1;
- TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_2;
+ TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_TTY;
+ continue;
+ }
+
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
+ }
+
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+
+ break;
+
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_1:
+
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;
+
+ Key.ScanCode = SCAN_NULL;
+
+ if (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt400 ||
+ TerminalDevice->TerminalType == TerminalTypeLinux) {
+ switch (UnicodeChar) {
+ case '1':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F1;
+ }
+ break;
+ case '2':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F2;
+ }
+ break;
+ case '3':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F3;
+ }
+ break;
+ case '4':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F4;
+ }
+ break;
+ case '5':
+ if (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F5;
+ }
+ break;
+ case '7':
+ Key.ScanCode = SCAN_F6;
+ break;
+ case '8':
+ Key.ScanCode = SCAN_F7;
+ break;
+ case '9':
+ Key.ScanCode = SCAN_F8;
+ break;
+ }
+ }
+
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
continue;
}

+ UnicodeToEfiKeyFlushState (TerminalDevice);
+
+ break;
+
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_2:
+
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ Key.ScanCode = SCAN_NULL;
+ if (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt400 ||
+ TerminalDevice->TerminalType == TerminalTypeLinux) {
+ switch (UnicodeChar) {
+ case '0':
+ Key.ScanCode = SCAN_F9;
+ break;
+ case '1':
+ Key.ScanCode = SCAN_F10;
+ break;
+ case '3':
+ Key.ScanCode = SCAN_F11;
+ break;
+ case '4':
+ Key.ScanCode = SCAN_F12;
+ break;
+ }
+ }
+
if (Key.ScanCode != SCAN_NULL) {
Key.UnicodeChar = 0;
EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
@@ -1720,8 +1932,44 @@ UnicodeToEfiKey (

break;

+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_2ND:
+
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ Key.ScanCode = SCAN_NULL;
+
+ if (TerminalDevice->TerminalType == TerminalTypeLinux) {
+ switch (UnicodeChar) {
+ case 'A':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case 'B':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case 'C':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case 'D':
+ Key.ScanCode = SCAN_F4;
+ break;
+ case 'E':
+ Key.ScanCode = SCAN_F5;
+ break;
+ }
+ }
+
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
+ }
+
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+
+ break;

- case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_2:
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_TTY:
/*
* Here we handle the VT220 escape codes that we accept. This
* state is only used by the TTY terminal type.
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
index 7ef655cca5..aae470e956 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
@@ -222,6 +222,10 @@ TerminalConOutOutputString (
case TerminalTypeVt100:
case TerminalTypeVt100Plus:
case TerminalTypeTtyTerm:
+ case TerminalTypeLinux:
+ case TerminalTypeXtermR6:
+ case TerminalTypeVt400:
+ case TerminalTypeSCO:

if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) {
//
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
index 24e164ef4d..b2a8aeba85 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
@@ -5,7 +5,7 @@
# protocols based on Serial I/O protocol for serial devices including hotplug serial
# devices.
#
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
@@ -69,6 +69,10 @@
gEfiVT100PlusGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
gEfiPcAnsiGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
gEfiTtyTermGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
+ gEdkiiLinuxTermGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
+ gEdkiiXtermR6Guid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
+ gEdkiiVT400Guid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
+ gEdkiiSCOTermGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID

[Protocols]
--
2.21.0.windows.1


[PATCH V3 1/3] MdeModulePkg: Extend the support keyboard type of Terminal console

Gao, Zhichao
 

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

A common terminal console software Putty support various types of
keyboard type, such as normal mode, Linux mode, Xterm R6, Vt400,
VT100+ and SCO. Refer to the link:
https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter4.html#config-funkeys

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
---
MdeModulePkg/Include/Guid/TtyTerm.h | 13 +++++++++++++
MdeModulePkg/MdeModulePkg.dec | 4 ++++
2 files changed, 17 insertions(+)

diff --git a/MdeModulePkg/Include/Guid/TtyTerm.h b/MdeModulePkg/Include/Guid/TtyTerm.h
index 8333344b9d..471a651d4d 100644
--- a/MdeModulePkg/Include/Guid/TtyTerm.h
+++ b/MdeModulePkg/Include/Guid/TtyTerm.h
@@ -4,6 +4,7 @@ provide support for modern *nix terminals.


Copyright (c) 2015 Linaro Ltd.
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -14,6 +15,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_TTY_TERM_GUID \
{0x7d916d80, 0x5bb1, 0x458c, {0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94 } }

+#define EDKII_LINUX_TERM_GUID \
+ {0xe4364a7f, 0xf825, 0x430e, {0x9d, 0x3a, 0x9c, 0x9b, 0xe6, 0x81, 0x7c, 0xa5 } }
+
+#define EDKII_XTERM_R6_GUID \
+ {0xfbfca56b, 0xbb36, 0x4b78, {0xaa, 0xab, 0xbe, 0x1b, 0x97, 0xec, 0x7c, 0xcb } }
+
+#define EDKII_VT400_GUID \
+ {0x8e46dddd, 0x3d49, 0x4a9d, {0xb8, 0x75, 0x3c, 0x08, 0x6f, 0x6a, 0xa2, 0xbd } }
+
+#define EDKII_SCO_TERM_GUID \
+ {0xfc7dd6e0, 0x813c, 0x434d, {0xb4, 0xda, 0x3b, 0xd6, 0x49, 0xe9, 0xe1, 0x5a } }
+
extern EFI_GUID gEfiTtyTermGuid;

#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 17beb45235..7f72c122fc 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -342,6 +342,10 @@

## Include/Guid/TtyTerm.h
gEfiTtyTermGuid = { 0x7d916d80, 0x5bb1, 0x458c, {0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94 }}
+ gEdkiiLinuxTermGuid = { 0xe4364a7f, 0xf825, 0x430e, {0x9d, 0x3a, 0x9c, 0x9b, 0xe6, 0x81, 0x7c, 0xa5 }}
+ gEdkiiXtermR6Guid = { 0xfbfca56b, 0xbb36, 0x4b78, {0xaa, 0xab, 0xbe, 0x1b, 0x97, 0xec, 0x7c, 0xcb }}
+ gEdkiiVT400Guid = { 0x8e46dddd, 0x3d49, 0x4a9d, {0xb8, 0x75, 0x3c, 0x08, 0x6f, 0x6a, 0xa2, 0xbd }}
+ gEdkiiSCOTermGuid = { 0xfc7dd6e0, 0x813c, 0x434d, {0xb4, 0xda, 0x3b, 0xd6, 0x49, 0xe9, 0xe1, 0x5a }}

## Include/Guid/HiiBootMaintenanceFormset.h
gEfiIfrBootMaintenanceGuid = { 0xb2dedc91, 0xd59f, 0x48d2, { 0x89, 0x8a, 0x12, 0x49, 0xc, 0x74, 0xa4, 0xe0 }}
--
2.21.0.windows.1


[PATCH V3 0/3] MdeModulePkg/TerminalConsole: Extend the support terminal types

Gao, Zhichao
 

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

Putty is a very popular terminal tool in windows. So add the whole support
terminal keyboard type for it. The new introduced type is Linux, XtermR6,
VT400 and SCO. And enhance the support for VT100+.
This patch set only add the support of function key. Refer to the link:
https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter4.html#config-funkeys

V2:
Fix typo.
Merge the type guid defination into TtyTerm.h.

V3:
Fix incorrect removal of Ttyterm parse.
Change the guid name of terminal type linux and SCO to clear ones:
LinuxTerm and SCOTerm.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-of-by: Zhichao Gao <zhichao.gao@intel.com>

Zhichao Gao (3):
MdeModulePkg: Extend the support keyboard type of Terminal console
MdeModulePkg/TerminalDxe: Extend the terminal console support types
MdeModulePkg/BM_UI: Add the new terminal types to related menu

MdeModulePkg/Include/Guid/TtyTerm.h | 13 +
.../BootMaintenanceManager.h | 12 +-
.../BootMaintenanceManagerStrings.uni | 10 +-
.../ConsoleOption.c | 35 +--
.../BootMaintenanceManagerUiLib/Data.c | 16 +-
MdeModulePkg/MdeModulePkg.dec | 4 +
.../Universal/Console/TerminalDxe/Terminal.c | 17 +-
.../Universal/Console/TerminalDxe/Terminal.h | 37 ++-
.../Console/TerminalDxe/TerminalConIn.c | 282 ++++++++++++++++--
.../Console/TerminalDxe/TerminalConOut.c | 4 +
.../Console/TerminalDxe/TerminalDxe.inf | 6 +-
11 files changed, 376 insertions(+), 60 deletions(-)

--
2.21.0.windows.1


Re: [patch v2 3/5] MdeModulePkg/UefiBootManager: Unload image on EFI_SECURITY_VIOLATION

Gao, Zhichao
 

Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>

Thanks,
Zhichao

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Dandan Bi
Sent: Wednesday, September 18, 2019 11:06 AM
To: devel@edk2.groups.io
Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
Ni, Ray <ray.ni@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Gao,
Liming <liming.gao@intel.com>; Laszlo Ersek <lersek@redhat.com>
Subject: [edk2-devel] [patch v2 3/5] MdeModulePkg/UefiBootManager:
Unload image on EFI_SECURITY_VIOLATION

For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval, the
Image was loaded and an ImageHandle was created with a valid
EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
This follows UEFI Spec.

But if the caller of LoadImage() doesn't have the option to defer the
execution of an image, we can not treat EFI_SECURITY_VIOLATION like any
other LoadImage() error, we should unload image for the
EFI_SECURITY_VIOLATION to avoid resource leak.

This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly for
the callers in UefiBootManagerLib which don't have the policy to defer the
execution of the image.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 9 +++++++++
.../Library/UefiBootManagerLib/BmLoadOption.c | 11 ++++++++++-
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 11
++++++++++-
3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 952033fc82..760d7647b8 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1859,10 +1859,19 @@ EfiBootManagerBoot (
if (FilePath != NULL) {
FreePool (FilePath);
}

if (EFI_ERROR (Status)) {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an
ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not
be started right now.
+ // If the caller doesn't have the option to defer the execution of an
image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
//
// Report Status Code with the failure status to indicate that the failure to
load boot option
//
BmReportLoadFailure
(EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Status);
BootOption->Status = Status;
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
index 07592f8ebd..af47b787d1 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
@@ -1,9 +1,9 @@
/** @file
Load option library functions which relate with creating and processing load
options.

-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

@@ -1409,10 +1409,19 @@ EfiBootManagerProcessLoadOption (
FileSize,
&ImageHandle
);
FreePool (FileBuffer);

+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an
ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be
started right now.
+ // If the caller doesn't have the option to defer the execution of an image,
we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
if (!EFI_ERROR (Status)) {
Status = gBS->HandleProtocol (ImageHandle,
&gEfiLoadedImageProtocolGuid, (VOID **)&ImageInfo);
ASSERT_EFI_ERROR (Status);

ImageInfo->LoadOptionsSize = LoadOption->OptionalDataSize; diff --git
a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index 6b8fb4d924..833e38c6fe 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
@@ -1,9 +1,9 @@
/** @file
Misc library functions.

-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

@@ -491,10 +491,19 @@ EfiBootManagerDispatchDeferredImages (
ImageDevicePath,
NULL,
0,
&ImageHandle
);
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an
ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not
be started right now.
+ // If the caller doesn't have the option to defer the execution of an
image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
if (!EFI_ERROR (Status)) {
LoadCount++;
//
// Before calling the image, enable the Watchdog Timer for
// a 5 Minute period
--
2.18.0.windows.1



Re: [PATCH 17/35] MdePkg/DxeServicesLib: remove bogus cast

Liming Gao
 

Reviewed-by: Liming Gao <liming.gao@intel.com>

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Laszlo Ersek
Sent: Wednesday, September 18, 2019 3:49 AM
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: Gao, Liming <liming.gao@intel.com>; Kinney, Michael D
<michael.d.kinney@intel.com>
Subject: [edk2-devel] [PATCH 17/35] MdePkg/DxeServicesLib: remove bogus
cast

The HandleProtocol() boot service takes an EFI_HANDLE, not an
(EFI_HANDLE*). Remove the bogus cast in the
InternalImageHandleToFvHandle() function.

This is a semantic cleanup; there is no change in behavior.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
lightly tested, most probably: it's practically impossible to build a
platform without consuming DxeServicesLib

MdePkg/Library/DxeServicesLib/DxeServicesLib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Library/DxeServicesLib/DxeServicesLib.c
b/MdePkg/Library/DxeServicesLib/DxeServicesLib.c
index c416b2dd8c65..0735b2f80400 100644
--- a/MdePkg/Library/DxeServicesLib/DxeServicesLib.c
+++ b/MdePkg/Library/DxeServicesLib/DxeServicesLib.c
@@ -49,7 +49,7 @@ InternalImageHandleToFvHandle (
ASSERT (ImageHandle != NULL);

Status = gBS->HandleProtocol (
- (EFI_HANDLE *) ImageHandle,
+ ImageHandle,
&gEfiLoadedImageProtocolGuid,
(VOID **) &LoadedImage
);
--
2.19.1.3.g30247aa5d201



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#47404): https://edk2.groups.io/g/devel/message/47404
Mute This Topic: https://groups.io/mt/34180218/1759384
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [liming.gao@intel.com]
-=-=-=-=-=-=