Date   

Event: TianoCore Community Meeting - APAC/NAMO - 08/12/2021 #cal-reminder

devel@edk2.groups.io Calendar <noreply@...>
 

Reminder: TianoCore Community Meeting - APAC/NAMO

When:
08/12/2021
7:30pm to 8:30pm
(UTC-07:00) America/Los Angeles

Where:
https://teams.microsoft.com/l/meetup-join/19%3ameeting_ZWNiZWM1MzgtNWEzMy00MTgwLTgwNjAtNWQ1ZWUwZmQzNjVh%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d

Organizer: Soumya Guptha

View Event

Description:

Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 119 132 712 6

Alternate VTC dialing instructions

Or call in (audio only)

+1 916-245-6934,,494156131#   United States, Sacramento

Phone Conference ID: 494 156 131#

Find a local number | Reset PIN

Learn More | Meeting options


Re: [edk2-libc PATCH 1/1] Update LibC to use safe string functions

Michael D Kinney
 

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
Sent: Monday, June 7, 2021 9:22 AM
To: devel@edk2.groups.io; Daryl McDaniel <edk2-lists@mc2research.org>; Carsey, Jaben <jaben.carsey@intel.com>
Cc: Rebecca Cran <rebecca@nuviainc.com>
Subject: [edk2-devel] [edk2-libc PATCH 1/1] Update LibC to use safe string functions

The insecure string functions such as StrCpy were removed a while ago,
breaking the StdLib build. Migrate StdLib/LibC to the safe string
versions.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
---
StdLib/LibC/StdLib/Environs.c | 11 ++++++-----
StdLib/LibC/StdLib/realpath.c | 5 +++--
StdLib/LibC/String/Concatenation.c | 7 +++++--
StdLib/LibC/String/Copying.c | 7 +++++--
StdLib/LibC/Uefi/Devices/Utility/Path.c | 3 ++-
StdLib/LibC/Uefi/SysCalls.c | 5 +++--
StdLib/LibC/Wchar/Concatenation.c | 6 ++++--
StdLib/LibC/Wchar/Copying.c | 4 ++--
8 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/StdLib/LibC/StdLib/Environs.c b/StdLib/LibC/StdLib/Environs.c
index a29cb9954cf9..ad56629554df 100644
--- a/StdLib/LibC/StdLib/Environs.c
+++ b/StdLib/LibC/StdLib/Environs.c
@@ -151,7 +151,7 @@ system(const char *string)
if( string == NULL) {
return 1;
}
- (void)AsciiStrToUnicodeStr( string, gMD->UString);
+ (void)AsciiStrToUnicodeStrS (string, gMD->UString, UNICODE_STRING_MAX);
OpStat = ShellExecute( &MyHandle, gMD->UString, FALSE, NULL, &CmdStat);
if(OpStat == RETURN_SUCCESS) {
EFIerrno = CmdStat;
@@ -177,10 +177,11 @@ char *getenv(const char *name)
const CHAR16 *EfiEnv;
char *retval = NULL;

- (void)AsciiStrToUnicodeStr( name, gMD->UString);
+ (void)AsciiStrToUnicodeStrS (name, gMD->UString, UNICODE_STRING_MAX);
EfiEnv = ShellGetEnvironmentVariable(gMD->UString);
if(EfiEnv != NULL) {
- retval = UnicodeStrToAsciiStr( EfiEnv, gMD->ASgetenv);
+ (void)UnicodeStrToAsciiStrS (EfiEnv, gMD->ASgetenv, UNICODE_STRING_MAX);
+ retval = gMD->ASgetenv;
}

return retval;
@@ -238,8 +239,8 @@ setenv (
//
// Convert the strings
//
- AsciiStrToUnicodeStr ( name, UName );
- AsciiStrToUnicodeStr ( value, UValue );
+ AsciiStrToUnicodeStrS (name, UName, UNICODE_STRING_MAX);
+ AsciiStrToUnicodeStrS (value, UValue, UNICODE_STRING_MAX);

//
// Determine if the string is already present
diff --git a/StdLib/LibC/StdLib/realpath.c b/StdLib/LibC/StdLib/realpath.c
index 6d75f17a394d..a8ff1e9d5b1d 100644
--- a/StdLib/LibC/StdLib/realpath.c
+++ b/StdLib/LibC/StdLib/realpath.c
@@ -14,6 +14,7 @@
#include <Library/BaseLib.h>
#include <Library/MemoryAllocationLib.h>
#include <errno.h>
+#include <limits.h>

/** The realpath() function shall derive, from the pathname pointed to by
file_name, an absolute pathname that names the same file, whose resolution
@@ -47,8 +48,8 @@ realpath(
errno = ENOMEM;
return (NULL);
}
- AsciiStrToUnicodeStr(file_name, Temp);
+ AsciiStrToUnicodeStrS (file_name, Temp, UNICODE_STRING_MAX);
PathCleanUpDirectories(Temp);
- UnicodeStrToAsciiStr(Temp, resolved_name);
+ UnicodeStrToAsciiStrS (Temp, resolved_name, UNICODE_STRING_MAX);
return (resolved_name);
}
diff --git a/StdLib/LibC/String/Concatenation.c b/StdLib/LibC/String/Concatenation.c
index e76bea0bf858..f78836fbe0d6 100644
--- a/StdLib/LibC/String/Concatenation.c
+++ b/StdLib/LibC/String/Concatenation.c
@@ -15,6 +15,7 @@

#include <LibConfig.h>

+#include <limits.h>
#include <string.h>

/** The strcat function appends a copy of the string pointed to by s2
@@ -28,7 +29,8 @@
char *
strcat(char * __restrict s1, const char * __restrict s2)
{
- return AsciiStrCat( s1, s2);
+ AsciiStrCatS (s1, UNICODE_STRING_MAX, s2);
+ return s1;
}

/** The strncat function appends not more than n characters (a null character
@@ -43,7 +45,8 @@ strcat(char * __restrict s1, const char * __restrict s2)
char *
strncat(char * __restrict s1, const char * __restrict s2, size_t n)
{
- return AsciiStrnCat( s1, s2, n);
+ AsciiStrnCatS (s1, UNICODE_STRING_MAX, s2, n);
+ return s1;
}

/** The strncatX function appends not more than n characters (a null character
diff --git a/StdLib/LibC/String/Copying.c b/StdLib/LibC/String/Copying.c
index 3234eccf0808..cc2077a5b80a 100644
--- a/StdLib/LibC/String/Copying.c
+++ b/StdLib/LibC/String/Copying.c
@@ -16,6 +16,7 @@

#include <LibConfig.h>

+#include <limits.h>
#include <stdlib.h>
#include <string.h>

@@ -73,7 +74,8 @@ strcpy(char * __restrict s1, const char * __restrict s2)

//while ( *s1++ = *s2++) /* Empty Body */;
//return(s1ret);
- return AsciiStrCpy( s1, s2);
+ AsciiStrCpyS (s1, UNICODE_STRING_MAX, s2);
+ return s1;
}

/** The strncpy function copies not more than n characters (characters that
@@ -89,7 +91,8 @@ strcpy(char * __restrict s1, const char * __restrict s2)
**/
char *strncpy(char * __restrict s1, const char * __restrict s2, size_t n)
{
- return AsciiStrnCpy( s1, s2, n);
+ AsciiStrnCpyS (s1, UNICODE_STRING_MAX, s2, n);
+ return s1;
//char *dest = s1;

//while(n != 0) {
diff --git a/StdLib/LibC/Uefi/Devices/Utility/Path.c b/StdLib/LibC/Uefi/Devices/Utility/Path.c
index 96392e018dac..d6728d3a647e 100644
--- a/StdLib/LibC/Uefi/Devices/Utility/Path.c
+++ b/StdLib/LibC/Uefi/Devices/Utility/Path.c
@@ -110,7 +110,8 @@ NormalizePath( const char *path)
wchar_t *NewPath;
size_t Length;

- OldPath = AsciiStrToUnicodeStr(path, gMD->UString);
+ AsciiStrToUnicodeStrS (path, gMD->UString, UNICODE_STRING_MAX);
+ OldPath = gMD->UString;
Length = wcslen(OldPath) + 1;

NewPath = calloc(Length, sizeof(wchar_t));
diff --git a/StdLib/LibC/Uefi/SysCalls.c b/StdLib/LibC/Uefi/SysCalls.c
index faa73ed7a4ee..e83b72308fbe 100644
--- a/StdLib/LibC/Uefi/SysCalls.c
+++ b/StdLib/LibC/Uefi/SysCalls.c
@@ -1320,7 +1320,8 @@ char
errno = ERANGE;
return (NULL);
}
- return (UnicodeStrToAsciiStr(Cwd, buf));
+ UnicodeStrToAsciiStrS (Cwd, buf, UNICODE_STRING_MAX);
+ return buf;
}

/** Change the current working directory.
@@ -1358,7 +1359,7 @@ chdir (const char *path)
errno = ENOMEM;
return -1;
}
- AsciiStrToUnicodeStr(path, UnicodePath);
+ AsciiStrToUnicodeStrS (path, UnicodePath, UNICODE_STRING_MAX);
Status = gEfiShellProtocol->SetCurDir(NULL, UnicodePath);
FreePool(UnicodePath);
if (EFI_ERROR(Status)) {
diff --git a/StdLib/LibC/Wchar/Concatenation.c b/StdLib/LibC/Wchar/Concatenation.c
index cf595a461f0e..7289240951aa 100644
--- a/StdLib/LibC/Wchar/Concatenation.c
+++ b/StdLib/LibC/Wchar/Concatenation.c
@@ -31,7 +31,8 @@
**/
wchar_t *wcscat(wchar_t * __restrict s1, const wchar_t * __restrict s2)
{
- return (wchar_t *)StrCat( (CHAR16 *)s1, (CONST CHAR16 *)s2);
+ StrCatS ((CHAR16 *)s1, UNICODE_STRING_MAX, (CONST CHAR16 *)s2);
+ return s1;
}

/** The wcsncat function appends not more than n wide characters (a null wide
@@ -44,5 +45,6 @@ wchar_t *wcscat(wchar_t * __restrict s1, const wchar_t * __restrict s2)
**/
wchar_t *wcsncat(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
{
- return (wchar_t *)StrnCat( (CHAR16 *)s1, (CONST CHAR16 *)s2, (UINTN)n);
+ StrnCatS ((CHAR16 *)s1, UNICODE_STRING_MAX, (CONST CHAR16 *)s2, (UINTN)n);
+ return s1;
}
diff --git a/StdLib/LibC/Wchar/Copying.c b/StdLib/LibC/Wchar/Copying.c
index 7075437965ad..848c83419ddb 100644
--- a/StdLib/LibC/Wchar/Copying.c
+++ b/StdLib/LibC/Wchar/Copying.c
@@ -29,7 +29,7 @@
**/
wchar_t *wcscpy(wchar_t * __restrict s1, const wchar_t * __restrict s2)
{
- return (wchar_t *)StrCpy( (CHAR16 *)s1, (CONST CHAR16 *)s2);
+ return (wchar_t *)StrCpyS ((CHAR16 *)s1, UNICODE_STRING_MAX, (CONST CHAR16 *)s2);
}

/** The wcsncpy function copies not more than n wide characters (those that
@@ -44,7 +44,7 @@ wchar_t *wcscpy(wchar_t * __restrict s1, const wchar_t * __restrict s2)
**/
wchar_t *wcsncpy(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
{
- return (wchar_t *)StrnCpy( (CHAR16 *)s1, (CONST CHAR16 *)s2, (UINTN)n);
+ return (wchar_t *)StrnCpyS ((CHAR16 *)s1, UNICODE_STRING_MAX, (CONST CHAR16 *)s2, (UINTN)n);
}

/** The wmemcpy function copies n wide characters from the object pointed to by
--
2.26.2





Re: [PATCH v2] Xcode.md: Update instructions to work on modern macOS and Xcode versions

Rebecca Cran
 

Thanks, that looks good.

Rebecca Cran

On Aug 12, 2021, at 7:32 PM, gaoliming <gaoliming@byosoft.com.cn> wrote:

Rebecca:
I just merge it. Please check.

Thanks
Liming
-----邮件原件-----
发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Rebecca Cran
发送时间: 2021年8月13日 0:56
收件人: Andrew Fish <afish@apple.com>; edk2-devel-groups-io
<devel@edk2.groups.io>
主题: Re: [edk2-devel] [PATCH v2] Xcode.md: Update instructions to work on
modern macOS and Xcode versions

Could you push the commit please?

https://github.com/tianocore/tianocore.github.io/wiki/Xcode is still
showing the old content.


Thanks.
Rebecca Cran

On 7/22/2021 1:10 AM, Andrew Fish wrote:
Reviewed-by: Andrew Fish <afish@apple.com>

On Jul 21, 2021, at 4:56 PM, Rebecca Cran <rebecca@bsdio.com> wrote:

The existing instructions no longer work on macOS Big Sur and Xcode 12.5.
Update them to include for example using lldb instead of gdb, installing
XQuartz, and using modern names such as macOS instead of Mac OS X.

Also, since MacPorts is less popular these days, remove instructions for
installing tools with it, leaving steps for using Homebrew.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
---
Xcode.md | 172 +++++++++-----------
1 file changed, 78 insertions(+), 94 deletions(-)

diff --git a/Xcode.md b/Xcode.md
index 3d220a5..8af2653 100644
--- a/Xcode.md
+++ b/Xcode.md
@@ -1,43 +1,28 @@
-This page provides step-by-step instructions for setting up a
[http://www.tianocore.org/edk2/ EDK II] build environment on Mac OS X
systems using the Xcode development tools. These steps have been verified
with macOS Sierra Version 10.12.4
+This page provides step-by-step instructions for setting up a [EDK
II](https://github.com/tianocore/tianocore.github.io/wiki/EDK-II) build
environment on macOS systems using the Xcode development tools. These
steps have been verified with macOS Big Sur 11.3.1

-# Mac OS X Xcode
-Download the latest version of
[Xcode](https://developer.apple.com/xcode) (9.4.1 as of this writing) from the
Mac App Store. After installing Xcode, you will additionally need to install
the extra command-line tools. To do this, at a Terminal prompt, enter:
+# macOS Xcode
+Download the latest version of
[Xcode](https://developer.apple.com/xcode) (12.5 as of 2021-05-09) from the
Mac App Store. After installing Xcode, you will additionally need to install
the extra command-line tools. To do this, at a Terminal prompt, enter:
```
$ xcode-select --install
```
## Additional Development Tools
-While Xcode provides a full development environment as well as a suite of
different utilities, it does not provide all tools required for Tianocore
development. These tools can be provided in a number of ways, but the two
most popular ways come from [Brew](https://brew.sh) and
[MacPorts](https://www.macports.org/install.php). Installation information
is provided at the previous links.
-
-### MacPorts Tips
-* If you work behind a firewall and need to pass your network traffic
through a proxy, ensure you set the environment variable RSYNC_PROXY to
your http proxy in the form of `proxy.dns.name:port_number`.
- * Remember that `sudo` by default drops most environment variables.
Add the `-E` option to tell `sudo` to keep your environment variables.
-* When installing MacPorts packages, if you would like to build from
source like traditional [FreeBSD
Ports](https://en.wikipedia.org/wiki/FreeBSD_Ports) systems, add the `-s`
option to the command line. Otherwise, default behavior is to pull
precompiled packages.
+While Xcode provides a full development environment as well as a suite
of different utilities, it does not provide all tools required for TianoCore
development. These tools can be provided in a number of ways, but the
most popular way comes from [Brew](https://brew.sh). Installation
information is provided at the previous link.

## Install mtoc
The mtoc utility is required to convert from the macOS Mach-O image
format to the PE/COFF format as required by the UEFI specification.

### Brew Instructions
```
-$ brew install mtoc
-```
-## MacPorts Instructions
-```
-$ sudo port install cctools
+$ brew install mtoc
```
-By default, this will install `mtoc` at `/opt/local/bin/mtoc`.
# Install NASM

-The assembler used for EDK II builds is Netwide Assembler (NASM). The
latest version of NASM is available from http://www.nasm.us/.
+The assembler used for EDK II builds is Netwide Assembler (NASM). The
latest version of NASM is available from https://nasm.us/.
## Brew Instructions
```
$ brew install nasm
$ brew upgrade nasm
```
-## MacPorts Instructions
-```
-$ sudo port install nasm
-```
-By default this installs `nasm` at `/opt/local/bin/nasm`.

# Install ACPI Compiler

@@ -47,26 +32,20 @@ In order to support EDK II firmware builds, the
latest version of the ASL compil
$ brew install acpica
$ brew upgrade acpica
```
-## MacPorts Install
-```
-$ sudo port install acpica
-```
-By default this installs `iasl` at `/opt/local/bin/iasl`
+
+# Install XQuartz
+
+The EmulatorPkg requires headers from X11, which are provided by the
XQuartz project. Install it from https://www.xquartz.org/.

# Install QEMU Emulator

-On order to support running the OVMF platforms from the OvmfPkg, the
QEMU emulator from http://www.qemu.org/ must be installed.
+On order to support running the OVMF platforms from the OvmfPkg, the
QEMU emulator from https://www.qemu.org/ must be installed.

## Brew Install
```
$ brew install qemu
$ brew upgrade qemu
```
-## MacPorts Install
-```
-$ sudo port install qemu
-```
-By default qemu is installed in `/opt/local/bin`.
## Update PATH environment variable

Tools installed using the `brew` command are placed in `/usr/local/bin`.
The `PATH` environment variable must be updated so the newly installed tools
are used instead of older pre-installed tools.
@@ -75,11 +54,6 @@ Tools installed using the `brew` command are
placed in `/usr/local/bin`. The `P
export PATH=/usr/local/bin:$PATH
```

-Tools installed using the `port` should automatically be in your shell's PATH.
If not, you can manually set it by:
-```
-export PATH=/opt/local/bin:$PATH
-```
-
# Verify tool versions

Run the following commands to verify the versions of the tools that have
been installed.
@@ -97,84 +71,94 @@ Pick the location you want to down load the files
to and `cd` to that directory:
```
cd ~/work
git clone https://github.com/tianocore/edk2.git
+cd edk2
+git submodule update --init
```

-# Build from Command Line/Debug with gdb
+# Build from Command Line/Debug with lldb

-Build the UnixPkg:
+Build the EmulatorPkg:

```
-cd ~/work/edk2/UnixPkg
+cd ~/work/edk2/EmulatorPkg
./build.sh
```

-Debug the UnixPkg
+Debug the EmulatorPkg

```
./build.sh run

-Building from: /Users/fish/work/edk2
+Initializing workspace
+/Users/bcran/src/edk2/BaseTools
+Loading previous configuration from
/Users/bcran/src/edk2/Conf/BuildEnv.sh
+Using EDK2 in-source Basetools
+WORKSPACE: /Users/bcran/src/edk2
+EDK_TOOLS_PATH: /Users/bcran/src/edk2/BaseTools
+CONF_PATH: /Users/bcran/src/edk2/Conf
using prebuilt tools
-Reading symbols for shared libraries ...... done
-Breakpoint 1 at 0xce84: file
/Users/fish/work/edk2/UnixPkg/Sec/SecMain.c, line 1070.
-(gdb)
-```
-
-Type `r` at the gdb prompt (don't forget to hit carriage return) to boot the
emulator. Ctrl-c in the terminal window will break in to gdb. bt is the stack
backtrace command:
-
-```
-^C
-Program received signal SIGINT, Interrupt.
-0x92423806 in __semwait_signal ()
-(gdb) bt
-#0 0x92423806 in __semwait_signal ()
-#1 0x9244f441 in nanosleep$UNIX2003 ()
-#2 0x0000b989 in msSleep (Milliseconds=0x14) at
/Users/fish/work/Migration/edk2/UnixPkg/Sec/UnixThunk.c:102
-#3 0x0000acf5 in UgaCheckKey (UgaIo=0x2078d0) at
/Users/fish/work/Migration/edk2/UnixPkg/Sec/UgaX11.c:380
-#4 0x0000d8b7 in _GasketUintn () at
/Users/fish/work/Migration/edk2/Build/Unix/DEBUG_XCODE32/IA32/UnixPk
g/Sec/SecMain/OUTPUT/Ia32/Gasket.iii:63
-#5 0x0000d801 in GasketUgaCheckKey (UgaIo=0x2078d0) at
/Users/fish/work/Migration/edk2/UnixPkg/Sec/Gasket.c:406
-#6 0x454a25fb in UnixUgaSimpleTextInWaitForKey (Event=0x45603610,
Context=0x45382110) at
/Users/fish/work/Migration/edk2/UnixPkg/UnixUgaDxe/UnixUgaInput.c:169
-#7 0x45faad3a in CoreDispatchEventNotifies (Priority=0x10) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:1
85
-#8 0x45faa639 in CoreRestoreTpl (NewTpl=0x4) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Event/Tpl.c:114
-#9 0x45f9f197 in CoreReleaseLock (Lock=0x45fb1024) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Library/Library.
c:102
-#10 0x45faabd6 in CoreReleaseEventLock () at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:1
13
-#11 0x45fab26c in CoreCheckEvent (UserEvent=0x45603210) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:5
62
-#12 0x45fab2db in CoreWaitForEvent (NumberOfEvents=0x1,
UserEvents=0x45f94cc4, UserIndex=0x45f94cb8) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:6
21
-#13 0x49ce9557 in ?? ()
-#14 0x49cf0344 in ?? ()
-#15 0x49ce3bc2 in ?? ()
-#16 0x49ce3ae1 in ?? ()
-#17 0x45f9e4e3 in CoreStartImage (ImageHandle=0x49e31e10,
ExitDataSize=0x45f94eec, ExitData=0x45f94ee8) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Image/Image.c:
1260
-#18 0x4550cccc in BdsLibBootViaBootOption (Option=0x49ffa110,
DevicePath=0x49ffa190, ExitDataSize=0x45f94eec, ExitData=0x45f94ee8) at
/Users/fish/work/Migration/edk2/IntelFrameworkModulePkg/Library/Generi
cBdsLib/BdsBoot.c:382
-#19 0x455252a9 in BdsBootDeviceSelect () at
/Users/fish/work/Migration/edk2/IntelFrameworkModulePkg/Universal/Bds
Dxe/BdsEntry.c:214
-#20 0x455255bc in BdsEntry (This=0x4552d01c) at
/Users/fish/work/Migration/edk2/IntelFrameworkModulePkg/Universal/Bds
Dxe/BdsEntry.c:356
-#21 0x45fad7e8 in DxeMain (HobStart=0x45f70010) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/DxeMain/DxeM
ain.c:425
-#22 0x45fadd1d in ProcessModuleEntryPointList (HobStart=0x42020000)
at
/Users/fish/work/Migration/edk2/Build/Unix/DEBUG_XCODE32/IA32/MdeM
odulePkg/Core/Dxe/DxeMain/DEBUG/AutoGen.c:287
-#23 0x45f97773 in _ModuleEntryPoint (HobStart=0x42020000) at
/Users/fish/work/Migration/edk2/MdePkg/Library/DxeCoreEntryPoint/DxeCo
reEntryPoint.c:54
-(gdb)
+(lldb) target create "./Host"
+Current executable set to
'/Users/bcran/src/edk2/Build/EmulatorX64/DEBUG_XCODE5/X64/Host'
(x86_64).
+(lldb) command script import
/Users/bcran/src/edk2/EmulatorPkg/Unix/lldbefi.py
+Type r to run emulator. SecLldbScriptBreak armed. EFI modules should
now get source level debugging in the emulator.
+(lldb) script lldb.debugger.SetAsync(True)
+(lldb) run
+Process 12155 launched:
'/Users/bcran/src/edk2/Build/EmulatorX64/DEBUG_XCODE5/X64/Host'
(x86_64)
+
+EDK II UNIX Host Emulation Environment from
http://www.tianocore.org/edk2/
+ BootMode 0x00
+ OS Emulator passing in 128 KB of temp RAM at 0x102000000 to SEC
+ FD loaded from ../FV/FV_RECOVERY.fd at 0x102020000 contains SEC
Core
+...
+```
+
+Type `process interrupt` at the lldb prompt (don't forget to hit carriage
return) to pause execution. Ctrl-c in the terminal window will quit lldb. `bt` is
the stack backtrace command:
+
+```
+Process 12420 stopped
+* thread #1, queue = 'com.apple.main-thread', stop reason = signal
SIGSTOP
+ frame #0: 0x00007fff2033cc22
libsystem_kernel.dylib:__semwait_signal() + 10
+libsystem_kernel.dylib`__semwait_signal:
+-> 0x7fff2033cc22 <+10>: jae 0x7fff2033cc2c ;
<+20>
+ 0x7fff2033cc24 <+12>: movq %rax, %rdi
+ 0x7fff2033cc27 <+15>: jmp 0x7fff2033b72d ;
cerror
+ 0x7fff2033cc2c <+20>: retq
+Target 0: (Host) stopped.
+(lldb) bt
+* thread #1, queue = 'com.apple.main-thread', stop reason = signal
SIGSTOP
+ * frame #0: 0x00007fff2033cc22
libsystem_kernel.dylib:__semwait_signal() + 10
+ frame #1: 0x00007fff202bcc2a libsystem_c.dylib:nanosleep() + 196
+ frame #2: 0x0000000100005e55 Host:SecCpuSleep() + 37 at
/Users/bcran/src/edk2/EmulatorPkg/Unix/Host/EmuThunk.c:334
+ frame #3: 0x000000010000e96e Host:GasketSecCpuSleep() + 11 at
/Users/bcran/src/edk2/Build/EmulatorX64/DEBUG_XCODE5/X64/EmulatorPk
g/Unix/Host/Host/OUTPUT/X64/Gasket.iiii:283
+ frame #4: 0x0000000106f985e9
DxeCore.dll:CoreDispatchEventNotifies() + 264 at
/Users/bcran/src/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:194
+ frame #5: 0x0000000106f97fce DxeCore.dll:CoreRestoreTpl() + 227
at /Users/bcran/src/edk2/MdeModulePkg/Core/Dxe/Event/Tpl.c:131
+ frame #6: 0x0000000106f989db DxeCore.dll:CoreSignalEvent() + 111
at /Users/bcran/src/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:566
+ frame #7: 0x0000000106f98b01 DxeCore.dll:CoreWaitForEvent() +
94 at /Users/bcran/src/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:707
+ frame #8: 0x0000000113e8e54c BdsDxe.dll:BdsWaitForSingleEvent()
+ 127 at
/Users/bcran/src/edk2/MdeModulePkg/Universal/BdsDxe/BdsEntry.c:250
+ frame #9: 0x0000000113e8e70b BdsDxe.dll:BdsWait() + 215 at
/Users/bcran/src/edk2/MdeModulePkg/Universal/BdsDxe/BdsEntry.c:328
+ frame #10: 0x0000000113e8dffb BdsDxe.dll:BdsEntry() + 2612 at
/Users/bcran/src/edk2/MdeModulePkg/Universal/BdsDxe/BdsEntry.c:1012
+ frame #11: 0x0000000106f9bbd6 DxeCore.dll:DxeMain() + 2791 at
/Users/bcran/src/edk2/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c:551
+ frame #12: 0x0000000106f9ed8f DxeCore.dll:_ModuleEntryPoint() +
20 at
/Users/bcran/src/edk2/MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoi
nt.c:48
+ frame #13: 0x0000000106fdd02f DxeIpl.dll:InternalSwitchStack() +
15
+ frame #14: 0x0000000106fdc0b6 DxeIpl.dll:HandOffToDxeCore() +
546 at
/Users/bcran/src/edk2/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.
c:126
+ frame #15: 0x0000000106fda78a DxeIpl.dll:DxeLoadCore() + 1354 at
/Users/bcran/src/edk2/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c:449
+ frame #16: 0x0000000106ff1d7c
+ frame #17: 0x00000001020255c6 PeiCore.dll:PeiCore() + 1982 at
/Users/bcran/src/edk2/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c:331
+ frame #18: 0x000000010202a82c
PeiCore.dll:PeiCheckAndSwitchStack() + 1171 at
/Users/bcran/src/edk2/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c:84
2
+ frame #19: 0x000000010202b853 PeiCore.dll:PeiDispatcher() + 1206
at
/Users/bcran/src/edk2/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c:16
09
+(lldb)
+
```

# Build and Debug from Xcode
-To build from the Xcode GUI open
~/work/edk2/UnixPkg/Xcode/xcode_project/xcode_project.xcodeproj. You
can build, clean, and source level debug from the Xcode GUI. You can hit
the Build and Debug button to start the build process. You need to need to hit
command-shift-B to show the output of the build. Click Pause to break into
the debugger.
-
-[[File:Xcode.jpg]]
+To build from the Xcode GUI open
~/work/edk2/EmulatorPkg/Unix/Xcode/xcode_project64/xcode_project.xcod
eproj. You can build, clean, and source level debug from the Xcode GUI. You
can hit the Build and Debug button to start the build process. You need to
need to hit command-shift-B to show the output of the build. Click Pause to
break into the debugger.

The stack trace contains items that show as ?? since the default shell is
checked in as a binary. `nanosleep$UNIX2003` and `__semwait_signal` are
POSIX library calls and you do not get C source debug with these symbols.

-# Source Level Debug Shell
-
-It is possible to get source level debug for the EFI Shell by pulling these
projects from source control and building them.
-
-Instructions for building and hooking in the shell are located in the
[https://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Gcc-shel
l gcc-shell] project.
-
-Please note the gcc-shell and UnixPkg build separately, so if you update
shell code you need to build the shell to see the changes. The following screen
shot shows being able to source level debug the shell:
-
-[[File:Xcode_good.jpg]]
+*Note* The Xcode project is currently (as of 2021-05-09) broken.

# See Also

-* [[Step-by-step instructions]]
-
# Continue with common instructions

-The [remaining instructions](../Common-instructions) are common for
most UNIX-like systems.
+The [remaining
instructions](https://github.com/tianocore/tianocore.github.io/wiki/Common
-instructions-for-Unix) are common for most UNIX-like systems.
--
2.30.1 (Apple Git-130)











回复: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

gaoliming
 

Bret:

 I suggest to define new macro that follows EDKII style. This MACRO is only used in CommandLib. Its impact should be small.

 

Thanks

Liming

发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Bret Barkelew via groups.io
发送时间: 2021813 8:24
收件人: Yao, Jiewen <jiewen.yao@...>; devel@edk2.groups.io; bret@...; Kinney, Michael D <michael.d.kinney@...>
抄送: Wang, Jian J <jian.j.wang@...>; Zhang, Qi1 <qi1.zhang@...>; Kumar, Rahul1 <rahul1.kumar@...>
主题: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

+ @Kinney, Michael D

 

Mike, any thoughts on when “sticking with the file convention” breaks ECC? Should I just ignore the rest of the file and pass ECC at all costs?

 

- Bret

 

From: Yao, Jiewen
Sent: Thursday, August 12, 2021 5:06 PM
To: Bret Barkelew; devel@edk2.groups.io; bret@...
Cc: Wang, Jian J; Zhang, Qi1; Kumar, Rahul1
Subject: RE: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

I don’t know the answer about ECC or PatchChecker.

I  just know we need pass CI to merge the patch.

 

Thank you

Yao Jiewen

 

From: Bret Barkelew <Bret.Barkelew@...>
Sent: Friday, August 13, 2021 1:52 AM
To: devel@edk2.groups.io; bret@...
Cc: Yao, Jiewen <jiewen.yao@...>; Wang, Jian J <jian.j.wang@...>; Zhang, Qi1 <qi1.zhang@...>; Kumar, Rahul1 <rahul1.kumar@...>
Subject: RE: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Thoughts?

 

- Bret

 

From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Bret Barkelew via groups.io <bret.barkelew@...>
Sent: Wednesday, August 11, 2021 12:37:52 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>; bret@... <bret@...>
Cc: Yao, Jiewen <jiewen.yao@...>; Jian J Wang <jian.j.wang@...>; Qi Zhang <qi1.zhang@...>; Rahul Kumar <rahul1.kumar@...>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Thoughts?

 

- Bret

 

From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Bret Barkelew via groups.io <bret.barkelew@...>
Sent: Wednesday, August 4, 2021 9:32:32 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>; bret@... <bret@...>
Cc: Yao, Jiewen <jiewen.yao@...>; Jian J Wang <jian.j.wang@...>; Qi Zhang <qi1.zhang@...>; Rahul Kumar <rahul1.kumar@...>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Poking this one.

 

  1. It’s a easy review with small, obvious code change.
  2. I need some answers on “when is it okay to violate ECC/PatchCheck, if the new code matches the style of the existing code. Should I endeavor to pass the PatchCheck and ECCCheck with this patch only, and leave it in conflict with the rest of the file?

 

Thanks!

 

- Bret

 

From: Bret Barkelew via groups.io
Sent: Friday, July 30, 2021 11:08 AM
To: devel@edk2.groups.io; bret@...
Cc: Yao, Jiewen; Jian J Wang; Qi Zhang; Rahul Kumar
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Note, even though this keeps with the style of the rest of the file, it breaks ECC:

SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib by corthon · Pull Request #1848 · tianocore/edk2 (github.com)

 

PROGRESS - --Running SecurityPkg: EccCheck Test NO-TARGET --

ERROR -

ERROR -

ERROR - EFI coding style error

ERROR - *Error code: 8001

ERROR - *Only capital letters are allowed to be used for #define declarations

ERROR - *file: //home/vsts/work/1/s/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c

ERROR - *Line number: 27

ERROR - *The #define name [RC_NV_UndefineSpaceSpecial_nvIndex] does no

 

Thoughts?

 

- Bret

 

From: Bret Barkelew via groups.io
Sent: Friday, July 30, 2021 10:55 AM
To: devel@edk2.groups.io
Cc: Yao, Jiewen; Jian J Wang; Qi Zhang; Rahul Kumar
Subject: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Used to provision and maintain certain HW-defined NV spaces.

REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2994&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397602953%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=s96M3RvxMOY831Vfr1nt%2Fz1h3cyb6jU9eFzvjKO7Dtc%3D&amp;reserved=0

Signed-off-by: Bret Barkelew <bret.barkelew@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Qi Zhang <qi1.zhang@...>
Cc: Rahul Kumar <rahul1.kumar@...>
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c | 122 ++++++++++++++++++++
 SecurityPkg/Include/Library/Tpm2CommandLib.h       |  22 ++++
 2 files changed, 144 insertions(+)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
index 87572de20164..7931fade9190 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
@@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define RC_NV_UndefineSpace_authHandle      (TPM_RC_H + TPM_RC_1)

 #define RC_NV_UndefineSpace_nvIndex         (TPM_RC_H + TPM_RC_2)

 

+#define RC_NV_UndefineSpaceSpecial_nvIndex  (TPM_RC_H + TPM_RC_1)

+

 #define RC_NV_Read_authHandle               (TPM_RC_H + TPM_RC_1)

 #define RC_NV_Read_nvIndex                  (TPM_RC_H + TPM_RC_2)

 #define RC_NV_Read_size                     (TPM_RC_P + TPM_RC_1)

@@ -74,6 +76,20 @@ typedef struct {
   TPMS_AUTH_RESPONSE         AuthSession;

 } TPM2_NV_UNDEFINESPACE_RESPONSE;

 

+typedef struct {

+  TPM2_COMMAND_HEADER       Header;

+  TPMI_RH_NV_INDEX          NvIndex;

+  TPMI_RH_PLATFORM          Platform;

+  UINT32                    AuthSessionSize;

+  TPMS_AUTH_COMMAND         AuthSession;

+} TPM2_NV_UNDEFINESPACESPECIAL_COMMAND;

+

+typedef struct {

+  TPM2_RESPONSE_HEADER       Header;

+  UINT32                     AuthSessionSize;

+  TPMS_AUTH_RESPONSE         AuthSession;

+} TPM2_NV_UNDEFINESPACESPECIAL_RESPONSE;

+

 typedef struct {

   TPM2_COMMAND_HEADER       Header;

   TPMI_RH_NV_AUTH           AuthHandle;

@@ -506,6 +522,112 @@ Done:
   return Status;

 }

 

+/**

+  This command removes an index from the TPM.

+

+  @param[in]  NvIndex             The NV Index.

+  @param[in]  IndexAuthSession    Auth session context for the Index auth/policy

+  @param[in]  PlatAuthSession     Auth session context for the Platform auth/policy

+

+  @retval EFI_SUCCESS             Operation completed successfully.

+  @retval EFI_NOT_FOUND           The command was returned successfully, but NvIndex is not found.

+  @retval EFI_UNSUPPORTED         Selected NvIndex does not support deletion through this call.

+  @retval EFI_SECURITY_VIOLATION  Deletion is not authorized by current policy session.

+  @retval EFI_INVALID_PARAMETER   The command was unsuccessful.

+  @retval EFI_DEVICE_ERROR        The command was unsuccessful.

+**/

+EFI_STATUS

+EFIAPI

+Tpm2NvUndefineSpaceSpecial (

+  IN      TPMI_RH_NV_INDEX          NvIndex,

+  IN      TPMS_AUTH_COMMAND         *IndexAuthSession OPTIONAL,

+  IN      TPMS_AUTH_COMMAND         *PlatAuthSession OPTIONAL

+  )

+{

+  EFI_STATUS                              Status;

+  TPM2_NV_UNDEFINESPACESPECIAL_COMMAND    SendBuffer;

+  TPM2_NV_UNDEFINESPACESPECIAL_RESPONSE   RecvBuffer;

+  UINT32                                  SendBufferSize;

+  UINT32                                  RecvBufferSize;

+  UINT8                                   *Buffer;

+  UINT32                                  IndexAuthSize, PlatAuthSize;

+  TPM_RC                                  ResponseCode;

+

+  //

+  // Construct command

+  //

+  SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);

+  SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_UndefineSpaceSpecial);

+

+  SendBuffer.NvIndex = SwapBytes32 (NvIndex);

+  SendBuffer.Platform = SwapBytes32 (TPM_RH_PLATFORM);

+

+  //

+  // Marshall the Auth Sessions for the two handles.

+  Buffer = (UINT8 *)&SendBuffer.AuthSession;

+  // IndexAuthSession

+  IndexAuthSize = CopyAuthSessionCommand (IndexAuthSession, Buffer);

+  Buffer += IndexAuthSize;

+  // PlatAuthSession

+  PlatAuthSize = CopyAuthSessionCommand (PlatAuthSession, Buffer);

+  Buffer += PlatAuthSize;

+  // AuthSessionSize

+  SendBuffer.AuthSessionSize = SwapBytes32(IndexAuthSize + PlatAuthSize);

+

+  // Update total command size.

+  SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);

+  SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);

+

+  //

+  // send Tpm command

+  //

+  RecvBufferSize = sizeof (RecvBuffer);

+  Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);

+  if (EFI_ERROR (Status)) {

+    goto Done;

+  }

+

+  if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {

+    DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpaceSpecial - RecvBufferSize Error - %x\n", RecvBufferSize));

+    Status = EFI_DEVICE_ERROR;

+    goto Done;

+  }

+

+  ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);

+  if (ResponseCode != TPM_RC_SUCCESS) {

+    DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpaceSpecial - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));

+  }

+  switch (ResponseCode) {

+  case TPM_RC_SUCCESS:

+    // return data

+    break;

+  case TPM_RC_ATTRIBUTES:

+  case TPM_RC_ATTRIBUTES + RC_NV_UndefineSpaceSpecial_nvIndex:

+    Status = EFI_UNSUPPORTED;

+    break;

+  case TPM_RC_NV_AUTHORIZATION:

+    Status = EFI_SECURITY_VIOLATION;

+    break;

+  case TPM_RC_HANDLE + RC_NV_UndefineSpaceSpecial_nvIndex: // TPM_RC_NV_DEFINED:

+    Status = EFI_NOT_FOUND;

+    break;

+  case TPM_RC_VALUE + RC_NV_UndefineSpace_nvIndex:

+    Status = EFI_INVALID_PARAMETER;

+    break;

+  default:

+    Status = EFI_DEVICE_ERROR;

+    break;

+  }

+

+Done:

+  //

+  // Clear AuthSession Content

+  //

+  ZeroMem (&SendBuffer, sizeof(SendBuffer));

+  ZeroMem (&RecvBuffer, sizeof(RecvBuffer));

+  return Status;

+} // Tpm2NvUndefineSpaceSpecial()

+

 /**

   This command reads a value from an area in NV memory previously defined by TPM2_NV_DefineSpace().

 

diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h b/SecurityPkg/Include/Library/Tpm2CommandLib.h
index ee8eb622951c..8d7b4998d98d 100644
--- a/SecurityPkg/Include/Library/Tpm2CommandLib.h
+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
@@ -364,6 +364,28 @@ Tpm2NvUndefineSpace (
   IN      TPMS_AUTH_COMMAND         *AuthSession OPTIONAL

   );

 

+/**

+  This command removes an index from the TPM.

+

+  @param[in]  NvIndex             The NV Index.

+  @param[in]  IndexAuthSession    Auth session context for the Index auth/policy

+  @param[in]  PlatAuthSession     Auth session context for the Platform auth/policy

+

+  @retval EFI_SUCCESS             Operation completed successfully.

+  @retval EFI_NOT_FOUND           The command was returned successfully, but NvIndex is not found.

+  @retval EFI_UNSUPPORTED         Selected NvIndex does not support deletion through this call.

+  @retval EFI_SECURITY_VIOLATION  Deletion is not authorized by current policy session.

+  @retval EFI_INVALID_PARAMETER   The command was unsuccessful.

+  @retval EFI_DEVICE_ERROR        The command was unsuccessful.

+**/

+EFI_STATUS

+EFIAPI

+Tpm2NvUndefineSpaceSpecial (

+  IN      TPMI_RH_NV_INDEX          NvIndex,

+  IN      TPMS_AUTH_COMMAND         *IndexAuthSession OPTIONAL,

+  IN      TPMS_AUTH_COMMAND         *PlatAuthSession OPTIONAL

+  );

+

 /**

   This command reads a value from an area in NV memory previously defined by TPM2_NV_DefineSpace().

 

--
2.31.1.windows.1



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78450): https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F78450&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=CWxLwgp73z2XQEa%2FN77gsCwRF73xha0RZCKwcFTlrRE%3D&amp;reserved=0
Mute This Topic: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.io%2Fmt%2F84555713%2F1822150&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=IWQ6E4yP0ECt3oYLYQa%2BnddGfcQEDMgfASlcxRuda%2BQ%3D&amp;reserved=0
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Funsub&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=qor4Y5FZEH8ch0AEmWDbe97FIQk4V1qx7IURcTHzjAU%3D&amp;reserved=0 [brbarkel@...]
-=-=-=-=-=-=

 

 

 


回复: [edk2-devel] [PATCH v2] Xcode.md: Update instructions to work on modern macOS and Xcode versions

gaoliming
 

Rebecca:
I just merge it. Please check.

Thanks
Liming

-----邮件原件-----
发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Rebecca Cran
发送时间: 2021年8月13日 0:56
收件人: Andrew Fish <afish@apple.com>; edk2-devel-groups-io
<devel@edk2.groups.io>
主题: Re: [edk2-devel] [PATCH v2] Xcode.md: Update instructions to work on
modern macOS and Xcode versions

Could you push the commit please?

https://github.com/tianocore/tianocore.github.io/wiki/Xcode is still
showing the old content.


Thanks.
Rebecca Cran

On 7/22/2021 1:10 AM, Andrew Fish wrote:
Reviewed-by: Andrew Fish <afish@apple.com>

On Jul 21, 2021, at 4:56 PM, Rebecca Cran <rebecca@bsdio.com> wrote:

The existing instructions no longer work on macOS Big Sur and Xcode 12.5.
Update them to include for example using lldb instead of gdb, installing
XQuartz, and using modern names such as macOS instead of Mac OS X.

Also, since MacPorts is less popular these days, remove instructions for
installing tools with it, leaving steps for using Homebrew.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
---
Xcode.md | 172 +++++++++-----------
1 file changed, 78 insertions(+), 94 deletions(-)

diff --git a/Xcode.md b/Xcode.md
index 3d220a5..8af2653 100644
--- a/Xcode.md
+++ b/Xcode.md
@@ -1,43 +1,28 @@
-This page provides step-by-step instructions for setting up a
[http://www.tianocore.org/edk2/ EDK II] build environment on Mac OS X
systems using the Xcode development tools. These steps have been verified
with macOS Sierra Version 10.12.4
+This page provides step-by-step instructions for setting up a [EDK
II](https://github.com/tianocore/tianocore.github.io/wiki/EDK-II) build
environment on macOS systems using the Xcode development tools. These
steps have been verified with macOS Big Sur 11.3.1

-# Mac OS X Xcode
-Download the latest version of
[Xcode](https://developer.apple.com/xcode) (9.4.1 as of this writing) from the
Mac App Store. After installing Xcode, you will additionally need to install
the extra command-line tools. To do this, at a Terminal prompt, enter:
+# macOS Xcode
+Download the latest version of
[Xcode](https://developer.apple.com/xcode) (12.5 as of 2021-05-09) from the
Mac App Store. After installing Xcode, you will additionally need to install
the extra command-line tools. To do this, at a Terminal prompt, enter:
```
$ xcode-select --install
```
## Additional Development Tools
-While Xcode provides a full development environment as well as a suite of
different utilities, it does not provide all tools required for Tianocore
development. These tools can be provided in a number of ways, but the two
most popular ways come from [Brew](https://brew.sh) and
[MacPorts](https://www.macports.org/install.php). Installation information
is provided at the previous links.
-
-### MacPorts Tips
-* If you work behind a firewall and need to pass your network traffic
through a proxy, ensure you set the environment variable RSYNC_PROXY to
your http proxy in the form of `proxy.dns.name:port_number`.
- * Remember that `sudo` by default drops most environment variables.
Add the `-E` option to tell `sudo` to keep your environment variables.
-* When installing MacPorts packages, if you would like to build from
source like traditional [FreeBSD
Ports](https://en.wikipedia.org/wiki/FreeBSD_Ports) systems, add the `-s`
option to the command line. Otherwise, default behavior is to pull
precompiled packages.
+While Xcode provides a full development environment as well as a suite
of different utilities, it does not provide all tools required for TianoCore
development. These tools can be provided in a number of ways, but the
most popular way comes from [Brew](https://brew.sh). Installation
information is provided at the previous link.

## Install mtoc
The mtoc utility is required to convert from the macOS Mach-O image
format to the PE/COFF format as required by the UEFI specification.

### Brew Instructions
```
-$ brew install mtoc
-```
-## MacPorts Instructions
-```
-$ sudo port install cctools
+$ brew install mtoc
```
-By default, this will install `mtoc` at `/opt/local/bin/mtoc`.
# Install NASM

-The assembler used for EDK II builds is Netwide Assembler (NASM). The
latest version of NASM is available from http://www.nasm.us/.
+The assembler used for EDK II builds is Netwide Assembler (NASM). The
latest version of NASM is available from https://nasm.us/.
## Brew Instructions
```
$ brew install nasm
$ brew upgrade nasm
```
-## MacPorts Instructions
-```
-$ sudo port install nasm
-```
-By default this installs `nasm` at `/opt/local/bin/nasm`.

# Install ACPI Compiler

@@ -47,26 +32,20 @@ In order to support EDK II firmware builds, the
latest version of the ASL compil
$ brew install acpica
$ brew upgrade acpica
```
-## MacPorts Install
-```
-$ sudo port install acpica
-```
-By default this installs `iasl` at `/opt/local/bin/iasl`
+
+# Install XQuartz
+
+The EmulatorPkg requires headers from X11, which are provided by the
XQuartz project. Install it from https://www.xquartz.org/.

# Install QEMU Emulator

-On order to support running the OVMF platforms from the OvmfPkg, the
QEMU emulator from http://www.qemu.org/ must be installed.
+On order to support running the OVMF platforms from the OvmfPkg, the
QEMU emulator from https://www.qemu.org/ must be installed.

## Brew Install
```
$ brew install qemu
$ brew upgrade qemu
```
-## MacPorts Install
-```
-$ sudo port install qemu
-```
-By default qemu is installed in `/opt/local/bin`.
## Update PATH environment variable

Tools installed using the `brew` command are placed in `/usr/local/bin`.
The `PATH` environment variable must be updated so the newly installed tools
are used instead of older pre-installed tools.
@@ -75,11 +54,6 @@ Tools installed using the `brew` command are
placed in `/usr/local/bin`. The `P
export PATH=/usr/local/bin:$PATH
```

-Tools installed using the `port` should automatically be in your shell's PATH.
If not, you can manually set it by:
-```
-export PATH=/opt/local/bin:$PATH
-```
-
# Verify tool versions

Run the following commands to verify the versions of the tools that have
been installed.
@@ -97,84 +71,94 @@ Pick the location you want to down load the files
to and `cd` to that directory:
```
cd ~/work
git clone https://github.com/tianocore/edk2.git
+cd edk2
+git submodule update --init
```

-# Build from Command Line/Debug with gdb
+# Build from Command Line/Debug with lldb

-Build the UnixPkg:
+Build the EmulatorPkg:

```
-cd ~/work/edk2/UnixPkg
+cd ~/work/edk2/EmulatorPkg
./build.sh
```

-Debug the UnixPkg
+Debug the EmulatorPkg

```
./build.sh run

-Building from: /Users/fish/work/edk2
+Initializing workspace
+/Users/bcran/src/edk2/BaseTools
+Loading previous configuration from
/Users/bcran/src/edk2/Conf/BuildEnv.sh
+Using EDK2 in-source Basetools
+WORKSPACE: /Users/bcran/src/edk2
+EDK_TOOLS_PATH: /Users/bcran/src/edk2/BaseTools
+CONF_PATH: /Users/bcran/src/edk2/Conf
using prebuilt tools
-Reading symbols for shared libraries ...... done
-Breakpoint 1 at 0xce84: file
/Users/fish/work/edk2/UnixPkg/Sec/SecMain.c, line 1070.
-(gdb)
-```
-
-Type `r` at the gdb prompt (don't forget to hit carriage return) to boot the
emulator. Ctrl-c in the terminal window will break in to gdb. bt is the stack
backtrace command:
-
-```
-^C
-Program received signal SIGINT, Interrupt.
-0x92423806 in __semwait_signal ()
-(gdb) bt
-#0 0x92423806 in __semwait_signal ()
-#1 0x9244f441 in nanosleep$UNIX2003 ()
-#2 0x0000b989 in msSleep (Milliseconds=0x14) at
/Users/fish/work/Migration/edk2/UnixPkg/Sec/UnixThunk.c:102
-#3 0x0000acf5 in UgaCheckKey (UgaIo=0x2078d0) at
/Users/fish/work/Migration/edk2/UnixPkg/Sec/UgaX11.c:380
-#4 0x0000d8b7 in _GasketUintn () at
/Users/fish/work/Migration/edk2/Build/Unix/DEBUG_XCODE32/IA32/UnixPk
g/Sec/SecMain/OUTPUT/Ia32/Gasket.iii:63
-#5 0x0000d801 in GasketUgaCheckKey (UgaIo=0x2078d0) at
/Users/fish/work/Migration/edk2/UnixPkg/Sec/Gasket.c:406
-#6 0x454a25fb in UnixUgaSimpleTextInWaitForKey (Event=0x45603610,
Context=0x45382110) at
/Users/fish/work/Migration/edk2/UnixPkg/UnixUgaDxe/UnixUgaInput.c:169
-#7 0x45faad3a in CoreDispatchEventNotifies (Priority=0x10) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:1
85
-#8 0x45faa639 in CoreRestoreTpl (NewTpl=0x4) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Event/Tpl.c:114
-#9 0x45f9f197 in CoreReleaseLock (Lock=0x45fb1024) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Library/Library.
c:102
-#10 0x45faabd6 in CoreReleaseEventLock () at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:1
13
-#11 0x45fab26c in CoreCheckEvent (UserEvent=0x45603210) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:5
62
-#12 0x45fab2db in CoreWaitForEvent (NumberOfEvents=0x1,
UserEvents=0x45f94cc4, UserIndex=0x45f94cb8) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:6
21
-#13 0x49ce9557 in ?? ()
-#14 0x49cf0344 in ?? ()
-#15 0x49ce3bc2 in ?? ()
-#16 0x49ce3ae1 in ?? ()
-#17 0x45f9e4e3 in CoreStartImage (ImageHandle=0x49e31e10,
ExitDataSize=0x45f94eec, ExitData=0x45f94ee8) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/Image/Image.c:
1260
-#18 0x4550cccc in BdsLibBootViaBootOption (Option=0x49ffa110,
DevicePath=0x49ffa190, ExitDataSize=0x45f94eec, ExitData=0x45f94ee8) at
/Users/fish/work/Migration/edk2/IntelFrameworkModulePkg/Library/Generi
cBdsLib/BdsBoot.c:382
-#19 0x455252a9 in BdsBootDeviceSelect () at
/Users/fish/work/Migration/edk2/IntelFrameworkModulePkg/Universal/Bds
Dxe/BdsEntry.c:214
-#20 0x455255bc in BdsEntry (This=0x4552d01c) at
/Users/fish/work/Migration/edk2/IntelFrameworkModulePkg/Universal/Bds
Dxe/BdsEntry.c:356
-#21 0x45fad7e8 in DxeMain (HobStart=0x45f70010) at
/Users/fish/work/Migration/edk2/MdeModulePkg/Core/Dxe/DxeMain/DxeM
ain.c:425
-#22 0x45fadd1d in ProcessModuleEntryPointList (HobStart=0x42020000)
at
/Users/fish/work/Migration/edk2/Build/Unix/DEBUG_XCODE32/IA32/MdeM
odulePkg/Core/Dxe/DxeMain/DEBUG/AutoGen.c:287
-#23 0x45f97773 in _ModuleEntryPoint (HobStart=0x42020000) at
/Users/fish/work/Migration/edk2/MdePkg/Library/DxeCoreEntryPoint/DxeCo
reEntryPoint.c:54
-(gdb)
+(lldb) target create "./Host"
+Current executable set to
'/Users/bcran/src/edk2/Build/EmulatorX64/DEBUG_XCODE5/X64/Host'
(x86_64).
+(lldb) command script import
/Users/bcran/src/edk2/EmulatorPkg/Unix/lldbefi.py
+Type r to run emulator. SecLldbScriptBreak armed. EFI modules should
now get source level debugging in the emulator.
+(lldb) script lldb.debugger.SetAsync(True)
+(lldb) run
+Process 12155 launched:
'/Users/bcran/src/edk2/Build/EmulatorX64/DEBUG_XCODE5/X64/Host'
(x86_64)
+
+EDK II UNIX Host Emulation Environment from
http://www.tianocore.org/edk2/
+ BootMode 0x00
+ OS Emulator passing in 128 KB of temp RAM at 0x102000000 to SEC
+ FD loaded from ../FV/FV_RECOVERY.fd at 0x102020000 contains SEC
Core
+...
+```
+
+Type `process interrupt` at the lldb prompt (don't forget to hit carriage
return) to pause execution. Ctrl-c in the terminal window will quit lldb. `bt` is
the stack backtrace command:
+
+```
+Process 12420 stopped
+* thread #1, queue = 'com.apple.main-thread', stop reason = signal
SIGSTOP
+ frame #0: 0x00007fff2033cc22
libsystem_kernel.dylib:__semwait_signal() + 10
+libsystem_kernel.dylib`__semwait_signal:
+-> 0x7fff2033cc22 <+10>: jae 0x7fff2033cc2c ;
<+20>
+ 0x7fff2033cc24 <+12>: movq %rax, %rdi
+ 0x7fff2033cc27 <+15>: jmp 0x7fff2033b72d ;
cerror
+ 0x7fff2033cc2c <+20>: retq
+Target 0: (Host) stopped.
+(lldb) bt
+* thread #1, queue = 'com.apple.main-thread', stop reason = signal
SIGSTOP
+ * frame #0: 0x00007fff2033cc22
libsystem_kernel.dylib:__semwait_signal() + 10
+ frame #1: 0x00007fff202bcc2a libsystem_c.dylib:nanosleep() + 196
+ frame #2: 0x0000000100005e55 Host:SecCpuSleep() + 37 at
/Users/bcran/src/edk2/EmulatorPkg/Unix/Host/EmuThunk.c:334
+ frame #3: 0x000000010000e96e Host:GasketSecCpuSleep() + 11 at
/Users/bcran/src/edk2/Build/EmulatorX64/DEBUG_XCODE5/X64/EmulatorPk
g/Unix/Host/Host/OUTPUT/X64/Gasket.iiii:283
+ frame #4: 0x0000000106f985e9
DxeCore.dll:CoreDispatchEventNotifies() + 264 at
/Users/bcran/src/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:194
+ frame #5: 0x0000000106f97fce DxeCore.dll:CoreRestoreTpl() + 227
at /Users/bcran/src/edk2/MdeModulePkg/Core/Dxe/Event/Tpl.c:131
+ frame #6: 0x0000000106f989db DxeCore.dll:CoreSignalEvent() + 111
at /Users/bcran/src/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:566
+ frame #7: 0x0000000106f98b01 DxeCore.dll:CoreWaitForEvent() +
94 at /Users/bcran/src/edk2/MdeModulePkg/Core/Dxe/Event/Event.c:707
+ frame #8: 0x0000000113e8e54c BdsDxe.dll:BdsWaitForSingleEvent()
+ 127 at
/Users/bcran/src/edk2/MdeModulePkg/Universal/BdsDxe/BdsEntry.c:250
+ frame #9: 0x0000000113e8e70b BdsDxe.dll:BdsWait() + 215 at
/Users/bcran/src/edk2/MdeModulePkg/Universal/BdsDxe/BdsEntry.c:328
+ frame #10: 0x0000000113e8dffb BdsDxe.dll:BdsEntry() + 2612 at
/Users/bcran/src/edk2/MdeModulePkg/Universal/BdsDxe/BdsEntry.c:1012
+ frame #11: 0x0000000106f9bbd6 DxeCore.dll:DxeMain() + 2791 at
/Users/bcran/src/edk2/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c:551
+ frame #12: 0x0000000106f9ed8f DxeCore.dll:_ModuleEntryPoint() +
20 at
/Users/bcran/src/edk2/MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoi
nt.c:48
+ frame #13: 0x0000000106fdd02f DxeIpl.dll:InternalSwitchStack() +
15
+ frame #14: 0x0000000106fdc0b6 DxeIpl.dll:HandOffToDxeCore() +
546 at
/Users/bcran/src/edk2/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.
c:126
+ frame #15: 0x0000000106fda78a DxeIpl.dll:DxeLoadCore() + 1354 at
/Users/bcran/src/edk2/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c:449
+ frame #16: 0x0000000106ff1d7c
+ frame #17: 0x00000001020255c6 PeiCore.dll:PeiCore() + 1982 at
/Users/bcran/src/edk2/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c:331
+ frame #18: 0x000000010202a82c
PeiCore.dll:PeiCheckAndSwitchStack() + 1171 at
/Users/bcran/src/edk2/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c:84
2
+ frame #19: 0x000000010202b853 PeiCore.dll:PeiDispatcher() + 1206
at
/Users/bcran/src/edk2/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c:16
09
+(lldb)
+
```

# Build and Debug from Xcode
-To build from the Xcode GUI open
~/work/edk2/UnixPkg/Xcode/xcode_project/xcode_project.xcodeproj. You
can build, clean, and source level debug from the Xcode GUI. You can hit
the Build and Debug button to start the build process. You need to need to hit
command-shift-B to show the output of the build. Click Pause to break into
the debugger.
-
-[[File:Xcode.jpg]]
+To build from the Xcode GUI open
~/work/edk2/EmulatorPkg/Unix/Xcode/xcode_project64/xcode_project.xcod
eproj. You can build, clean, and source level debug from the Xcode GUI. You
can hit the Build and Debug button to start the build process. You need to
need to hit command-shift-B to show the output of the build. Click Pause to
break into the debugger.

The stack trace contains items that show as ?? since the default shell is
checked in as a binary. `nanosleep$UNIX2003` and `__semwait_signal` are
POSIX library calls and you do not get C source debug with these symbols.

-# Source Level Debug Shell
-
-It is possible to get source level debug for the EFI Shell by pulling these
projects from source control and building them.
-
-Instructions for building and hooking in the shell are located in the
[https://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Gcc-shel
l gcc-shell] project.
-
-Please note the gcc-shell and UnixPkg build separately, so if you update
shell code you need to build the shell to see the changes. The following screen
shot shows being able to source level debug the shell:
-
-[[File:Xcode_good.jpg]]
+*Note* The Xcode project is currently (as of 2021-05-09) broken.

# See Also

-* [[Step-by-step instructions]]
-
# Continue with common instructions

-The [remaining instructions](../Common-instructions) are common for
most UNIX-like systems.
+The [remaining
instructions](https://github.com/tianocore/tianocore.github.io/wiki/Common
-instructions-for-Unix) are common for most UNIX-like systems.
--
2.30.1 (Apple Git-130)










Re: [PATCH] MdeModulePkg PCD: Reinstall PCD service PPIS when memory available

Dandan Bi
 

Hi Greg,

I have added all the R-B for this patch and create a pull request for it.
https://github.com/tianocore/edk2/pull/1898



Thanks,
Dandan

-----Original Message-----
From: Yeh, GregX <gregx.yeh@intel.com>
Sent: Thursday, August 12, 2021 3:22 PM
To: devel@edk2.groups.io
Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
Bi, Dandan <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH] MdeModulePkg PCD: Reinstall PCD service PPIS when
memory available

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

After PciSegmentLib using Dynamic PCD for Pcie base address such long delay
found in FSP. The root cause is some of the PCD service PPIs not shadowed
to memory and flash cache may have been disabled in NotifyPhase stage.
Solution is to shadow all PCD service PPIs to memory.

Signed-off-by: GregX Yeh <gregx.yeh@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
---
MdeModulePkg/Universal/PCD/Pei/Pcd.c | 71
+++++++++++++++++++++++++++-
1 file changed, 70 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
index 9c6346924f..f31e0be35f 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
@@ -1,7 +1,7 @@
/** @file All Pcd Ppi services are implemented here. -Copyright (c) 2006 -
2018, Intel Corporation. All rights reserved.<BR>+Copyright (c) 2006 - 2021,
Intel Corporation. All rights reserved.<BR> (C) Copyright 2016 Hewlett
Packard Enterprise Development LP<BR> SPDX-License-Identifier: BSD-2-
Clause-Patent @@ -339,6 +339,75 @@ PcdPeimInit (
{ EFI_STATUS Status; + Status = PeiServicesRegisterForShadow
(FileHandle);+ if (Status == EFI_ALREADY_STARTED) {+ //+ // This is now
starting in memory, the second time starting.+ //+
EFI_PEI_PPI_DESCRIPTOR *OldPpiList;+ EFI_PEI_PPI_DESCRIPTOR
*OldPpiList2;+ VOID *Ppi;+ VOID *Ppi2;++ OldPpiList = NULL;+ Status =
PeiServicesLocatePpi (+ &gPcdPpiGuid,+ 0,+
&OldPpiList,+ &Ppi+ );+ ASSERT_EFI_ERROR (Status);++ if
(OldPpiList != NULL) {+ Status = PeiServicesReInstallPpi (OldPpiList,
&mPpiList[0]);+ ASSERT_EFI_ERROR (Status);+ }++ OldPpiList2 = NULL;+
Status = PeiServicesLocatePpi (+ &gGetPcdInfoPpiGuid,+ 0,+
&OldPpiList2,+ &Ppi2+ );+ ASSERT_EFI_ERROR (Status);++ if
(OldPpiList2 != NULL) {+ Status = PeiServicesReInstallPpi (OldPpiList2,
&mPpiList2[0]);+ ASSERT_EFI_ERROR (Status);+ }++ OldPpiList = NULL;+
Status = PeiServicesLocatePpi (+ &gEfiPeiPcdPpiGuid,+ 0,+
&OldPpiList,+ &Ppi+ );+ ASSERT_EFI_ERROR (Status);++ if
(OldPpiList != NULL) {+ Status = PeiServicesReInstallPpi (OldPpiList,
&mPpiList[1]);+ ASSERT_EFI_ERROR (Status);+ }++ OldPpiList2 = NULL;+
Status = PeiServicesLocatePpi (+ &gEfiGetPcdInfoPpiGuid,+ 0,+
&OldPpiList2,+ &Ppi2+ );+ ASSERT_EFI_ERROR (Status);++ if
(OldPpiList2 != NULL) {+ Status = PeiServicesReInstallPpi (OldPpiList2,
&mPpiList2[1]);+ ASSERT_EFI_ERROR (Status);+ }++ return Status;+ }+
BuildPcdDatabase (FileHandle); //--
2.32.0.windows.1


Re: [PATCH 1/1] MdeModulePkg/Console: Improve encoding of box drawing characters

Wu, Hao A
 

Add Console and Graphics modules reviewers.

 

Best Regards,

Hao Wu

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu, Hao A
Sent: Friday, August 13, 2021 9:19 AM
To: devel@edk2.groups.io; Caden Kline <cadenkline9@...>
Subject: Re: [edk2-devel] [PATCH 1/1] MdeModulePkg/Console: Improve encoding of box drawing characters

 

Reposting to the mailing list.

 

Best Regards,

Hao Wu

 

From: Caden Kline <cadenkline9@...>
Sent: Friday, August 13, 2021 12:32 AM
To: Wu, Hao A <hao.a.wu@...>
Subject: Re: [PATCH 1/1] MdeModulePkg/Console: Improve encoding of box drawing characters

 

For testing I just ran a program that printed out the impacted characters and checked it against different terminals, putty for windows, xtrem and tillix for linux, and standard mac os terminal with all the effected terminal types.   

 

On Mon, Aug 9, 2021 at 1:57 AM Wu, Hao A <hao.a.wu@...> wrote:

Sorry Zhichao and Ray, could you please help to check if you have comments for this patch. Thanks in advance.

Hello Caden Kline, could you help to provide the information on what kind of unit test was done for this patch?

Some inline comments for ONLY coding style issues:


> -----Original Message-----
> From: Caden Kline <cadenkline9@...>
> Sent: Friday, July 30, 2021 10:45 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@...>; Wu, Hao A <hao.a.wu@...>;
> Gao, Zhichao <zhichao.gao@...>; Ni, Ray <ray.ni@...>
> Subject: [PATCH 1/1] MdeModulePkg/Console: Improve encoding of box
> drawing characters
>
> Improved encoding of box drawing characters for different terminal types.
> This includes Dec special graphics mode and more utf8.
>
> Cc: Jian J Wang <jian.j.wang@...>
> Cc: Hao A Wu <hao.a.wu@...>
> Cc: Zhichao Gao <zhichao.gao@...>
> Cc: Ray Ni <ray.ni@...>
> Signed-off-by: Caden Kline <cadenkline9@...>
> ---
>  .../Universal/Console/TerminalDxe/Terminal.h  |  24 +-
>  .../Universal/Console/TerminalDxe/Ansi.c      |   2 +-
>  .../Console/TerminalDxe/TerminalConOut.c      | 322 ++++++++++++++----
>  3 files changed, 269 insertions(+), 79 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> index 360e58e84743..83c3ea94a042 100644
> --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> @@ -122,7 +122,10 @@ typedef struct {
>    EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL   SimpleInputEx;
>
>    LIST_ENTRY                          NotifyList;
>
>    EFI_EVENT                           KeyNotifyProcessEvent;
>
> +  BOOLEAN                             DecSpecialGraphicsMode;
>
>  } TERMINAL_DEV;
>
> +// This the lenth the escape squences for entering and exiting Dec Special


Typo: lenth -> length, squences -> sequences

Also, please help to update the comments to style:
//
// This the length the escape sequences for entering and exiting Dec Special
//



> Graphics Mode
>
> +#define LENGTH_DEC_ESCAPE                 0x03
>
>
>
>  #define INPUT_STATE_DEFAULT               0x00
>
>  #define INPUT_STATE_ESC                   0x01
>
> @@ -169,6 +172,7 @@ typedef struct {
>    UINT16  Unicode;
>
>    CHAR8   PcAnsi;
>
>    CHAR8   Ascii;
>
> +  CHAR8   DecSpecialGraphics;
>
>  } UNICODE_TO_CHAR;
>
>
>
>  //
>
> @@ -1367,20 +1371,22 @@ Utf8ToUnicode (
>  /**
>
>    Detects if a Unicode char is for Box Drawing text graphics.
>
>
>
> -  @param  Graphic      Unicode char to test.
>
> -  @param  PcAnsi       Optional pointer to return PCANSI equivalent of
>
> -                       Graphic.
>
> -  @param  Ascii        Optional pointer to return ASCII equivalent of
>
> -                       Graphic.
>
> -
>
> -  @retval TRUE         If Graphic is a supported Unicode Box Drawing character.
>
> +  @param  Graphic             Unicode char to test.
>
> +  @param  PcAnsi              Optional pointer to return PCANSI equivalent of
>
> +                              Graphic.
>
> +  @param  Ascii               Optional pointer to return ASCII equivalent of
>
> +                              Graphic.
>
> +  @param  DecSpecialGraphics  Optional pointer to return Dec Special
> Graphics equivalent of
>
> +                              Graphic.
>
> +  @retval TRUE                If Graphic is a supported Unicode Box Drawing
> character.
>
>
>
>  **/
>
>  BOOLEAN
>
>  TerminalIsValidTextGraphics (
>
>    IN  CHAR16  Graphic,
>
> -  OUT CHAR8   *PcAnsi, OPTIONAL
>
> -  OUT CHAR8   *Ascii OPTIONAL
>
> +  OUT CHAR8   *PcAnsi,            OPTIONAL
>
> +  OUT CHAR8   *Ascii,             OPTIONAL
>
> +  OUT CHAR8   *DecSpecialGraphics OPTIONAL
>
>    );
>
>
>
>  /**
>
> diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
> b/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
> index f117d90b9de3..5ae5a4f0212e 100644
> --- a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
> +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
> @@ -63,7 +63,7 @@ AnsiTestString (
>
>
>      if ( !(TerminalIsValidAscii (*WString) ||
>
>          TerminalIsValidEfiCntlChar (*WString) ||
>
> -        TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL) )) {
>
> +        TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL, NULL) )) {
>
>
>
>        return EFI_UNSUPPORTED;
>
>      }
>
> diff --git
> a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
> b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
> index aae470e9562c..1c22ed426715 100644
> --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
> +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
> @@ -16,61 +16,59 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  //
>
>  //
>
>  UNICODE_TO_CHAR  UnicodeToPcAnsiOrAscii[] = {
>
> -  { BOXDRAW_HORIZONTAL,                 0xc4, L'-' },
>
> -  { BOXDRAW_VERTICAL,                   0xb3, L'|' },
>
> -  { BOXDRAW_DOWN_RIGHT,                 0xda, L'/' },
>
> -  { BOXDRAW_DOWN_LEFT,                  0xbf, L'\\' },
>
> -  { BOXDRAW_UP_RIGHT,                   0xc0, L'\\' },
>
> -  { BOXDRAW_UP_LEFT,                    0xd9, L'/' },
>
> -  { BOXDRAW_VERTICAL_RIGHT,             0xc3, L'|' },
>
> -  { BOXDRAW_VERTICAL_LEFT,              0xb4, L'|' },
>
> -  { BOXDRAW_DOWN_HORIZONTAL,            0xc2, L'+' },
>
> -  { BOXDRAW_UP_HORIZONTAL,              0xc1, L'+' },
>
> -  { BOXDRAW_VERTICAL_HORIZONTAL,        0xc5, L'+' },
>
> -  { BOXDRAW_DOUBLE_HORIZONTAL,          0xcd, L'-' },
>
> -  { BOXDRAW_DOUBLE_VERTICAL,            0xba, L'|' },
>
> -  { BOXDRAW_DOWN_RIGHT_DOUBLE,          0xd5, L'/' },
>
> -  { BOXDRAW_DOWN_DOUBLE_RIGHT,          0xd6, L'/' },
>
> -  { BOXDRAW_DOUBLE_DOWN_RIGHT,          0xc9, L'/' },
>
> -  { BOXDRAW_DOWN_LEFT_DOUBLE,           0xb8, L'\\' },
>
> -  { BOXDRAW_DOWN_DOUBLE_LEFT,           0xb7, L'\\' },
>
> -  { BOXDRAW_DOUBLE_DOWN_LEFT,           0xbb, L'\\' },
>
> -  { BOXDRAW_UP_RIGHT_DOUBLE,            0xd4, L'\\' },
>
> -  { BOXDRAW_UP_DOUBLE_RIGHT,            0xd3, L'\\' },
>
> -  { BOXDRAW_DOUBLE_UP_RIGHT,            0xc8, L'\\' },
>
> -  { BOXDRAW_UP_LEFT_DOUBLE,             0xbe, L'/' },
>
> -  { BOXDRAW_UP_DOUBLE_LEFT,             0xbd, L'/' },
>
> -  { BOXDRAW_DOUBLE_UP_LEFT,             0xbc, L'/' },
>
> -  { BOXDRAW_VERTICAL_RIGHT_DOUBLE,      0xc6, L'|' },
>
> -  { BOXDRAW_VERTICAL_DOUBLE_RIGHT,      0xc7, L'|' },
>
> -  { BOXDRAW_DOUBLE_VERTICAL_RIGHT,      0xcc, L'|' },
>
> -  { BOXDRAW_VERTICAL_LEFT_DOUBLE,       0xb5, L'|' },
>
> -  { BOXDRAW_VERTICAL_DOUBLE_LEFT,       0xb6, L'|' },
>
> -  { BOXDRAW_DOUBLE_VERTICAL_LEFT,       0xb9, L'|' },
>
> -  { BOXDRAW_DOWN_HORIZONTAL_DOUBLE,     0xd1, L'+' },
>
> -  { BOXDRAW_DOWN_DOUBLE_HORIZONTAL,     0xd2, L'+' },
>
> -  { BOXDRAW_DOUBLE_DOWN_HORIZONTAL,     0xcb, L'+' },
>
> -  { BOXDRAW_UP_HORIZONTAL_DOUBLE,       0xcf, L'+' },
>
> -  { BOXDRAW_UP_DOUBLE_HORIZONTAL,       0xd0, L'+' },
>
> -  { BOXDRAW_DOUBLE_UP_HORIZONTAL,       0xca, L'+' },
>
> -  { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+' },
>
> -  { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+' },
>
> -  { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+' },
>
> +  { BOXDRAW_HORIZONTAL,                 0xc4, L'-',  0x71 },
>
> +  { BOXDRAW_VERTICAL,                   0xb3, L'|',  0x78 },
>
> +  { BOXDRAW_DOWN_RIGHT,                 0xda, L'/',  0x6c },
>
> +  { BOXDRAW_DOWN_LEFT,                  0xbf, L'\\', 0x6b },
>
> +  { BOXDRAW_UP_RIGHT,                   0xc0, L'\\', 0x6d },
>
> +  { BOXDRAW_UP_LEFT,                    0xd9, L'/',  0x6a },
>
> +  { BOXDRAW_VERTICAL_RIGHT,             0xc3, L'|',  0x74 },
>
> +  { BOXDRAW_VERTICAL_LEFT,              0xb4, L'|',  0x75 },
>
> +  { BOXDRAW_DOWN_HORIZONTAL,            0xc2, L'+',  0x77 },
>
> +  { BOXDRAW_UP_HORIZONTAL,              0xc1, L'+',  0x76 },
>
> +  { BOXDRAW_VERTICAL_HORIZONTAL,        0xc5, L'+',  0x6e },
>
> +  { BOXDRAW_DOUBLE_HORIZONTAL,          0xcd, L'-',  0x71 },
>
> +  { BOXDRAW_DOUBLE_VERTICAL,            0xba, L'|',  0x78 },
>
> +  { BOXDRAW_DOWN_RIGHT_DOUBLE,          0xd5, L'/',  0x6c },
>
> +  { BOXDRAW_DOWN_DOUBLE_RIGHT,          0xd6, L'/',  0x6c },
>
> +  { BOXDRAW_DOUBLE_DOWN_RIGHT,          0xc9, L'/',  0x6c },
>
> +  { BOXDRAW_DOWN_LEFT_DOUBLE,           0xb8, L'\\', 0x6b },
>
> +  { BOXDRAW_DOWN_DOUBLE_LEFT,           0xb7, L'\\', 0x6b },
>
> +  { BOXDRAW_DOUBLE_DOWN_LEFT,           0xbb, L'\\', 0x6b },
>
> +  { BOXDRAW_UP_RIGHT_DOUBLE,            0xd4, L'\\', 0x6d },
>
> +  { BOXDRAW_UP_DOUBLE_RIGHT,            0xd3, L'\\', 0x6d },
>
> +  { BOXDRAW_DOUBLE_UP_RIGHT,            0xc8, L'\\', 0x6d },
>
> +  { BOXDRAW_UP_LEFT_DOUBLE,             0xbe, L'/',  0x6a },
>
> +  { BOXDRAW_UP_DOUBLE_LEFT,             0xbd, L'/',  0x6a },
>
> +  { BOXDRAW_DOUBLE_UP_LEFT,             0xbc, L'/',  0x6a },
>
> +  { BOXDRAW_VERTICAL_RIGHT_DOUBLE,      0xc6, L'|',  0x74 },
>
> +  { BOXDRAW_VERTICAL_DOUBLE_RIGHT,      0xc7, L'|',  0x74 },
>
> +  { BOXDRAW_DOUBLE_VERTICAL_RIGHT,      0xcc, L'|',  0x74 },
>
> +  { BOXDRAW_VERTICAL_LEFT_DOUBLE,       0xb5, L'|',  0x75 },
>
> +  { BOXDRAW_VERTICAL_DOUBLE_LEFT,       0xb6, L'|',  0x75 },
>
> +  { BOXDRAW_DOUBLE_VERTICAL_LEFT,       0xb9, L'|',  0x75 },
>
> +  { BOXDRAW_DOWN_HORIZONTAL_DOUBLE,     0xd1, L'+',  0x77 },
>
> +  { BOXDRAW_DOWN_DOUBLE_HORIZONTAL,     0xd2, L'+',  0x77 },
>
> +  { BOXDRAW_DOUBLE_DOWN_HORIZONTAL,     0xcb, L'+',  0x77 },
>
> +  { BOXDRAW_UP_HORIZONTAL_DOUBLE,       0xcf, L'+',  0x76 },
>
> +  { BOXDRAW_UP_DOUBLE_HORIZONTAL,       0xd0, L'+',  0x76 },
>
> +  { BOXDRAW_DOUBLE_UP_HORIZONTAL,       0xca, L'+',  0x76 },
>
> +  { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+',  0x6e },
>
> +  { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+',  0x6e },
>
> +  { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+',  0x6e },
>
>
>
> -  { BLOCKELEMENT_FULL_BLOCK,            0xdb, L'*' },
>
> -  { BLOCKELEMENT_LIGHT_SHADE,           0xb0, L'+' },
>
> +  { BLOCKELEMENT_FULL_BLOCK,            0xdb, L'*',  0x61 },
>
> +  { BLOCKELEMENT_LIGHT_SHADE,           0xb0, L'+',  0x61 },
>
>
>
> -  { GEOMETRICSHAPE_UP_TRIANGLE,         '^', L'^' },
>
> -  { GEOMETRICSHAPE_RIGHT_TRIANGLE,      '>', L'>' },
>
> -  { GEOMETRICSHAPE_DOWN_TRIANGLE,       'v', L'v' },
>
> -  { GEOMETRICSHAPE_LEFT_TRIANGLE,       '<', L'<' },
>
> +  { GEOMETRICSHAPE_UP_TRIANGLE,         '^',  L'^',  L'^' },
>
> +  { GEOMETRICSHAPE_RIGHT_TRIANGLE,      '>',  L'>',  L'>' },
>
> +  { GEOMETRICSHAPE_DOWN_TRIANGLE,       'v',  L'v',  L'v' },
>
> +  { GEOMETRICSHAPE_LEFT_TRIANGLE,       '<',  L'<',  L'<' },
>
>
>
> -  { ARROW_LEFT,                         '<', L'<' },
>
> -  { ARROW_UP,                           '^', L'^' },
>
> -  { ARROW_RIGHT,                        '>', L'>' },
>
> -  { ARROW_DOWN,                         'v', L'v' },
>
> -
>
> -  { 0x0000,                             0x00, L'\0' }
>
> +  { ARROW_LEFT,                         '<',  L'<',  L'<' },
>
> +  { ARROW_UP,                           '^',  L'^',  L'^' },
>
> +  { ARROW_RIGHT,                        '>',  L'>',  L'>' },
>
> +  { ARROW_DOWN,                         'v',  L'v',  L'v' },
>
>  };
>
>
>
>  CHAR16 mSetModeString[]            = { ESC, '[', '=', '3', 'h', 0 };
>
> @@ -80,6 +78,8 @@ CHAR16 mSetCursorPositionString[]  = { ESC, '[', '0', '0', ';',
> '0', '0', 'H', 0
>  CHAR16 mCursorForwardString[]      = { ESC, '[', '0', '0', 'C', 0 };
>
>  CHAR16 mCursorBackwardString[]     = { ESC, '[', '0', '0', 'D', 0 };
>
>
>
> +CHAR8  SetDecModeString[]          = {ESC, 0x28, 0x30};
>
> +CHAR8  ExitDecModeString[]         = {ESC, 0x28, 0x42};
>
>  //
>
>  // Body of the ConOut functions
>
>  //
>
> @@ -183,16 +183,19 @@ TerminalConOutOutputString (
>    EFI_STATUS                  Status;
>
>    UINT8                       ValidBytes;
>
>    CHAR8                       CrLfStr[2];
>
> +  CHAR8                       DecChar;
>
> +  UINTN                       ModeSwitchLength;
>
>    //
>
>    //  flag used to indicate whether condition happens which will cause
>
>    //  return EFI_WARN_UNKNOWN_GLYPH
>
>    //
>
>    BOOLEAN                     Warning;
>
>
>
> -  ValidBytes  = 0;
>
> -  Warning     = FALSE;
>
> -  AsciiChar   = 0;
>
> -
>
> +  ValidBytes       = 0;
>
> +  Warning          = FALSE;
>
> +  AsciiChar        = 0;
>
> +  DecChar          = 0;
>
> +  ModeSwitchLength = LENGTH_DEC_ESCAPE;
>
>    //
>
>    //  get Terminal device data structure pointer.
>
>    //
>
> @@ -217,17 +220,136 @@ TerminalConOutOutputString (
>    for (; *WString != CHAR_NULL; WString++) {
>
>
>
>      switch (TerminalDevice->TerminalType) {
>
> -
>
>      case TerminalTypePcAnsi:
>
> -    case TerminalTypeVt100:
>
> -    case TerminalTypeVt100Plus:
>
> -    case TerminalTypeTtyTerm:
>
> -    case TerminalTypeLinux:
>
> +      if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar,
> NULL)) {
>
> +        //
>
> +        // If it's not a graphic character convert Unicode to ASCII.
>
> +        //
>
> +          GraphicChar = (CHAR8)*WString;


Please help to fix the space indent (extra spaces) here to keep it aligned with the contexts.


>
> +
>
> +        if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntlChar
> (GraphicChar))) {
>
> +          //
>
> +          // when this driver use the OutputString to output control string,
>
> +          // TerminalDevice->OutputEscChar is set to let the Esc char
>
> +          // to be output to the terminal emulation software.
>
> +          //
>
> +          if ((GraphicChar == 27) && TerminalDevice->OutputEscChar) {
>
> +            GraphicChar = 27;
>
> +          } else {
>
> +            GraphicChar = '?';
>
> +            Warning     = TRUE;
>
> +          }
>
> +        }
>
> +
>
> +        AsciiChar = GraphicChar;
>
> +      }
>
> +      Length = 1;
>
> +      Status = TerminalDevice->SerialIo->Write (
>
> +                                          TerminalDevice->SerialIo,
>
> +                                          &Length,
>
> +                                          &GraphicChar
>
> +                                          );


Please help to add an extra space for the above 3 lines for space indent coding style.


>
> +
>
> +      if (EFI_ERROR (Status)) {
>
> +        goto OutputError;
>
> +      }
>
> +
>
> +      break;
>
>      case TerminalTypeXtermR6:
>
> -    case TerminalTypeVt400:
>
>      case TerminalTypeSCO:
>


For the below added codes (for case TerminalTypeXtermR6 & TerminalTypeSCO), please help to fix below coding style issues:
a) Codes within a 'case' or 'if-else' statement is recommended to add 2 spaces for indent. (The space indent of the below chunk of codes are messy, which impacts the readability.)
b) For multi-line function calls, the input parameters (including the closing bracket) are recommended to add 2 spaces from the function name in the 1st line.
c) Please update multi-line comment to align with style:
//
// Comments...
//


> +        if (TerminalIsValidTextGraphics (*WString, NULL, NULL, &DecChar)
> && !TerminalIsValidAscii (*WString)) {
>
> +          //Box graphics are split into 2 types simple and advanced
>
> +          //simple are drawn with dec special graphics
>
> +          //advanced are drawn with utf8
>
> +          //This checks for simple because they have a lower value than the
> advanced
>
> +          if(*WString < BOXDRAW_DOUBLE_HORIZONTAL) {
>
> +            if (!TerminalDevice->DecSpecialGraphicsMode) {
>
> +              ValidBytes = 0;
>
> +              ModeSwitchLength = LENGTH_DEC_ESCAPE;
>
> +              Status = TerminalDevice->SerialIo->Write (
>
> +                                                   TerminalDevice->SerialIo,
>
> +                                                   &ModeSwitchLength,
>
> +                                                   (UINT8 *)SetDecModeString
>
> +                                          );
>
> +          TerminalDevice->DecSpecialGraphicsMode = TRUE;
>
> +        }
>
>
>
> -      if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) {
>
> +        GraphicChar = DecChar;
>
> +        Length = 1;
>
> +          } else {
>
> +            if (TerminalDevice->DecSpecialGraphicsMode) {
>
> +              ModeSwitchLength = LENGTH_DEC_ESCAPE;
>
> +              Status = TerminalDevice->SerialIo->Write (
>
> +                                                   TerminalDevice->SerialIo,
>
> +                                                   &ModeSwitchLength,
>
> +                                                   (UINT8 *)ExitDecModeString
>
> +                                                );
>
> +                if (EFI_ERROR (Status)) {
>
> +                  goto OutputError;
>
> +                }
>
> +
>
> +            TerminalDevice->DecSpecialGraphicsMode = FALSE;
>
> +          }
>
> +
>
> +          UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);
>
> +          Length = ValidBytes;
>
> +        }
>
> +        } else {
>
> +          if (TerminalDevice->DecSpecialGraphicsMode) {
>
> +          Status = TerminalDevice->SerialIo->Write (
>
> +                                          TerminalDevice->SerialIo,
>
> +                                          &ModeSwitchLength,
>
> +                                          (UINT8 *)ExitDecModeString
>
> +                                          );
>
> +          if (EFI_ERROR (Status)) {
>
> +            goto OutputError;
>
> +          }
>
> +
>
> +          TerminalDevice->DecSpecialGraphicsMode = FALSE;
>
> +        }
>
> +
>
> +          GraphicChar = (CHAR8)*WString;
>
> +
>
> +        if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntlChar
> (GraphicChar))) {
>
> +          //
>
> +          // when this driver use the OutputString to output control string,
>
> +          // TerminalDevice->OutputEscChar is set to let the Esc char
>
> +          // to be output to the terminal emulation software.
>
> +          //
>
> +            if ((GraphicChar == 27) && TerminalDevice->OutputEscChar) {
>
> +              GraphicChar = 27;
>
> +              Length = 1;
>
> +            } else {
>
> +          UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);
>
> +          Length = ValidBytes;
>
> +            }
>
> +          } else {
>
> +        Length = 1;
>
> +      }
>
> +      }
>
> +
>
> +        if (ValidBytes) {
>
> +        Status = TerminalDevice->SerialIo->Write (
>
> +                                        TerminalDevice->SerialIo,
>
> +                                        &Length,
>
> +                                               (UINT8 *)&Utf8Char
>
> +                                        );
>
> +          ValidBytes = 0;
>
> +        } else {
>
> +      Status = TerminalDevice->SerialIo->Write (
>
> +                                      TerminalDevice->SerialIo,
>
> +                                      &Length,
>
> +                                      &GraphicChar
>
> +                                      );
>
> +        }
>
> +      if (EFI_ERROR (Status)) {
>
> +        goto OutputError;
>
> +      }
>
> +
>
> +      break;
>
> +    case TerminalTypeVt100:
>
> +    case TerminalTypeTtyTerm:
>
> +      if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar,
> NULL)) {
>
>          //
>
>          // If it's not a graphic character convert Unicode to ASCII.
>
>          //
>
> @@ -248,12 +370,9 @@ TerminalConOutOutputString (
>          }
>
>
>
>          AsciiChar = GraphicChar;
>
> -
>
>        }
>
>
>
> -      if (TerminalDevice->TerminalType != TerminalTypePcAnsi) {
>
> -        GraphicChar = AsciiChar;
>
> -      }
>
> +      GraphicChar = AsciiChar;
>
>
>
>        Length = 1;
>
>
>
> @@ -267,8 +386,67 @@ TerminalConOutOutputString (
>          goto OutputError;
>
>        }
>
>
>
> -      break;
>
> +        break;
>
> +    case TerminalTypeVt100Plus:
>
> +    case TerminalTypeVt400:


For the below added codes (for case TerminalTypeVt100Plus & TerminalTypeVt400), please help to fix below coding style issues:
a) Codes within a 'case' or 'if-else' statement is recommended to add 2 spaces for indent. (The space indent of the below chunk of codes are messy, which impacts the readability.)
b) For multi-line function calls, the input parameters (including the closing bracket) are recommended to add 2 spaces from the function name in the 1st line.

Best Regards,
Hao Wu


>
> +        Length = 1;
>
> +        if (TerminalIsValidTextGraphics (*WString, NULL, NULL, &DecChar)) {
>
> +          if (!TerminalDevice->DecSpecialGraphicsMode) {
>
> +            ModeSwitchLength = LENGTH_DEC_ESCAPE;
>
> +            Status = TerminalDevice->SerialIo->Write (
>
> +                                                 TerminalDevice->SerialIo,
>
> +                                                 &ModeSwitchLength,
>
> +                                                 (UINT8 *)SetDecModeString
>
> +                                          );
>
> +          TerminalDevice->DecSpecialGraphicsMode = TRUE;
>
> +        }
>
>
>
> +        GraphicChar = DecChar;
>
> +        } else {
>
> +          if (TerminalDevice->DecSpecialGraphicsMode) {
>
> +            ModeSwitchLength = LENGTH_DEC_ESCAPE;
>
> +            Status = TerminalDevice->SerialIo->Write (
>
> +                                                 TerminalDevice->SerialIo,
>
> +                                                 &ModeSwitchLength,
>
> +                                                 (UINT8 *)ExitDecModeString
>
> +                                          );
>
> +
>
> +          if (EFI_ERROR (Status)) {
>
> +            goto OutputError;
>
> +          }
>
> +
>
> +          TerminalDevice->DecSpecialGraphicsMode = FALSE;
>
> +        }
>
> +
>
> +          GraphicChar = (CHAR8)*WString;
>
> +
>
> +        if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntlChar
> (GraphicChar))) {
>
> +          //
>
> +          // when this driver use the OutputString to output control string,
>
> +          // TerminalDevice->OutputEscChar is set to let the Esc char
>
> +          // to be output to the terminal emulation software.
>
> +          //
>
> +          if ((GraphicChar == 27) && TerminalDevice->OutputEscChar) {
>
> +            GraphicChar = 27;
>
> +          } else {
>
> +            GraphicChar = '?';
>
> +            Warning     = TRUE;
>
> +          }
>
> +        }
>
> +      }
>
> +
>
> +    Status = TerminalDevice->SerialIo->Write (
>
> +                                      TerminalDevice->SerialIo,
>
> +                                      &Length,
>
> +                                      &GraphicChar
>
> +                                      );
>
> +
>
> +      if (EFI_ERROR (Status)) {
>
> +        goto OutputError;
>
> +      }
>
> +
>
> +        break;
>
> +    case TerminalTypeLinux:
>
>      case TerminalTypeVtUtf8:
>
>        UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);
>
>        Length = ValidBytes;
>
> @@ -280,8 +458,10 @@ TerminalConOutOutputString (
>        if (EFI_ERROR (Status)) {
>
>          goto OutputError;
>
>        }
>
> +
>
>        break;
>
>      }
>
> +
>
>      //
>
>      //  Update cursor position.
>
>      //
>
> @@ -875,7 +1055,8 @@ BOOLEAN
>  TerminalIsValidTextGraphics (
>
>    IN  CHAR16  Graphic,
>
>    OUT CHAR8   *PcAnsi, OPTIONAL
>
> -  OUT CHAR8   *Ascii OPTIONAL
>
> +  OUT CHAR8   *Ascii, OPTIONAL
>
> +  OUT CHAR8   *DecSpecialGraphics OPTIONAL
>
>    )
>
>  {
>
>    UNICODE_TO_CHAR *Table;
>
> @@ -897,6 +1078,9 @@ TerminalIsValidTextGraphics (
>        if (Ascii != NULL) {
>
>          *Ascii = Table->Ascii;
>
>        }
>
> +      if (DecSpecialGraphics != NULL){
>
> +        *DecSpecialGraphics = Table->DecSpecialGraphics;
>
> +      }
>
>
>
>        return TRUE;
>
>      }
>
> --
> 2.32.0


Re: 回复: [PATCH EDK2 v3 1/1] MdeModulePkg/UefiSortLib:Add UefiSortLib unit test

Wu, Hao A
 

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
gaoliming
Sent: Friday, August 13, 2021 9:03 AM
To: Wu, Hao A <hao.a.wu@intel.com>; 'Wenyi Xie'
<xiewenyi2@huawei.com>; devel@edk2.groups.io
Cc: songdongkuang@huawei.com; Wang, Jian J <jian.j.wang@intel.com>
Subject: [edk2-devel] 回复: [PATCH EDK2 v3 1/1]
MdeModulePkg/UefiSortLib:Add UefiSortLib unit test

Hao:
I think this patch can be merged for this stable tag. It passes code review
before soft feature freeze. ECC issue can be regarded as bug fix. Bug fix is still
allowed in soft feature freeze. Can you merge this patch before hard feature
freeze?

Thanks, already merged via:
PR - https://github.com/tianocore/edk2/pull/1892
Commit - https://github.com/tianocore/edk2/commit/ac826886c98524e918753419c039d8b44198943f

Best Regards,
Hao Wu



Thanks
Liming
-----邮件原件-----
发件人: Wu, Hao A <hao.a.wu@intel.com>
发送时间: 2021年8月11日 16:33
收件人: Liming Gao <gaoliming@byosoft.com.cn>; Wenyi Xie
<xiewenyi2@huawei.com>; devel@edk2.groups.io
抄送: songdongkuang@huawei.com; Wang, Jian J <jian.j.wang@intel.com>
主题: RE: [PATCH EDK2 v3 1/1] MdeModulePkg/UefiSortLib:Add
UefiSortLib
unit test

-----Original Message-----
From: Wenyi Xie <xiewenyi2@huawei.com>
Sent: Wednesday, August 11, 2021 2:36 PM
To: devel@edk2.groups.io; Wang, Jian J <jian.j.wang@intel.com>; Wu,
Hao
A
<hao.a.wu@intel.com>
Cc: songdongkuang@huawei.com; xiewenyi2@huawei.com
Subject: [PATCH EDK2 v3 1/1] MdeModulePkg/UefiSortLib:Add
UefiSortLib unit test

Adding two unit test case for UefiSortLib. One is a test on sorting
an
array of
UINT32 by using PerformQuickSort, another is a test on comparing the
same
buffer by using StringCompare.
Add 'main' function name to ECC exception list to avoid ECC error.

Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Hello Liming,

Since the patch looks more like a feature than a bugfix to me, I would
like to
confirm that can I merge this change now?
I already gave my 'R-b' tag for the V2 patch on 29th July, but met
some
ECC
check issues during previous merging attempt.
I verified that the latest patch can pass the merging test
(https://github.com/tianocore/edk2/pull/1892).

Best Regards,
Hao Wu



Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
---
MdeModulePkg/Test/MdeModulePkgHostTest.dsc
| 6 +
MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf |
32
+++
MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c |
207
++++++++++++++++++++
MdeModulePkg/MdeModulePkg.ci.yaml
| 1 +
4 files changed, 246 insertions(+)

diff --git a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
index 4da4692c8451..c9ec835df65d 100644
--- a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
+++ b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
@@ -41,3 +41,9 @@ [Components]
<PcdsFixedAtBuild>

gEfiMdeModulePkgTokenSpaceGuid.PcdAllowVariablePolicyEnforcementDis
able|TRUE
}
+
+ MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf {
+ <LibraryClasses>
+ UefiSortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+
+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.i
+ DevicePathLib|nf
+ }
diff --git
a/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf
b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf
new file mode 100644
index 000000000000..85d8dcd69619
--- /dev/null
+++ b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.
+++ inf
@@ -0,0 +1,32 @@
+## @file
+# This is a unit test for the UefiSortLib.
+#
+# Copyright (C) Huawei Technologies Co., Ltd. All rights reserved #
+SPDX-License-Identifier: BSD-2-Clause-Patent ##
+
+[Defines]
+ INF_VERSION = 0x00010017
+ BASE_NAME = UefiSortLibUnitTest
+ FILE_GUID = 271337A3-0D79-BA3E-BC03-714E518E3B1B
+ VERSION_STRING = 1.0
+ MODULE_TYPE = HOST_APPLICATION
+
+#
+# The following information is for reference only and not required
+by
the
build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ UefiSortLibUnitTest.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+ UnitTestLib
+ DebugLib
+ UefiSortLib
diff --git
a/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c
b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c
new file mode 100644
index 000000000000..4f44a02c5b5d
--- /dev/null
+++ b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.
+++ c
@@ -0,0 +1,207 @@
+/** @file
+ Unit tests of the UefiSortLib
+
+ Copyright (C) Huawei Technologies Co., Ltd. All rights reserved
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+#include <Library/UnitTestLib.h>
+#include <Library/SortLib.h>
+
+#define UNIT_TEST_APP_NAME "UefiSortLib Unit Tests"
+#define UNIT_TEST_APP_VERSION "1.0"
+
+#define TEST_ARRAY_SIZE_9 9
+
+/**
+ The function is called by PerformQuickSort to compare int values.
+
+ @param[in] Left The pointer to first buffer.
+ @param[in] Right The pointer to second buffer.
+
+ @retval 0 Buffer1 equal to Buffer2.
+ @return <0 Buffer1 is less than Buffer2.
+ @return >0 Buffer1 is greater than Buffer2.
+
+**/
+INTN
+EFIAPI
+TestCompareFunction (
+ IN CONST VOID *Left,
+ IN CONST VOID *Right
+ )
+{
+ if (*(UINT32*)Right > *(UINT32*)Left) {
+ return 1;
+ } else if (*(UINT32*)Right < *(UINT32*)Left) {
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ Unit test for PerformQuickSort () API of the UefiSortLib.
+
+ @param[in] Context [Optional] An optional parameter that
enables:
+ 1) test-case reuse with varied parameters
and
+ 2) test-case re-entry for Target tests
+ that
need a
+ reboot. This parameter is a VOID* and it
is the
+ responsibility of the test author to
+ ensure
that the
+ contents are well understood by all test
cases that may
+ consume it.
+
+ @retval UNIT_TEST_PASSED The Unit test has
completed and the
test
+ case was successful.
+ @retval UNIT_TEST_ERROR_TEST_FAILED A test case assertion has
failed.
+**/
+UNIT_TEST_STATUS
+EFIAPI
+SortUINT32ArrayShouldSucceed (
+ IN UNIT_TEST_CONTEXT Context
+ )
+{
+ UINTN TestCount;
+ UINT32 Index;
+ UINT32 TestBuffer[TEST_ARRAY_SIZE_9];
+ UINT32 TestResult[TEST_ARRAY_SIZE_9];
+
+ TestCount = TEST_ARRAY_SIZE_9;
+ for (Index = 0; Index < TEST_ARRAY_SIZE_9; Index++) {
+ TestBuffer[Index] = Index + 1;
+ TestResult[Index] = TEST_ARRAY_SIZE_9 - Index; }
+
+ PerformQuickSort (TestBuffer, TestCount, sizeof (UINT32),
+ (SORT_COMPARE)TestCompareFunction);
+ UT_ASSERT_MEM_EQUAL (TestBuffer, TestResult, sizeof (UINT32) *
+ TEST_ARRAY_SIZE_9);
+
+ return UNIT_TEST_PASSED;
+}
+
+/**
+ Unit test for StringCompare () API of the UefiSortLib.
+
+ @param[in] Context [Optional] An optional parameter that
enables:
+ 1) test-case reuse with varied parameters
and
+ 2) test-case re-entry for Target tests
+ that
need a
+ reboot. This parameter is a VOID* and it
is the
+ responsibility of the test author to
+ ensure
that the
+ contents are well understood by all test
cases that may
+ consume it.
+
+ @retval UNIT_TEST_PASSED The Unit test has
completed and the
test
+ case was successful.
+ @retval UNIT_TEST_ERROR_TEST_FAILED A test case assertion has
failed.
+**/
+UNIT_TEST_STATUS
+EFIAPI
+CompareSameBufferShouldSucceed (
+ IN UNIT_TEST_CONTEXT Context
+ )
+{
+ INTN retval;
+ CONST CHAR16* TestBuffer[] = { L"abcdefg" };
+
+ retval = StringCompare (TestBuffer, TestBuffer); UT_ASSERT_TRUE
+ (retval == 0);
+
+ return UNIT_TEST_PASSED;
+}
+
+/**
+ Initialze the unit test framework, suite, and unit tests for the
+ UefiSortLib and run the UefiSortLib unit test.
+
+ @retval EFI_SUCCESS All test cases were dispatched.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources
available to
+ initialize the unit tests.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+UnitTestingEntry (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UNIT_TEST_FRAMEWORK_HANDLE Framework;
+ UNIT_TEST_SUITE_HANDLE SortTests;
+
+ Framework = NULL;
+
+ DEBUG(( DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME,
+ UNIT_TEST_APP_VERSION ));
+
+ //
+ // Start setting up the test framework for running the tests.
+ //
+ Status = InitUnitTestFramework (&Framework,
UNIT_TEST_APP_NAME,
+ gEfiCallerBaseName, UNIT_TEST_APP_VERSION); if (EFI_ERROR
+ (Status))
{
+ DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status
= %r\n", Status));
+ goto EXIT;
+ }
+
+ //
+ // Populate the UefiSortLib Unit Test Suite.
+ //
+ Status = CreateUnitTestSuite (&SortTests, Framework, "UefiSortLib
+ Sort Tests", "UefiSortLib.SortLib", NULL, NULL); if (EFI_ERROR
(Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for
UefiSortLib
API Tests\n"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto EXIT;
+ }
+
+ //
+ //
+ --------------Suite--------Description------------Name------------
+ --Fu
+ nction----------------Pre---Post---Context-----------
+ //
+ AddTestCase (SortTests, "Sort the Array", "Sort",
SortUINT32ArrayShouldSucceed, NULL, NULL, NULL);
+ AddTestCase (SortTests, "Compare the Buffer", "Compare",
CompareSameBufferShouldSucceed, NULL, NULL, NULL);
+
+ //
+ // Execute the tests.
+ //
+ Status = RunAllTestSuites (Framework);
+
+EXIT:
+ if (Framework) {
+ FreeUnitTestFramework (Framework);
+ }
+
+ return Status;
+}
+
+///
+/// Avoid ECC error for function name that starts with lower case
+letter /// #define UefiSortLibUnitTestMain main
+
+/**
+ Standard POSIX C entry point for host based unit test execution.
+
+ @param[in] Argc Number of arguments @param[in] Argv Array of
+ pointers to arguments
+
+ @retval 0 Success
+ @retval other Error
+**/
+INT32
+UefiSortLibUnitTestMain (
+ IN INT32 Argc,
+ IN CHAR8 *Argv[]
+ )
+{
+ UnitTestingEntry ();
+ return 0;
+}
diff --git a/MdeModulePkg/MdeModulePkg.ci.yaml
b/MdeModulePkg/MdeModulePkg.ci.yaml
index 8e01caf94cbf..aa304f2ccd5c 100644
--- a/MdeModulePkg/MdeModulePkg.ci.yaml
+++ b/MdeModulePkg/MdeModulePkg.ci.yaml
@@ -19,6 +19,7 @@
"ExceptionList": [
"8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.UID",
"8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.HID",
+ "8001", "UefiSortLibUnitTestMain",
],
## Both file path and directory path are accepted.
"IgnoreFiles": [
--
2.20.1.windows.1






Re: [PATCH 1/1] MdeModulePkg/Console: Improve encoding of box drawing characters

Wu, Hao A
 

Reposting to the mailing list.

 

Best Regards,

Hao Wu

 

From: Caden Kline <cadenkline9@...>
Sent: Friday, August 13, 2021 12:32 AM
To: Wu, Hao A <hao.a.wu@...>
Subject: Re: [PATCH 1/1] MdeModulePkg/Console: Improve encoding of box drawing characters

 

For testing I just ran a program that printed out the impacted characters and checked it against different terminals, putty for windows, xtrem and tillix for linux, and standard mac os terminal with all the effected terminal types.   

 

On Mon, Aug 9, 2021 at 1:57 AM Wu, Hao A <hao.a.wu@...> wrote:

Sorry Zhichao and Ray, could you please help to check if you have comments for this patch. Thanks in advance.

Hello Caden Kline, could you help to provide the information on what kind of unit test was done for this patch?

Some inline comments for ONLY coding style issues:


> -----Original Message-----
> From: Caden Kline <cadenkline9@...>
> Sent: Friday, July 30, 2021 10:45 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@...>; Wu, Hao A <hao.a.wu@...>;
> Gao, Zhichao <zhichao.gao@...>; Ni, Ray <ray.ni@...>
> Subject: [PATCH 1/1] MdeModulePkg/Console: Improve encoding of box
> drawing characters
>
> Improved encoding of box drawing characters for different terminal types.
> This includes Dec special graphics mode and more utf8.
>
> Cc: Jian J Wang <jian.j.wang@...>
> Cc: Hao A Wu <hao.a.wu@...>
> Cc: Zhichao Gao <zhichao.gao@...>
> Cc: Ray Ni <ray.ni@...>
> Signed-off-by: Caden Kline <cadenkline9@...>
> ---
>  .../Universal/Console/TerminalDxe/Terminal.h  |  24 +-
>  .../Universal/Console/TerminalDxe/Ansi.c      |   2 +-
>  .../Console/TerminalDxe/TerminalConOut.c      | 322 ++++++++++++++----
>  3 files changed, 269 insertions(+), 79 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> index 360e58e84743..83c3ea94a042 100644
> --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
> @@ -122,7 +122,10 @@ typedef struct {
>    EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL   SimpleInputEx;
>
>    LIST_ENTRY                          NotifyList;
>
>    EFI_EVENT                           KeyNotifyProcessEvent;
>
> +  BOOLEAN                             DecSpecialGraphicsMode;
>
>  } TERMINAL_DEV;
>
> +// This the lenth the escape squences for entering and exiting Dec Special


Typo: lenth -> length, squences -> sequences

Also, please help to update the comments to style:
//
// This the length the escape sequences for entering and exiting Dec Special
//



> Graphics Mode
>
> +#define LENGTH_DEC_ESCAPE                 0x03
>
>
>
>  #define INPUT_STATE_DEFAULT               0x00
>
>  #define INPUT_STATE_ESC                   0x01
>
> @@ -169,6 +172,7 @@ typedef struct {
>    UINT16  Unicode;
>
>    CHAR8   PcAnsi;
>
>    CHAR8   Ascii;
>
> +  CHAR8   DecSpecialGraphics;
>
>  } UNICODE_TO_CHAR;
>
>
>
>  //
>
> @@ -1367,20 +1371,22 @@ Utf8ToUnicode (
>  /**
>
>    Detects if a Unicode char is for Box Drawing text graphics.
>
>
>
> -  @param  Graphic      Unicode char to test.
>
> -  @param  PcAnsi       Optional pointer to return PCANSI equivalent of
>
> -                       Graphic.
>
> -  @param  Ascii        Optional pointer to return ASCII equivalent of
>
> -                       Graphic.
>
> -
>
> -  @retval TRUE         If Graphic is a supported Unicode Box Drawing character.
>
> +  @param  Graphic             Unicode char to test.
>
> +  @param  PcAnsi              Optional pointer to return PCANSI equivalent of
>
> +                              Graphic.
>
> +  @param  Ascii               Optional pointer to return ASCII equivalent of
>
> +                              Graphic.
>
> +  @param  DecSpecialGraphics  Optional pointer to return Dec Special
> Graphics equivalent of
>
> +                              Graphic.
>
> +  @retval TRUE                If Graphic is a supported Unicode Box Drawing
> character.
>
>
>
>  **/
>
>  BOOLEAN
>
>  TerminalIsValidTextGraphics (
>
>    IN  CHAR16  Graphic,
>
> -  OUT CHAR8   *PcAnsi, OPTIONAL
>
> -  OUT CHAR8   *Ascii OPTIONAL
>
> +  OUT CHAR8   *PcAnsi,            OPTIONAL
>
> +  OUT CHAR8   *Ascii,             OPTIONAL
>
> +  OUT CHAR8   *DecSpecialGraphics OPTIONAL
>
>    );
>
>
>
>  /**
>
> diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
> b/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
> index f117d90b9de3..5ae5a4f0212e 100644
> --- a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
> +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
> @@ -63,7 +63,7 @@ AnsiTestString (
>
>
>      if ( !(TerminalIsValidAscii (*WString) ||
>
>          TerminalIsValidEfiCntlChar (*WString) ||
>
> -        TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL) )) {
>
> +        TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL, NULL) )) {
>
>
>
>        return EFI_UNSUPPORTED;
>
>      }
>
> diff --git
> a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
> b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
> index aae470e9562c..1c22ed426715 100644
> --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
> +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
> @@ -16,61 +16,59 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  //
>
>  //
>
>  UNICODE_TO_CHAR  UnicodeToPcAnsiOrAscii[] = {
>
> -  { BOXDRAW_HORIZONTAL,                 0xc4, L'-' },
>
> -  { BOXDRAW_VERTICAL,                   0xb3, L'|' },
>
> -  { BOXDRAW_DOWN_RIGHT,                 0xda, L'/' },
>
> -  { BOXDRAW_DOWN_LEFT,                  0xbf, L'\\' },
>
> -  { BOXDRAW_UP_RIGHT,                   0xc0, L'\\' },
>
> -  { BOXDRAW_UP_LEFT,                    0xd9, L'/' },
>
> -  { BOXDRAW_VERTICAL_RIGHT,             0xc3, L'|' },
>
> -  { BOXDRAW_VERTICAL_LEFT,              0xb4, L'|' },
>
> -  { BOXDRAW_DOWN_HORIZONTAL,            0xc2, L'+' },
>
> -  { BOXDRAW_UP_HORIZONTAL,              0xc1, L'+' },
>
> -  { BOXDRAW_VERTICAL_HORIZONTAL,        0xc5, L'+' },
>
> -  { BOXDRAW_DOUBLE_HORIZONTAL,          0xcd, L'-' },
>
> -  { BOXDRAW_DOUBLE_VERTICAL,            0xba, L'|' },
>
> -  { BOXDRAW_DOWN_RIGHT_DOUBLE,          0xd5, L'/' },
>
> -  { BOXDRAW_DOWN_DOUBLE_RIGHT,          0xd6, L'/' },
>
> -  { BOXDRAW_DOUBLE_DOWN_RIGHT,          0xc9, L'/' },
>
> -  { BOXDRAW_DOWN_LEFT_DOUBLE,           0xb8, L'\\' },
>
> -  { BOXDRAW_DOWN_DOUBLE_LEFT,           0xb7, L'\\' },
>
> -  { BOXDRAW_DOUBLE_DOWN_LEFT,           0xbb, L'\\' },
>
> -  { BOXDRAW_UP_RIGHT_DOUBLE,            0xd4, L'\\' },
>
> -  { BOXDRAW_UP_DOUBLE_RIGHT,            0xd3, L'\\' },
>
> -  { BOXDRAW_DOUBLE_UP_RIGHT,            0xc8, L'\\' },
>
> -  { BOXDRAW_UP_LEFT_DOUBLE,             0xbe, L'/' },
>
> -  { BOXDRAW_UP_DOUBLE_LEFT,             0xbd, L'/' },
>
> -  { BOXDRAW_DOUBLE_UP_LEFT,             0xbc, L'/' },
>
> -  { BOXDRAW_VERTICAL_RIGHT_DOUBLE,      0xc6, L'|' },
>
> -  { BOXDRAW_VERTICAL_DOUBLE_RIGHT,      0xc7, L'|' },
>
> -  { BOXDRAW_DOUBLE_VERTICAL_RIGHT,      0xcc, L'|' },
>
> -  { BOXDRAW_VERTICAL_LEFT_DOUBLE,       0xb5, L'|' },
>
> -  { BOXDRAW_VERTICAL_DOUBLE_LEFT,       0xb6, L'|' },
>
> -  { BOXDRAW_DOUBLE_VERTICAL_LEFT,       0xb9, L'|' },
>
> -  { BOXDRAW_DOWN_HORIZONTAL_DOUBLE,     0xd1, L'+' },
>
> -  { BOXDRAW_DOWN_DOUBLE_HORIZONTAL,     0xd2, L'+' },
>
> -  { BOXDRAW_DOUBLE_DOWN_HORIZONTAL,     0xcb, L'+' },
>
> -  { BOXDRAW_UP_HORIZONTAL_DOUBLE,       0xcf, L'+' },
>
> -  { BOXDRAW_UP_DOUBLE_HORIZONTAL,       0xd0, L'+' },
>
> -  { BOXDRAW_DOUBLE_UP_HORIZONTAL,       0xca, L'+' },
>
> -  { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+' },
>
> -  { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+' },
>
> -  { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+' },
>
> +  { BOXDRAW_HORIZONTAL,                 0xc4, L'-',  0x71 },
>
> +  { BOXDRAW_VERTICAL,                   0xb3, L'|',  0x78 },
>
> +  { BOXDRAW_DOWN_RIGHT,                 0xda, L'/',  0x6c },
>
> +  { BOXDRAW_DOWN_LEFT,                  0xbf, L'\\', 0x6b },
>
> +  { BOXDRAW_UP_RIGHT,                   0xc0, L'\\', 0x6d },
>
> +  { BOXDRAW_UP_LEFT,                    0xd9, L'/',  0x6a },
>
> +  { BOXDRAW_VERTICAL_RIGHT,             0xc3, L'|',  0x74 },
>
> +  { BOXDRAW_VERTICAL_LEFT,              0xb4, L'|',  0x75 },
>
> +  { BOXDRAW_DOWN_HORIZONTAL,            0xc2, L'+',  0x77 },
>
> +  { BOXDRAW_UP_HORIZONTAL,              0xc1, L'+',  0x76 },
>
> +  { BOXDRAW_VERTICAL_HORIZONTAL,        0xc5, L'+',  0x6e },
>
> +  { BOXDRAW_DOUBLE_HORIZONTAL,          0xcd, L'-',  0x71 },
>
> +  { BOXDRAW_DOUBLE_VERTICAL,            0xba, L'|',  0x78 },
>
> +  { BOXDRAW_DOWN_RIGHT_DOUBLE,          0xd5, L'/',  0x6c },
>
> +  { BOXDRAW_DOWN_DOUBLE_RIGHT,          0xd6, L'/',  0x6c },
>
> +  { BOXDRAW_DOUBLE_DOWN_RIGHT,          0xc9, L'/',  0x6c },
>
> +  { BOXDRAW_DOWN_LEFT_DOUBLE,           0xb8, L'\\', 0x6b },
>
> +  { BOXDRAW_DOWN_DOUBLE_LEFT,           0xb7, L'\\', 0x6b },
>
> +  { BOXDRAW_DOUBLE_DOWN_LEFT,           0xbb, L'\\', 0x6b },
>
> +  { BOXDRAW_UP_RIGHT_DOUBLE,            0xd4, L'\\', 0x6d },
>
> +  { BOXDRAW_UP_DOUBLE_RIGHT,            0xd3, L'\\', 0x6d },
>
> +  { BOXDRAW_DOUBLE_UP_RIGHT,            0xc8, L'\\', 0x6d },
>
> +  { BOXDRAW_UP_LEFT_DOUBLE,             0xbe, L'/',  0x6a },
>
> +  { BOXDRAW_UP_DOUBLE_LEFT,             0xbd, L'/',  0x6a },
>
> +  { BOXDRAW_DOUBLE_UP_LEFT,             0xbc, L'/',  0x6a },
>
> +  { BOXDRAW_VERTICAL_RIGHT_DOUBLE,      0xc6, L'|',  0x74 },
>
> +  { BOXDRAW_VERTICAL_DOUBLE_RIGHT,      0xc7, L'|',  0x74 },
>
> +  { BOXDRAW_DOUBLE_VERTICAL_RIGHT,      0xcc, L'|',  0x74 },
>
> +  { BOXDRAW_VERTICAL_LEFT_DOUBLE,       0xb5, L'|',  0x75 },
>
> +  { BOXDRAW_VERTICAL_DOUBLE_LEFT,       0xb6, L'|',  0x75 },
>
> +  { BOXDRAW_DOUBLE_VERTICAL_LEFT,       0xb9, L'|',  0x75 },
>
> +  { BOXDRAW_DOWN_HORIZONTAL_DOUBLE,     0xd1, L'+',  0x77 },
>
> +  { BOXDRAW_DOWN_DOUBLE_HORIZONTAL,     0xd2, L'+',  0x77 },
>
> +  { BOXDRAW_DOUBLE_DOWN_HORIZONTAL,     0xcb, L'+',  0x77 },
>
> +  { BOXDRAW_UP_HORIZONTAL_DOUBLE,       0xcf, L'+',  0x76 },
>
> +  { BOXDRAW_UP_DOUBLE_HORIZONTAL,       0xd0, L'+',  0x76 },
>
> +  { BOXDRAW_DOUBLE_UP_HORIZONTAL,       0xca, L'+',  0x76 },
>
> +  { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+',  0x6e },
>
> +  { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+',  0x6e },
>
> +  { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+',  0x6e },
>
>
>
> -  { BLOCKELEMENT_FULL_BLOCK,            0xdb, L'*' },
>
> -  { BLOCKELEMENT_LIGHT_SHADE,           0xb0, L'+' },
>
> +  { BLOCKELEMENT_FULL_BLOCK,            0xdb, L'*',  0x61 },
>
> +  { BLOCKELEMENT_LIGHT_SHADE,           0xb0, L'+',  0x61 },
>
>
>
> -  { GEOMETRICSHAPE_UP_TRIANGLE,         '^', L'^' },
>
> -  { GEOMETRICSHAPE_RIGHT_TRIANGLE,      '>', L'>' },
>
> -  { GEOMETRICSHAPE_DOWN_TRIANGLE,       'v', L'v' },
>
> -  { GEOMETRICSHAPE_LEFT_TRIANGLE,       '<', L'<' },
>
> +  { GEOMETRICSHAPE_UP_TRIANGLE,         '^',  L'^',  L'^' },
>
> +  { GEOMETRICSHAPE_RIGHT_TRIANGLE,      '>',  L'>',  L'>' },
>
> +  { GEOMETRICSHAPE_DOWN_TRIANGLE,       'v',  L'v',  L'v' },
>
> +  { GEOMETRICSHAPE_LEFT_TRIANGLE,       '<',  L'<',  L'<' },
>
>
>
> -  { ARROW_LEFT,                         '<', L'<' },
>
> -  { ARROW_UP,                           '^', L'^' },
>
> -  { ARROW_RIGHT,                        '>', L'>' },
>
> -  { ARROW_DOWN,                         'v', L'v' },
>
> -
>
> -  { 0x0000,                             0x00, L'\0' }
>
> +  { ARROW_LEFT,                         '<',  L'<',  L'<' },
>
> +  { ARROW_UP,                           '^',  L'^',  L'^' },
>
> +  { ARROW_RIGHT,                        '>',  L'>',  L'>' },
>
> +  { ARROW_DOWN,                         'v',  L'v',  L'v' },
>
>  };
>
>
>
>  CHAR16 mSetModeString[]            = { ESC, '[', '=', '3', 'h', 0 };
>
> @@ -80,6 +78,8 @@ CHAR16 mSetCursorPositionString[]  = { ESC, '[', '0', '0', ';',
> '0', '0', 'H', 0
>  CHAR16 mCursorForwardString[]      = { ESC, '[', '0', '0', 'C', 0 };
>
>  CHAR16 mCursorBackwardString[]     = { ESC, '[', '0', '0', 'D', 0 };
>
>
>
> +CHAR8  SetDecModeString[]          = {ESC, 0x28, 0x30};
>
> +CHAR8  ExitDecModeString[]         = {ESC, 0x28, 0x42};
>
>  //
>
>  // Body of the ConOut functions
>
>  //
>
> @@ -183,16 +183,19 @@ TerminalConOutOutputString (
>    EFI_STATUS                  Status;
>
>    UINT8                       ValidBytes;
>
>    CHAR8                       CrLfStr[2];
>
> +  CHAR8                       DecChar;
>
> +  UINTN                       ModeSwitchLength;
>
>    //
>
>    //  flag used to indicate whether condition happens which will cause
>
>    //  return EFI_WARN_UNKNOWN_GLYPH
>
>    //
>
>    BOOLEAN                     Warning;
>
>
>
> -  ValidBytes  = 0;
>
> -  Warning     = FALSE;
>
> -  AsciiChar   = 0;
>
> -
>
> +  ValidBytes       = 0;
>
> +  Warning          = FALSE;
>
> +  AsciiChar        = 0;
>
> +  DecChar          = 0;
>
> +  ModeSwitchLength = LENGTH_DEC_ESCAPE;
>
>    //
>
>    //  get Terminal device data structure pointer.
>
>    //
>
> @@ -217,17 +220,136 @@ TerminalConOutOutputString (
>    for (; *WString != CHAR_NULL; WString++) {
>
>
>
>      switch (TerminalDevice->TerminalType) {
>
> -
>
>      case TerminalTypePcAnsi:
>
> -    case TerminalTypeVt100:
>
> -    case TerminalTypeVt100Plus:
>
> -    case TerminalTypeTtyTerm:
>
> -    case TerminalTypeLinux:
>
> +      if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar,
> NULL)) {
>
> +        //
>
> +        // If it's not a graphic character convert Unicode to ASCII.
>
> +        //
>
> +          GraphicChar = (CHAR8)*WString;


Please help to fix the space indent (extra spaces) here to keep it aligned with the contexts.


>
> +
>
> +        if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntlChar
> (GraphicChar))) {
>
> +          //
>
> +          // when this driver use the OutputString to output control string,
>
> +          // TerminalDevice->OutputEscChar is set to let the Esc char
>
> +          // to be output to the terminal emulation software.
>
> +          //
>
> +          if ((GraphicChar == 27) && TerminalDevice->OutputEscChar) {
>
> +            GraphicChar = 27;
>
> +          } else {
>
> +            GraphicChar = '?';
>
> +            Warning     = TRUE;
>
> +          }
>
> +        }
>
> +
>
> +        AsciiChar = GraphicChar;
>
> +      }
>
> +      Length = 1;
>
> +      Status = TerminalDevice->SerialIo->Write (
>
> +                                          TerminalDevice->SerialIo,
>
> +                                          &Length,
>
> +                                          &GraphicChar
>
> +                                          );


Please help to add an extra space for the above 3 lines for space indent coding style.


>
> +
>
> +      if (EFI_ERROR (Status)) {
>
> +        goto OutputError;
>
> +      }
>
> +
>
> +      break;
>
>      case TerminalTypeXtermR6:
>
> -    case TerminalTypeVt400:
>
>      case TerminalTypeSCO:
>


For the below added codes (for case TerminalTypeXtermR6 & TerminalTypeSCO), please help to fix below coding style issues:
a) Codes within a 'case' or 'if-else' statement is recommended to add 2 spaces for indent. (The space indent of the below chunk of codes are messy, which impacts the readability.)
b) For multi-line function calls, the input parameters (including the closing bracket) are recommended to add 2 spaces from the function name in the 1st line.
c) Please update multi-line comment to align with style:
//
// Comments...
//


> +        if (TerminalIsValidTextGraphics (*WString, NULL, NULL, &DecChar)
> && !TerminalIsValidAscii (*WString)) {
>
> +          //Box graphics are split into 2 types simple and advanced
>
> +          //simple are drawn with dec special graphics
>
> +          //advanced are drawn with utf8
>
> +          //This checks for simple because they have a lower value than the
> advanced
>
> +          if(*WString < BOXDRAW_DOUBLE_HORIZONTAL) {
>
> +            if (!TerminalDevice->DecSpecialGraphicsMode) {
>
> +              ValidBytes = 0;
>
> +              ModeSwitchLength = LENGTH_DEC_ESCAPE;
>
> +              Status = TerminalDevice->SerialIo->Write (
>
> +                                                   TerminalDevice->SerialIo,
>
> +                                                   &ModeSwitchLength,
>
> +                                                   (UINT8 *)SetDecModeString
>
> +                                          );
>
> +          TerminalDevice->DecSpecialGraphicsMode = TRUE;
>
> +        }
>
>
>
> -      if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) {
>
> +        GraphicChar = DecChar;
>
> +        Length = 1;
>
> +          } else {
>
> +            if (TerminalDevice->DecSpecialGraphicsMode) {
>
> +              ModeSwitchLength = LENGTH_DEC_ESCAPE;
>
> +              Status = TerminalDevice->SerialIo->Write (
>
> +                                                   TerminalDevice->SerialIo,
>
> +                                                   &ModeSwitchLength,
>
> +                                                   (UINT8 *)ExitDecModeString
>
> +                                                );
>
> +                if (EFI_ERROR (Status)) {
>
> +                  goto OutputError;
>
> +                }
>
> +
>
> +            TerminalDevice->DecSpecialGraphicsMode = FALSE;
>
> +          }
>
> +
>
> +          UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);
>
> +          Length = ValidBytes;
>
> +        }
>
> +        } else {
>
> +          if (TerminalDevice->DecSpecialGraphicsMode) {
>
> +          Status = TerminalDevice->SerialIo->Write (
>
> +                                          TerminalDevice->SerialIo,
>
> +                                          &ModeSwitchLength,
>
> +                                          (UINT8 *)ExitDecModeString
>
> +                                          );
>
> +          if (EFI_ERROR (Status)) {
>
> +            goto OutputError;
>
> +          }
>
> +
>
> +          TerminalDevice->DecSpecialGraphicsMode = FALSE;
>
> +        }
>
> +
>
> +          GraphicChar = (CHAR8)*WString;
>
> +
>
> +        if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntlChar
> (GraphicChar))) {
>
> +          //
>
> +          // when this driver use the OutputString to output control string,
>
> +          // TerminalDevice->OutputEscChar is set to let the Esc char
>
> +          // to be output to the terminal emulation software.
>
> +          //
>
> +            if ((GraphicChar == 27) && TerminalDevice->OutputEscChar) {
>
> +              GraphicChar = 27;
>
> +              Length = 1;
>
> +            } else {
>
> +          UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);
>
> +          Length = ValidBytes;
>
> +            }
>
> +          } else {
>
> +        Length = 1;
>
> +      }
>
> +      }
>
> +
>
> +        if (ValidBytes) {
>
> +        Status = TerminalDevice->SerialIo->Write (
>
> +                                        TerminalDevice->SerialIo,
>
> +                                        &Length,
>
> +                                               (UINT8 *)&Utf8Char
>
> +                                        );
>
> +          ValidBytes = 0;
>
> +        } else {
>
> +      Status = TerminalDevice->SerialIo->Write (
>
> +                                      TerminalDevice->SerialIo,
>
> +                                      &Length,
>
> +                                      &GraphicChar
>
> +                                      );
>
> +        }
>
> +      if (EFI_ERROR (Status)) {
>
> +        goto OutputError;
>
> +      }
>
> +
>
> +      break;
>
> +    case TerminalTypeVt100:
>
> +    case TerminalTypeTtyTerm:
>
> +      if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar,
> NULL)) {
>
>          //
>
>          // If it's not a graphic character convert Unicode to ASCII.
>
>          //
>
> @@ -248,12 +370,9 @@ TerminalConOutOutputString (
>          }
>
>
>
>          AsciiChar = GraphicChar;
>
> -
>
>        }
>
>
>
> -      if (TerminalDevice->TerminalType != TerminalTypePcAnsi) {
>
> -        GraphicChar = AsciiChar;
>
> -      }
>
> +      GraphicChar = AsciiChar;
>
>
>
>        Length = 1;
>
>
>
> @@ -267,8 +386,67 @@ TerminalConOutOutputString (
>          goto OutputError;
>
>        }
>
>
>
> -      break;
>
> +        break;
>
> +    case TerminalTypeVt100Plus:
>
> +    case TerminalTypeVt400:


For the below added codes (for case TerminalTypeVt100Plus & TerminalTypeVt400), please help to fix below coding style issues:
a) Codes within a 'case' or 'if-else' statement is recommended to add 2 spaces for indent. (The space indent of the below chunk of codes are messy, which impacts the readability.)
b) For multi-line function calls, the input parameters (including the closing bracket) are recommended to add 2 spaces from the function name in the 1st line.

Best Regards,
Hao Wu


>
> +        Length = 1;
>
> +        if (TerminalIsValidTextGraphics (*WString, NULL, NULL, &DecChar)) {
>
> +          if (!TerminalDevice->DecSpecialGraphicsMode) {
>
> +            ModeSwitchLength = LENGTH_DEC_ESCAPE;
>
> +            Status = TerminalDevice->SerialIo->Write (
>
> +                                                 TerminalDevice->SerialIo,
>
> +                                                 &ModeSwitchLength,
>
> +                                                 (UINT8 *)SetDecModeString
>
> +                                          );
>
> +          TerminalDevice->DecSpecialGraphicsMode = TRUE;
>
> +        }
>
>
>
> +        GraphicChar = DecChar;
>
> +        } else {
>
> +          if (TerminalDevice->DecSpecialGraphicsMode) {
>
> +            ModeSwitchLength = LENGTH_DEC_ESCAPE;
>
> +            Status = TerminalDevice->SerialIo->Write (
>
> +                                                 TerminalDevice->SerialIo,
>
> +                                                 &ModeSwitchLength,
>
> +                                                 (UINT8 *)ExitDecModeString
>
> +                                          );
>
> +
>
> +          if (EFI_ERROR (Status)) {
>
> +            goto OutputError;
>
> +          }
>
> +
>
> +          TerminalDevice->DecSpecialGraphicsMode = FALSE;
>
> +        }
>
> +
>
> +          GraphicChar = (CHAR8)*WString;
>
> +
>
> +        if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntlChar
> (GraphicChar))) {
>
> +          //
>
> +          // when this driver use the OutputString to output control string,
>
> +          // TerminalDevice->OutputEscChar is set to let the Esc char
>
> +          // to be output to the terminal emulation software.
>
> +          //
>
> +          if ((GraphicChar == 27) && TerminalDevice->OutputEscChar) {
>
> +            GraphicChar = 27;
>
> +          } else {
>
> +            GraphicChar = '?';
>
> +            Warning     = TRUE;
>
> +          }
>
> +        }
>
> +      }
>
> +
>
> +    Status = TerminalDevice->SerialIo->Write (
>
> +                                      TerminalDevice->SerialIo,
>
> +                                      &Length,
>
> +                                      &GraphicChar
>
> +                                      );
>
> +
>
> +      if (EFI_ERROR (Status)) {
>
> +        goto OutputError;
>
> +      }
>
> +
>
> +        break;
>
> +    case TerminalTypeLinux:
>
>      case TerminalTypeVtUtf8:
>
>        UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);
>
>        Length = ValidBytes;
>
> @@ -280,8 +458,10 @@ TerminalConOutOutputString (
>        if (EFI_ERROR (Status)) {
>
>          goto OutputError;
>
>        }
>
> +
>
>        break;
>
>      }
>
> +
>
>      //
>
>      //  Update cursor position.
>
>      //
>
> @@ -875,7 +1055,8 @@ BOOLEAN
>  TerminalIsValidTextGraphics (
>
>    IN  CHAR16  Graphic,
>
>    OUT CHAR8   *PcAnsi, OPTIONAL
>
> -  OUT CHAR8   *Ascii OPTIONAL
>
> +  OUT CHAR8   *Ascii, OPTIONAL
>
> +  OUT CHAR8   *DecSpecialGraphics OPTIONAL
>
>    )
>
>  {
>
>    UNICODE_TO_CHAR *Table;
>
> @@ -897,6 +1078,9 @@ TerminalIsValidTextGraphics (
>        if (Ascii != NULL) {
>
>          *Ascii = Table->Ascii;
>
>        }
>
> +      if (DecSpecialGraphics != NULL){
>
> +        *DecSpecialGraphics = Table->DecSpecialGraphics;
>
> +      }
>
>
>
>        return TRUE;
>
>      }
>
> --
> 2.32.0


回复: [edk2-devel] [2021-gsoc-llvm-gnumake]: proposal for building using llvm/gnumake

gaoliming
 

Yuqi:

 On Windows, can Clang + make combination drop the dependency of Visual studio? If I don’t install Visual studio 2015 or 2017, I only install LLVM, can I fully compile BaseTools and Edk2 code?

 

Thanks

Liming

发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Yuqi Chen
发送时间: 2021812 9:52
收件人: devel@edk2.groups.io
主题: [edk2-devel] [2021-gsoc-llvm-gnumake]: proposal for building using llvm/gnumake

 

Hi,

 

I want to push my change to my codes to edk2-staging, yet it seems like I don’t have permission to do so:

 

My mentor and I have enabled edk2 building using llvm+make and gnumake+clang in windows command prompt. The attached patch indicates changes we made to make this happen.

 

I also attach the readme file to go through the steps to build Basetools.

 

Please review our codes and thank you very much for your time.

 

Best regards,

Yuqi

 


回复: [PATCH EDK2 v3 1/1] MdeModulePkg/UefiSortLib:Add UefiSortLib unit test

gaoliming
 

Hao:
I think this patch can be merged for this stable tag. It passes code
review before soft feature freeze. ECC issue can be regarded as bug fix. Bug
fix is still allowed in soft feature freeze. Can you merge this patch before
hard feature freeze?

Thanks
Liming
-----邮件原件-----
发件人: Wu, Hao A <hao.a.wu@intel.com>
发送时间: 2021年8月11日 16:33
收件人: Liming Gao <gaoliming@byosoft.com.cn>; Wenyi Xie
<xiewenyi2@huawei.com>; devel@edk2.groups.io
抄送: songdongkuang@huawei.com; Wang, Jian J <jian.j.wang@intel.com>
主题: RE: [PATCH EDK2 v3 1/1] MdeModulePkg/UefiSortLib:Add UefiSortLib
unit test

-----Original Message-----
From: Wenyi Xie <xiewenyi2@huawei.com>
Sent: Wednesday, August 11, 2021 2:36 PM
To: devel@edk2.groups.io; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao
A
<hao.a.wu@intel.com>
Cc: songdongkuang@huawei.com; xiewenyi2@huawei.com
Subject: [PATCH EDK2 v3 1/1] MdeModulePkg/UefiSortLib:Add UefiSortLib
unit test

Adding two unit test case for UefiSortLib. One is a test on sorting an
array of
UINT32 by using PerformQuickSort, another is a test on comparing the
same
buffer by using StringCompare.
Add 'main' function name to ECC exception list to avoid ECC error.

Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Hello Liming,

Since the patch looks more like a feature than a bugfix to me, I would
like to
confirm that can I merge this change now?
I already gave my 'R-b' tag for the V2 patch on 29th July, but met some
ECC
check issues during previous merging attempt.
I verified that the latest patch can pass the merging test
(https://github.com/tianocore/edk2/pull/1892).

Best Regards,
Hao Wu



Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
---
MdeModulePkg/Test/MdeModulePkgHostTest.dsc
| 6 +
MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf |
32
+++
MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c |
207
++++++++++++++++++++
MdeModulePkg/MdeModulePkg.ci.yaml
| 1 +
4 files changed, 246 insertions(+)

diff --git a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
index 4da4692c8451..c9ec835df65d 100644
--- a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
+++ b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
@@ -41,3 +41,9 @@ [Components]
<PcdsFixedAtBuild>

gEfiMdeModulePkgTokenSpaceGuid.PcdAllowVariablePolicyEnforcementDis
able|TRUE
}
+
+ MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf {
+ <LibraryClasses>
+ UefiSortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+
+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+ }
diff --git
a/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf
b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf
new file mode 100644
index 000000000000..85d8dcd69619
--- /dev/null
+++ b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf
@@ -0,0 +1,32 @@
+## @file
+# This is a unit test for the UefiSortLib.
+#
+# Copyright (C) Huawei Technologies Co., Ltd. All rights reserved #
+SPDX-License-Identifier: BSD-2-Clause-Patent ##
+
+[Defines]
+ INF_VERSION = 0x00010017
+ BASE_NAME = UefiSortLibUnitTest
+ FILE_GUID = 271337A3-0D79-BA3E-BC03-714E518E3B1B
+ VERSION_STRING = 1.0
+ MODULE_TYPE = HOST_APPLICATION
+
+#
+# The following information is for reference only and not required by
the
build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ UefiSortLibUnitTest.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+ UnitTestLib
+ DebugLib
+ UefiSortLib
diff --git
a/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c
b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c
new file mode 100644
index 000000000000..4f44a02c5b5d
--- /dev/null
+++ b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c
@@ -0,0 +1,207 @@
+/** @file
+ Unit tests of the UefiSortLib
+
+ Copyright (C) Huawei Technologies Co., Ltd. All rights reserved
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+#include <Library/UnitTestLib.h>
+#include <Library/SortLib.h>
+
+#define UNIT_TEST_APP_NAME "UefiSortLib Unit Tests"
+#define UNIT_TEST_APP_VERSION "1.0"
+
+#define TEST_ARRAY_SIZE_9 9
+
+/**
+ The function is called by PerformQuickSort to compare int values.
+
+ @param[in] Left The pointer to first buffer.
+ @param[in] Right The pointer to second buffer.
+
+ @retval 0 Buffer1 equal to Buffer2.
+ @return <0 Buffer1 is less than Buffer2.
+ @return >0 Buffer1 is greater than Buffer2.
+
+**/
+INTN
+EFIAPI
+TestCompareFunction (
+ IN CONST VOID *Left,
+ IN CONST VOID *Right
+ )
+{
+ if (*(UINT32*)Right > *(UINT32*)Left) {
+ return 1;
+ } else if (*(UINT32*)Right < *(UINT32*)Left) {
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ Unit test for PerformQuickSort () API of the UefiSortLib.
+
+ @param[in] Context [Optional] An optional parameter that
enables:
+ 1) test-case reuse with varied parameters
and
+ 2) test-case re-entry for Target tests that
need a
+ reboot. This parameter is a VOID* and it
is the
+ responsibility of the test author to ensure
that the
+ contents are well understood by all test
cases that may
+ consume it.
+
+ @retval UNIT_TEST_PASSED The Unit test has
completed and the
test
+ case was successful.
+ @retval UNIT_TEST_ERROR_TEST_FAILED A test case assertion has
failed.
+**/
+UNIT_TEST_STATUS
+EFIAPI
+SortUINT32ArrayShouldSucceed (
+ IN UNIT_TEST_CONTEXT Context
+ )
+{
+ UINTN TestCount;
+ UINT32 Index;
+ UINT32 TestBuffer[TEST_ARRAY_SIZE_9];
+ UINT32 TestResult[TEST_ARRAY_SIZE_9];
+
+ TestCount = TEST_ARRAY_SIZE_9;
+ for (Index = 0; Index < TEST_ARRAY_SIZE_9; Index++) {
+ TestBuffer[Index] = Index + 1;
+ TestResult[Index] = TEST_ARRAY_SIZE_9 - Index; }
+
+ PerformQuickSort (TestBuffer, TestCount, sizeof (UINT32),
+ (SORT_COMPARE)TestCompareFunction);
+ UT_ASSERT_MEM_EQUAL (TestBuffer, TestResult, sizeof (UINT32) *
+ TEST_ARRAY_SIZE_9);
+
+ return UNIT_TEST_PASSED;
+}
+
+/**
+ Unit test for StringCompare () API of the UefiSortLib.
+
+ @param[in] Context [Optional] An optional parameter that
enables:
+ 1) test-case reuse with varied parameters
and
+ 2) test-case re-entry for Target tests that
need a
+ reboot. This parameter is a VOID* and it
is the
+ responsibility of the test author to ensure
that the
+ contents are well understood by all test
cases that may
+ consume it.
+
+ @retval UNIT_TEST_PASSED The Unit test has
completed and the
test
+ case was successful.
+ @retval UNIT_TEST_ERROR_TEST_FAILED A test case assertion has
failed.
+**/
+UNIT_TEST_STATUS
+EFIAPI
+CompareSameBufferShouldSucceed (
+ IN UNIT_TEST_CONTEXT Context
+ )
+{
+ INTN retval;
+ CONST CHAR16* TestBuffer[] = { L"abcdefg" };
+
+ retval = StringCompare (TestBuffer, TestBuffer); UT_ASSERT_TRUE
+ (retval == 0);
+
+ return UNIT_TEST_PASSED;
+}
+
+/**
+ Initialze the unit test framework, suite, and unit tests for the
+ UefiSortLib and run the UefiSortLib unit test.
+
+ @retval EFI_SUCCESS All test cases were dispatched.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources
available to
+ initialize the unit tests.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+UnitTestingEntry (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UNIT_TEST_FRAMEWORK_HANDLE Framework;
+ UNIT_TEST_SUITE_HANDLE SortTests;
+
+ Framework = NULL;
+
+ DEBUG(( DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME,
+ UNIT_TEST_APP_VERSION ));
+
+ //
+ // Start setting up the test framework for running the tests.
+ //
+ Status = InitUnitTestFramework (&Framework, UNIT_TEST_APP_NAME,
+ gEfiCallerBaseName, UNIT_TEST_APP_VERSION); if (EFI_ERROR (Status))
{
+ DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status
= %r\n", Status));
+ goto EXIT;
+ }
+
+ //
+ // Populate the UefiSortLib Unit Test Suite.
+ //
+ Status = CreateUnitTestSuite (&SortTests, Framework, "UefiSortLib
+ Sort Tests", "UefiSortLib.SortLib", NULL, NULL); if (EFI_ERROR
(Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for
UefiSortLib
API Tests\n"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto EXIT;
+ }
+
+ //
+ //
+ --------------Suite--------Description------------Name--------------Fu
+ nction----------------Pre---Post---Context-----------
+ //
+ AddTestCase (SortTests, "Sort the Array", "Sort",
SortUINT32ArrayShouldSucceed, NULL, NULL, NULL);
+ AddTestCase (SortTests, "Compare the Buffer", "Compare",
CompareSameBufferShouldSucceed, NULL, NULL, NULL);
+
+ //
+ // Execute the tests.
+ //
+ Status = RunAllTestSuites (Framework);
+
+EXIT:
+ if (Framework) {
+ FreeUnitTestFramework (Framework);
+ }
+
+ return Status;
+}
+
+///
+/// Avoid ECC error for function name that starts with lower case
+letter /// #define UefiSortLibUnitTestMain main
+
+/**
+ Standard POSIX C entry point for host based unit test execution.
+
+ @param[in] Argc Number of arguments
+ @param[in] Argv Array of pointers to arguments
+
+ @retval 0 Success
+ @retval other Error
+**/
+INT32
+UefiSortLibUnitTestMain (
+ IN INT32 Argc,
+ IN CHAR8 *Argv[]
+ )
+{
+ UnitTestingEntry ();
+ return 0;
+}
diff --git a/MdeModulePkg/MdeModulePkg.ci.yaml
b/MdeModulePkg/MdeModulePkg.ci.yaml
index 8e01caf94cbf..aa304f2ccd5c 100644
--- a/MdeModulePkg/MdeModulePkg.ci.yaml
+++ b/MdeModulePkg/MdeModulePkg.ci.yaml
@@ -19,6 +19,7 @@
"ExceptionList": [
"8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.UID",
"8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.HID",
+ "8001", "UefiSortLibUnitTestMain",
],
## Both file path and directory path are accepted.
"IgnoreFiles": [
--
2.20.1.windows.1


Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

Bret Barkelew
 

+ @Kinney, Michael D

 

Mike, any thoughts on when “sticking with the file convention” breaks ECC? Should I just ignore the rest of the file and pass ECC at all costs?

 

- Bret

 

From: Yao, Jiewen
Sent: Thursday, August 12, 2021 5:06 PM
To: Bret Barkelew; devel@edk2.groups.io; bret@...
Cc: Wang, Jian J; Zhang, Qi1; Kumar, Rahul1
Subject: RE: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

I don’t know the answer about ECC or PatchChecker.

I  just know we need pass CI to merge the patch.

 

Thank you

Yao Jiewen

 

From: Bret Barkelew <Bret.Barkelew@...>
Sent: Friday, August 13, 2021 1:52 AM
To: devel@edk2.groups.io; bret@...
Cc: Yao, Jiewen <jiewen.yao@...>; Wang, Jian J <jian.j.wang@...>; Zhang, Qi1 <qi1.zhang@...>; Kumar, Rahul1 <rahul1.kumar@...>
Subject: RE: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Thoughts?

 

- Bret

 

From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Bret Barkelew via groups.io <bret.barkelew@...>
Sent: Wednesday, August 11, 2021 12:37:52 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>; bret@... <bret@...>
Cc: Yao, Jiewen <jiewen.yao@...>; Jian J Wang <jian.j.wang@...>; Qi Zhang <qi1.zhang@...>; Rahul Kumar <rahul1.kumar@...>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Thoughts?

 

- Bret

 

From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Bret Barkelew via groups.io <bret.barkelew@...>
Sent: Wednesday, August 4, 2021 9:32:32 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>; bret@... <bret@...>
Cc: Yao, Jiewen <jiewen.yao@...>; Jian J Wang <jian.j.wang@...>; Qi Zhang <qi1.zhang@...>; Rahul Kumar <rahul1.kumar@...>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Poking this one.

 

  1. It’s a easy review with small, obvious code change.
  2. I need some answers on “when is it okay to violate ECC/PatchCheck, if the new code matches the style of the existing code. Should I endeavor to pass the PatchCheck and ECCCheck with this patch only, and leave it in conflict with the rest of the file?

 

Thanks!

 

- Bret

 

From: Bret Barkelew via groups.io
Sent: Friday, July 30, 2021 11:08 AM
To: devel@edk2.groups.io; bret@...
Cc: Yao, Jiewen; Jian J Wang; Qi Zhang; Rahul Kumar
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Note, even though this keeps with the style of the rest of the file, it breaks ECC:

SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib by corthon · Pull Request #1848 · tianocore/edk2 (github.com)

 

PROGRESS - --Running SecurityPkg: EccCheck Test NO-TARGET --

ERROR -

ERROR -

ERROR - EFI coding style error

ERROR - *Error code: 8001

ERROR - *Only capital letters are allowed to be used for #define declarations

ERROR - *file: //home/vsts/work/1/s/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c

ERROR - *Line number: 27

ERROR - *The #define name [RC_NV_UndefineSpaceSpecial_nvIndex] does no

 

Thoughts?

 

- Bret

 

From: Bret Barkelew via groups.io
Sent: Friday, July 30, 2021 10:55 AM
To: devel@edk2.groups.io
Cc: Yao, Jiewen; Jian J Wang; Qi Zhang; Rahul Kumar
Subject: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Used to provision and maintain certain HW-defined NV spaces.

REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2994&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397602953%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=s96M3RvxMOY831Vfr1nt%2Fz1h3cyb6jU9eFzvjKO7Dtc%3D&amp;reserved=0

Signed-off-by: Bret Barkelew <bret.barkelew@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Qi Zhang <qi1.zhang@...>
Cc: Rahul Kumar <rahul1.kumar@...>
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c | 122 ++++++++++++++++++++
 SecurityPkg/Include/Library/Tpm2CommandLib.h       |  22 ++++
 2 files changed, 144 insertions(+)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
index 87572de20164..7931fade9190 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
@@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define RC_NV_UndefineSpace_authHandle      (TPM_RC_H + TPM_RC_1)

 #define RC_NV_UndefineSpace_nvIndex         (TPM_RC_H + TPM_RC_2)

 

+#define RC_NV_UndefineSpaceSpecial_nvIndex  (TPM_RC_H + TPM_RC_1)

+

 #define RC_NV_Read_authHandle               (TPM_RC_H + TPM_RC_1)

 #define RC_NV_Read_nvIndex                  (TPM_RC_H + TPM_RC_2)

 #define RC_NV_Read_size                     (TPM_RC_P + TPM_RC_1)

@@ -74,6 +76,20 @@ typedef struct {
   TPMS_AUTH_RESPONSE         AuthSession;

 } TPM2_NV_UNDEFINESPACE_RESPONSE;

 

+typedef struct {

+  TPM2_COMMAND_HEADER       Header;

+  TPMI_RH_NV_INDEX          NvIndex;

+  TPMI_RH_PLATFORM          Platform;

+  UINT32                    AuthSessionSize;

+  TPMS_AUTH_COMMAND         AuthSession;

+} TPM2_NV_UNDEFINESPACESPECIAL_COMMAND;

+

+typedef struct {

+  TPM2_RESPONSE_HEADER       Header;

+  UINT32                     AuthSessionSize;

+  TPMS_AUTH_RESPONSE         AuthSession;

+} TPM2_NV_UNDEFINESPACESPECIAL_RESPONSE;

+

 typedef struct {

   TPM2_COMMAND_HEADER       Header;

   TPMI_RH_NV_AUTH           AuthHandle;

@@ -506,6 +522,112 @@ Done:
   return Status;

 }

 

+/**

+  This command removes an index from the TPM.

+

+  @param[in]  NvIndex             The NV Index.

+  @param[in]  IndexAuthSession    Auth session context for the Index auth/policy

+  @param[in]  PlatAuthSession     Auth session context for the Platform auth/policy

+

+  @retval EFI_SUCCESS             Operation completed successfully.

+  @retval EFI_NOT_FOUND           The command was returned successfully, but NvIndex is not found.

+  @retval EFI_UNSUPPORTED         Selected NvIndex does not support deletion through this call.

+  @retval EFI_SECURITY_VIOLATION  Deletion is not authorized by current policy session.

+  @retval EFI_INVALID_PARAMETER   The command was unsuccessful.

+  @retval EFI_DEVICE_ERROR        The command was unsuccessful.

+**/

+EFI_STATUS

+EFIAPI

+Tpm2NvUndefineSpaceSpecial (

+  IN      TPMI_RH_NV_INDEX          NvIndex,

+  IN      TPMS_AUTH_COMMAND         *IndexAuthSession OPTIONAL,

+  IN      TPMS_AUTH_COMMAND         *PlatAuthSession OPTIONAL

+  )

+{

+  EFI_STATUS                              Status;

+  TPM2_NV_UNDEFINESPACESPECIAL_COMMAND    SendBuffer;

+  TPM2_NV_UNDEFINESPACESPECIAL_RESPONSE   RecvBuffer;

+  UINT32                                  SendBufferSize;

+  UINT32                                  RecvBufferSize;

+  UINT8                                   *Buffer;

+  UINT32                                  IndexAuthSize, PlatAuthSize;

+  TPM_RC                                  ResponseCode;

+

+  //

+  // Construct command

+  //

+  SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);

+  SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_UndefineSpaceSpecial);

+

+  SendBuffer.NvIndex = SwapBytes32 (NvIndex);

+  SendBuffer.Platform = SwapBytes32 (TPM_RH_PLATFORM);

+

+  //

+  // Marshall the Auth Sessions for the two handles.

+  Buffer = (UINT8 *)&SendBuffer.AuthSession;

+  // IndexAuthSession

+  IndexAuthSize = CopyAuthSessionCommand (IndexAuthSession, Buffer);

+  Buffer += IndexAuthSize;

+  // PlatAuthSession

+  PlatAuthSize = CopyAuthSessionCommand (PlatAuthSession, Buffer);

+  Buffer += PlatAuthSize;

+  // AuthSessionSize

+  SendBuffer.AuthSessionSize = SwapBytes32(IndexAuthSize + PlatAuthSize);

+

+  // Update total command size.

+  SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);

+  SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);

+

+  //

+  // send Tpm command

+  //

+  RecvBufferSize = sizeof (RecvBuffer);

+  Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);

+  if (EFI_ERROR (Status)) {

+    goto Done;

+  }

+

+  if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {

+    DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpaceSpecial - RecvBufferSize Error - %x\n", RecvBufferSize));

+    Status = EFI_DEVICE_ERROR;

+    goto Done;

+  }

+

+  ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);

+  if (ResponseCode != TPM_RC_SUCCESS) {

+    DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpaceSpecial - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));

+  }

+  switch (ResponseCode) {

+  case TPM_RC_SUCCESS:

+    // return data

+    break;

+  case TPM_RC_ATTRIBUTES:

+  case TPM_RC_ATTRIBUTES + RC_NV_UndefineSpaceSpecial_nvIndex:

+    Status = EFI_UNSUPPORTED;

+    break;

+  case TPM_RC_NV_AUTHORIZATION:

+    Status = EFI_SECURITY_VIOLATION;

+    break;

+  case TPM_RC_HANDLE + RC_NV_UndefineSpaceSpecial_nvIndex: // TPM_RC_NV_DEFINED:

+    Status = EFI_NOT_FOUND;

+    break;

+  case TPM_RC_VALUE + RC_NV_UndefineSpace_nvIndex:

+    Status = EFI_INVALID_PARAMETER;

+    break;

+  default:

+    Status = EFI_DEVICE_ERROR;

+    break;

+  }

+

+Done:

+  //

+  // Clear AuthSession Content

+  //

+  ZeroMem (&SendBuffer, sizeof(SendBuffer));

+  ZeroMem (&RecvBuffer, sizeof(RecvBuffer));

+  return Status;

+} // Tpm2NvUndefineSpaceSpecial()

+

 /**

   This command reads a value from an area in NV memory previously defined by TPM2_NV_DefineSpace().

 

diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h b/SecurityPkg/Include/Library/Tpm2CommandLib.h
index ee8eb622951c..8d7b4998d98d 100644
--- a/SecurityPkg/Include/Library/Tpm2CommandLib.h
+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
@@ -364,6 +364,28 @@ Tpm2NvUndefineSpace (
   IN      TPMS_AUTH_COMMAND         *AuthSession OPTIONAL

   );

 

+/**

+  This command removes an index from the TPM.

+

+  @param[in]  NvIndex             The NV Index.

+  @param[in]  IndexAuthSession    Auth session context for the Index auth/policy

+  @param[in]  PlatAuthSession     Auth session context for the Platform auth/policy

+

+  @retval EFI_SUCCESS             Operation completed successfully.

+  @retval EFI_NOT_FOUND           The command was returned successfully, but NvIndex is not found.

+  @retval EFI_UNSUPPORTED         Selected NvIndex does not support deletion through this call.

+  @retval EFI_SECURITY_VIOLATION  Deletion is not authorized by current policy session.

+  @retval EFI_INVALID_PARAMETER   The command was unsuccessful.

+  @retval EFI_DEVICE_ERROR        The command was unsuccessful.

+**/

+EFI_STATUS

+EFIAPI

+Tpm2NvUndefineSpaceSpecial (

+  IN      TPMI_RH_NV_INDEX          NvIndex,

+  IN      TPMS_AUTH_COMMAND         *IndexAuthSession OPTIONAL,

+  IN      TPMS_AUTH_COMMAND         *PlatAuthSession OPTIONAL

+  );

+

 /**

   This command reads a value from an area in NV memory previously defined by TPM2_NV_DefineSpace().

 

--
2.31.1.windows.1



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78450): https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F78450&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=CWxLwgp73z2XQEa%2FN77gsCwRF73xha0RZCKwcFTlrRE%3D&amp;reserved=0
Mute This Topic: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.io%2Fmt%2F84555713%2F1822150&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=IWQ6E4yP0ECt3oYLYQa%2BnddGfcQEDMgfASlcxRuda%2BQ%3D&amp;reserved=0
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Funsub&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=qor4Y5FZEH8ch0AEmWDbe97FIQk4V1qx7IURcTHzjAU%3D&amp;reserved=0 [brbarkel@...]
-=-=-=-=-=-=

 

 

 


Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

Yao, Jiewen
 

I don’t know the answer about ECC or PatchChecker.

I  just know we need pass CI to merge the patch.

 

Thank you

Yao Jiewen

 

From: Bret Barkelew <Bret.Barkelew@...>
Sent: Friday, August 13, 2021 1:52 AM
To: devel@edk2.groups.io; bret@...
Cc: Yao, Jiewen <jiewen.yao@...>; Wang, Jian J <jian.j.wang@...>; Zhang, Qi1 <qi1.zhang@...>; Kumar, Rahul1 <rahul1.kumar@...>
Subject: RE: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Thoughts?

 

- Bret

 


From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Bret Barkelew via groups.io <bret.barkelew@...>
Sent: Wednesday, August 11, 2021 12:37:52 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>; bret@... <bret@...>
Cc: Yao, Jiewen <jiewen.yao@...>; Jian J Wang <jian.j.wang@...>; Qi Zhang <qi1.zhang@...>; Rahul Kumar <rahul1.kumar@...>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Thoughts?

 

- Bret

 


From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Bret Barkelew via groups.io <bret.barkelew@...>
Sent: Wednesday, August 4, 2021 9:32:32 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>; bret@... <bret@...>
Cc: Yao, Jiewen <jiewen.yao@...>; Jian J Wang <jian.j.wang@...>; Qi Zhang <qi1.zhang@...>; Rahul Kumar <rahul1.kumar@...>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Poking this one.

 

  1. It’s a easy review with small, obvious code change.
  2. I need some answers on “when is it okay to violate ECC/PatchCheck, if the new code matches the style of the existing code. Should I endeavor to pass the PatchCheck and ECCCheck with this patch only, and leave it in conflict with the rest of the file?

 

Thanks!

 

- Bret

 

From: Bret Barkelew via groups.io
Sent: Friday, July 30, 2021 11:08 AM
To: devel@edk2.groups.io; bret@...
Cc: Yao, Jiewen; Jian J Wang; Qi Zhang; Rahul Kumar
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Note, even though this keeps with the style of the rest of the file, it breaks ECC:

SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib by corthon · Pull Request #1848 · tianocore/edk2 (github.com)

 

PROGRESS - --Running SecurityPkg: EccCheck Test NO-TARGET --

ERROR -

ERROR -

ERROR - EFI coding style error

ERROR - *Error code: 8001

ERROR - *Only capital letters are allowed to be used for #define declarations

ERROR - *file: //home/vsts/work/1/s/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c

ERROR - *Line number: 27

ERROR - *The #define name [RC_NV_UndefineSpaceSpecial_nvIndex] does no

 

Thoughts?

 

- Bret

 

From: Bret Barkelew via groups.io
Sent: Friday, July 30, 2021 10:55 AM
To: devel@edk2.groups.io
Cc: Yao, Jiewen; Jian J Wang; Qi Zhang; Rahul Kumar
Subject: [EXTERNAL] [edk2-devel] [PATCH v1 1/1] SecurityPkg/Library: Add Tpm2NvUndefineSpaceSpecial to Tpm2CommandLib

 

Used to provision and maintain certain HW-defined NV spaces.

REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2994&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397602953%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=s96M3RvxMOY831Vfr1nt%2Fz1h3cyb6jU9eFzvjKO7Dtc%3D&amp;reserved=0

Signed-off-by: Bret Barkelew <bret.barkelew@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Qi Zhang <qi1.zhang@...>
Cc: Rahul Kumar <rahul1.kumar@...>
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c | 122 ++++++++++++++++++++
 SecurityPkg/Include/Library/Tpm2CommandLib.h       |  22 ++++
 2 files changed, 144 insertions(+)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
index 87572de20164..7931fade9190 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
@@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define RC_NV_UndefineSpace_authHandle      (TPM_RC_H + TPM_RC_1)

 #define RC_NV_UndefineSpace_nvIndex         (TPM_RC_H + TPM_RC_2)

 

+#define RC_NV_UndefineSpaceSpecial_nvIndex  (TPM_RC_H + TPM_RC_1)

+

 #define RC_NV_Read_authHandle               (TPM_RC_H + TPM_RC_1)

 #define RC_NV_Read_nvIndex                  (TPM_RC_H + TPM_RC_2)

 #define RC_NV_Read_size                     (TPM_RC_P + TPM_RC_1)

@@ -74,6 +76,20 @@ typedef struct {
   TPMS_AUTH_RESPONSE         AuthSession;

 } TPM2_NV_UNDEFINESPACE_RESPONSE;

 

+typedef struct {

+  TPM2_COMMAND_HEADER       Header;

+  TPMI_RH_NV_INDEX          NvIndex;

+  TPMI_RH_PLATFORM          Platform;

+  UINT32                    AuthSessionSize;

+  TPMS_AUTH_COMMAND         AuthSession;

+} TPM2_NV_UNDEFINESPACESPECIAL_COMMAND;

+

+typedef struct {

+  TPM2_RESPONSE_HEADER       Header;

+  UINT32                     AuthSessionSize;

+  TPMS_AUTH_RESPONSE         AuthSession;

+} TPM2_NV_UNDEFINESPACESPECIAL_RESPONSE;

+

 typedef struct {

   TPM2_COMMAND_HEADER       Header;

   TPMI_RH_NV_AUTH           AuthHandle;

@@ -506,6 +522,112 @@ Done:
   return Status;

 }

 

+/**

+  This command removes an index from the TPM.

+

+  @param[in]  NvIndex             The NV Index.

+  @param[in]  IndexAuthSession    Auth session context for the Index auth/policy

+  @param[in]  PlatAuthSession     Auth session context for the Platform auth/policy

+

+  @retval EFI_SUCCESS             Operation completed successfully.

+  @retval EFI_NOT_FOUND           The command was returned successfully, but NvIndex is not found.

+  @retval EFI_UNSUPPORTED         Selected NvIndex does not support deletion through this call.

+  @retval EFI_SECURITY_VIOLATION  Deletion is not authorized by current policy session.

+  @retval EFI_INVALID_PARAMETER   The command was unsuccessful.

+  @retval EFI_DEVICE_ERROR        The command was unsuccessful.

+**/

+EFI_STATUS

+EFIAPI

+Tpm2NvUndefineSpaceSpecial (

+  IN      TPMI_RH_NV_INDEX          NvIndex,

+  IN      TPMS_AUTH_COMMAND         *IndexAuthSession OPTIONAL,

+  IN      TPMS_AUTH_COMMAND         *PlatAuthSession OPTIONAL

+  )

+{

+  EFI_STATUS                              Status;

+  TPM2_NV_UNDEFINESPACESPECIAL_COMMAND    SendBuffer;

+  TPM2_NV_UNDEFINESPACESPECIAL_RESPONSE   RecvBuffer;

+  UINT32                                  SendBufferSize;

+  UINT32                                  RecvBufferSize;

+  UINT8                                   *Buffer;

+  UINT32                                  IndexAuthSize, PlatAuthSize;

+  TPM_RC                                  ResponseCode;

+

+  //

+  // Construct command

+  //

+  SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);

+  SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_UndefineSpaceSpecial);

+

+  SendBuffer.NvIndex = SwapBytes32 (NvIndex);

+  SendBuffer.Platform = SwapBytes32 (TPM_RH_PLATFORM);

+

+  //

+  // Marshall the Auth Sessions for the two handles.

+  Buffer = (UINT8 *)&SendBuffer.AuthSession;

+  // IndexAuthSession

+  IndexAuthSize = CopyAuthSessionCommand (IndexAuthSession, Buffer);

+  Buffer += IndexAuthSize;

+  // PlatAuthSession

+  PlatAuthSize = CopyAuthSessionCommand (PlatAuthSession, Buffer);

+  Buffer += PlatAuthSize;

+  // AuthSessionSize

+  SendBuffer.AuthSessionSize = SwapBytes32(IndexAuthSize + PlatAuthSize);

+

+  // Update total command size.

+  SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);

+  SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);

+

+  //

+  // send Tpm command

+  //

+  RecvBufferSize = sizeof (RecvBuffer);

+  Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);

+  if (EFI_ERROR (Status)) {

+    goto Done;

+  }

+

+  if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {

+    DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpaceSpecial - RecvBufferSize Error - %x\n", RecvBufferSize));

+    Status = EFI_DEVICE_ERROR;

+    goto Done;

+  }

+

+  ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);

+  if (ResponseCode != TPM_RC_SUCCESS) {

+    DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpaceSpecial - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));

+  }

+  switch (ResponseCode) {

+  case TPM_RC_SUCCESS:

+    // return data

+    break;

+  case TPM_RC_ATTRIBUTES:

+  case TPM_RC_ATTRIBUTES + RC_NV_UndefineSpaceSpecial_nvIndex:

+    Status = EFI_UNSUPPORTED;

+    break;

+  case TPM_RC_NV_AUTHORIZATION:

+    Status = EFI_SECURITY_VIOLATION;

+    break;

+  case TPM_RC_HANDLE + RC_NV_UndefineSpaceSpecial_nvIndex: // TPM_RC_NV_DEFINED:

+    Status = EFI_NOT_FOUND;

+    break;

+  case TPM_RC_VALUE + RC_NV_UndefineSpace_nvIndex:

+    Status = EFI_INVALID_PARAMETER;

+    break;

+  default:

+    Status = EFI_DEVICE_ERROR;

+    break;

+  }

+

+Done:

+  //

+  // Clear AuthSession Content

+  //

+  ZeroMem (&SendBuffer, sizeof(SendBuffer));

+  ZeroMem (&RecvBuffer, sizeof(RecvBuffer));

+  return Status;

+} // Tpm2NvUndefineSpaceSpecial()

+

 /**

   This command reads a value from an area in NV memory previously defined by TPM2_NV_DefineSpace().

 

diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h b/SecurityPkg/Include/Library/Tpm2CommandLib.h
index ee8eb622951c..8d7b4998d98d 100644
--- a/SecurityPkg/Include/Library/Tpm2CommandLib.h
+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
@@ -364,6 +364,28 @@ Tpm2NvUndefineSpace (
   IN      TPMS_AUTH_COMMAND         *AuthSession OPTIONAL

   );

 

+/**

+  This command removes an index from the TPM.

+

+  @param[in]  NvIndex             The NV Index.

+  @param[in]  IndexAuthSession    Auth session context for the Index auth/policy

+  @param[in]  PlatAuthSession     Auth session context for the Platform auth/policy

+

+  @retval EFI_SUCCESS             Operation completed successfully.

+  @retval EFI_NOT_FOUND           The command was returned successfully, but NvIndex is not found.

+  @retval EFI_UNSUPPORTED         Selected NvIndex does not support deletion through this call.

+  @retval EFI_SECURITY_VIOLATION  Deletion is not authorized by current policy session.

+  @retval EFI_INVALID_PARAMETER   The command was unsuccessful.

+  @retval EFI_DEVICE_ERROR        The command was unsuccessful.

+**/

+EFI_STATUS

+EFIAPI

+Tpm2NvUndefineSpaceSpecial (

+  IN      TPMI_RH_NV_INDEX          NvIndex,

+  IN      TPMS_AUTH_COMMAND         *IndexAuthSession OPTIONAL,

+  IN      TPMS_AUTH_COMMAND         *PlatAuthSession OPTIONAL

+  );

+

 /**

   This command reads a value from an area in NV memory previously defined by TPM2_NV_DefineSpace().

 

--
2.31.1.windows.1



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78450): https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F78450&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=CWxLwgp73z2XQEa%2FN77gsCwRF73xha0RZCKwcFTlrRE%3D&amp;reserved=0
Mute This Topic: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.io%2Fmt%2F84555713%2F1822150&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=IWQ6E4yP0ECt3oYLYQa%2BnddGfcQEDMgfASlcxRuda%2BQ%3D&amp;reserved=0
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Funsub&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7Cb7ae3c62047c48fc85d908d953833ca0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637632645397612922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=qor4Y5FZEH8ch0AEmWDbe97FIQk4V1qx7IURcTHzjAU%3D&amp;reserved=0 [brbarkel@...]
-=-=-=-=-=-=

 

 


[PATCH v2 1/1] MdeModulePkg/Console: Improve encoding of box drawing characters

Caden Kline
 

Improved encoding of box drawing characters for different terminal types.
This includes Dec special graphics mode and more utf8.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Caden Kline <cadenkline9@gmail.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---

Notes:
v2:
- code style changes to fix indents and comments [Hao A Wu]

MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h | 26 +-
MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c | 2 +-
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c | 321 ++++++++=
+++++++-----
3 files changed, 271 insertions(+), 78 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeMod=
ulePkg/Universal/Console/TerminalDxe/Terminal.h
index 360e58e84743..1eab439531dc 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -122,7 +122,12 @@ typedef struct {
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;=0D
LIST_ENTRY NotifyList;=0D
EFI_EVENT KeyNotifyProcessEvent;=0D
+ BOOLEAN DecSpecialGraphicsMode;=0D
} TERMINAL_DEV;=0D
+//=0D
+// This the length the escape sequences for entering and exiting Dec Speci=
al Graphics Mode=0D
+//=0D
+#define LENGTH_DEC_ESCAPE 0x03=0D
=0D
#define INPUT_STATE_DEFAULT 0x00=0D
#define INPUT_STATE_ESC 0x01=0D
@@ -169,6 +174,7 @@ typedef struct {
UINT16 Unicode;=0D
CHAR8 PcAnsi;=0D
CHAR8 Ascii;=0D
+ CHAR8 DecSpecialGraphics;=0D
} UNICODE_TO_CHAR;=0D
=0D
//=0D
@@ -1367,20 +1373,22 @@ Utf8ToUnicode (
/**=0D
Detects if a Unicode char is for Box Drawing text graphics.=0D
=0D
- @param Graphic Unicode char to test.=0D
- @param PcAnsi Optional pointer to return PCANSI equivalent of=0D
- Graphic.=0D
- @param Ascii Optional pointer to return ASCII equivalent of=0D
- Graphic.=0D
-=0D
- @retval TRUE If Graphic is a supported Unicode Box Drawing chara=
cter.=0D
+ @param Graphic Unicode char to test.=0D
+ @param PcAnsi Optional pointer to return PCANSI equivalent=
of=0D
+ Graphic.=0D
+ @param Ascii Optional pointer to return ASCII equivalent =
of=0D
+ Graphic.=0D
+ @param DecSpecialGraphics Optional pointer to return Dec Special Graph=
ics equivalent of=0D
+ Graphic.=0D
+ @retval TRUE If Graphic is a supported Unicode Box Drawin=
g character.=0D
=0D
**/=0D
BOOLEAN=0D
TerminalIsValidTextGraphics (=0D
IN CHAR16 Graphic,=0D
- OUT CHAR8 *PcAnsi, OPTIONAL=0D
- OUT CHAR8 *Ascii OPTIONAL=0D
+ OUT CHAR8 *PcAnsi, OPTIONAL=0D
+ OUT CHAR8 *Ascii, OPTIONAL=0D
+ OUT CHAR8 *DecSpecialGraphics OPTIONAL=0D
);=0D
=0D
/**=0D
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c b/MdeModuleP=
kg/Universal/Console/TerminalDxe/Ansi.c
index f117d90b9de3..5ae5a4f0212e 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
@@ -63,7 +63,7 @@ AnsiTestString (
=0D
if ( !(TerminalIsValidAscii (*WString) ||=0D
TerminalIsValidEfiCntlChar (*WString) ||=0D
- TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL) )) {=0D
+ TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL, NULL) )=
) {=0D
=0D
return EFI_UNSUPPORTED;=0D
}=0D
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/=
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
index aae470e9562c..6da1fa64a2f3 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
@@ -16,61 +16,59 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//=0D
//=0D
UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] =3D {=0D
- { BOXDRAW_HORIZONTAL, 0xc4, L'-' },=0D
- { BOXDRAW_VERTICAL, 0xb3, L'|' },=0D
- { BOXDRAW_DOWN_RIGHT, 0xda, L'/' },=0D
- { BOXDRAW_DOWN_LEFT, 0xbf, L'\\' },=0D
- { BOXDRAW_UP_RIGHT, 0xc0, L'\\' },=0D
- { BOXDRAW_UP_LEFT, 0xd9, L'/' },=0D
- { BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|' },=0D
- { BOXDRAW_VERTICAL_LEFT, 0xb4, L'|' },=0D
- { BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+' },=0D
- { BOXDRAW_UP_HORIZONTAL, 0xc1, L'+' },=0D
- { BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+' },=0D
- { BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-' },=0D
- { BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|' },=0D
- { BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/' },=0D
- { BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/' },=0D
- { BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/' },=0D
- { BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, L'\\' },=0D
- { BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, L'\\' },=0D
- { BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, L'\\' },=0D
- { BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, L'\\' },=0D
- { BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, L'\\' },=0D
- { BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, L'\\' },=0D
- { BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/' },=0D
- { BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/' },=0D
- { BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/' },=0D
- { BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|' },=0D
- { BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|' },=0D
- { BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|' },=0D
- { BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|' },=0D
- { BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|' },=0D
- { BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|' },=0D
- { BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+' },=0D
- { BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+' },=0D
- { BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+' },=0D
- { BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+' },=0D
- { BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+' },=0D
- { BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+' },=0D
- { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+' },=0D
- { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+' },=0D
- { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+' },=0D
+ { BOXDRAW_HORIZONTAL, 0xc4, L'-', 0x71 },=0D
+ { BOXDRAW_VERTICAL, 0xb3, L'|', 0x78 },=0D
+ { BOXDRAW_DOWN_RIGHT, 0xda, L'/', 0x6c },=0D
+ { BOXDRAW_DOWN_LEFT, 0xbf, L'\\', 0x6b },=0D
+ { BOXDRAW_UP_RIGHT, 0xc0, L'\\', 0x6d },=0D
+ { BOXDRAW_UP_LEFT, 0xd9, L'/', 0x6a },=0D
+ { BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|', 0x74 },=0D
+ { BOXDRAW_VERTICAL_LEFT, 0xb4, L'|', 0x75 },=0D
+ { BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+', 0x77 },=0D
+ { BOXDRAW_UP_HORIZONTAL, 0xc1, L'+', 0x76 },=0D
+ { BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+', 0x6e },=0D
+ { BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-', 0x71 },=0D
+ { BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|', 0x78 },=0D
+ { BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/', 0x6c },=0D
+ { BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/', 0x6c },=0D
+ { BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/', 0x6c },=0D
+ { BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, L'\\', 0x6b },=0D
+ { BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, L'\\', 0x6b },=0D
+ { BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, L'\\', 0x6b },=0D
+ { BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, L'\\', 0x6d },=0D
+ { BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, L'\\', 0x6d },=0D
+ { BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, L'\\', 0x6d },=0D
+ { BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/', 0x6a },=0D
+ { BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/', 0x6a },=0D
+ { BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/', 0x6a },=0D
+ { BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|', 0x74 },=0D
+ { BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|', 0x74 },=0D
+ { BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|', 0x74 },=0D
+ { BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|', 0x75 },=0D
+ { BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|', 0x75 },=0D
+ { BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|', 0x75 },=0D
+ { BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+', 0x77 },=0D
+ { BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+', 0x77 },=0D
+ { BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+', 0x77 },=0D
+ { BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+', 0x76 },=0D
+ { BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+', 0x76 },=0D
+ { BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+', 0x76 },=0D
+ { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+', 0x6e },=0D
+ { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+', 0x6e },=0D
+ { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+', 0x6e },=0D
=0D
- { BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*' },=0D
- { BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+' },=0D
+ { BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*', 0x61 },=0D
+ { BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+', 0x61 },=0D
=0D
- { GEOMETRICSHAPE_UP_TRIANGLE, '^', L'^' },=0D
- { GEOMETRICSHAPE_RIGHT_TRIANGLE, '>', L'>' },=0D
- { GEOMETRICSHAPE_DOWN_TRIANGLE, 'v', L'v' },=0D
- { GEOMETRICSHAPE_LEFT_TRIANGLE, '<', L'<' },=0D
+ { GEOMETRICSHAPE_UP_TRIANGLE, '^', L'^', L'^' },=0D
+ { GEOMETRICSHAPE_RIGHT_TRIANGLE, '>', L'>', L'>' },=0D
+ { GEOMETRICSHAPE_DOWN_TRIANGLE, 'v', L'v', L'v' },=0D
+ { GEOMETRICSHAPE_LEFT_TRIANGLE, '<', L'<', L'<' },=0D
=0D
- { ARROW_LEFT, '<', L'<' },=0D
- { ARROW_UP, '^', L'^' },=0D
- { ARROW_RIGHT, '>', L'>' },=0D
- { ARROW_DOWN, 'v', L'v' },=0D
-=0D
- { 0x0000, 0x00, L'\0' }=0D
+ { ARROW_LEFT, '<', L'<', L'<' },=0D
+ { ARROW_UP, '^', L'^', L'^' },=0D
+ { ARROW_RIGHT, '>', L'>', L'>' },=0D
+ { ARROW_DOWN, 'v', L'v', L'v' },=0D
};=0D
=0D
CHAR16 mSetModeString[] =3D { ESC, '[', '=3D', '3', 'h', 0 };=0D
@@ -80,6 +78,8 @@ CHAR16 mSetCursorPositionString[] =3D { ESC, '[', '0', '=
0', ';', '0', '0', 'H', 0
CHAR16 mCursorForwardString[] =3D { ESC, '[', '0', '0', 'C', 0 };=0D
CHAR16 mCursorBackwardString[] =3D { ESC, '[', '0', '0', 'D', 0 };=0D
=0D
+CHAR8 SetDecModeString[] =3D {ESC, 0x28, 0x30};=0D
+CHAR8 ExitDecModeString[] =3D {ESC, 0x28, 0x42};=0D
//=0D
// Body of the ConOut functions=0D
//=0D
@@ -183,16 +183,19 @@ TerminalConOutOutputString (
EFI_STATUS Status;=0D
UINT8 ValidBytes;=0D
CHAR8 CrLfStr[2];=0D
+ CHAR8 DecChar;=0D
+ UINTN ModeSwitchLength;=0D
//=0D
// flag used to indicate whether condition happens which will cause=0D
// return EFI_WARN_UNKNOWN_GLYPH=0D
//=0D
BOOLEAN Warning;=0D
=0D
- ValidBytes =3D 0;=0D
- Warning =3D FALSE;=0D
- AsciiChar =3D 0;=0D
-=0D
+ ValidBytes =3D 0;=0D
+ Warning =3D FALSE;=0D
+ AsciiChar =3D 0;=0D
+ DecChar =3D 0;=0D
+ ModeSwitchLength =3D LENGTH_DEC_ESCAPE;=0D
//=0D
// get Terminal device data structure pointer.=0D
//=0D
@@ -217,17 +220,137 @@ TerminalConOutOutputString (
for (; *WString !=3D CHAR_NULL; WString++) {=0D
=0D
switch (TerminalDevice->TerminalType) {=0D
-=0D
case TerminalTypePcAnsi:=0D
- case TerminalTypeVt100:=0D
- case TerminalTypeVt100Plus:=0D
- case TerminalTypeTtyTerm:=0D
- case TerminalTypeLinux:=0D
+ if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar=
, NULL)) {=0D
+ //=0D
+ // If it's not a graphic character convert Unicode to ASCII.=0D
+ //=0D
+ GraphicChar =3D (CHAR8)*WString;=0D
+=0D
+ if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntl=
Char (GraphicChar))) {=0D
+ //=0D
+ // when this driver use the OutputString to output control strin=
g,=0D
+ // TerminalDevice->OutputEscChar is set to let the Esc char=0D
+ // to be output to the terminal emulation software.=0D
+ //=0D
+ if ((GraphicChar =3D=3D 27) && TerminalDevice->OutputEscChar) {=
=0D
+ GraphicChar =3D 27;=0D
+ } else {=0D
+ GraphicChar =3D '?';=0D
+ Warning =3D TRUE;=0D
+ }=0D
+ }=0D
+=0D
+ AsciiChar =3D GraphicChar;=0D
+ }=0D
+ Length =3D 1;=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &Length,=0D
+ &GraphicChar=0D
+ );=0D
+=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
+ }=0D
+=0D
+ break;=0D
case TerminalTypeXtermR6:=0D
- case TerminalTypeVt400:=0D
case TerminalTypeSCO:=0D
+ if (TerminalIsValidTextGraphics (*WString, NULL, NULL, &DecChar) && =
!TerminalIsValidAscii (*WString)) {=0D
+ //=0D
+ // Box graphics are split into 2 types simple and advanced.=0D
+ // Simple are drawn with dec special graphics.=0D
+ // Advanced are drawn with utf8.=0D
+ // This checks for simple because they have a lower value than the=
advanced.=0D
+ if(*WString < BOXDRAW_DOUBLE_HORIZONTAL) {=0D
+ if (!TerminalDevice->DecSpecialGraphicsMode) {=0D
+ ValidBytes =3D 0;=0D
+ ModeSwitchLength =3D LENGTH_DEC_ESCAPE;=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=
=0D
+ &ModeSwitchLength,=0D
+ (UINT8 *)SetDecModeString=
=0D
+ );=0D
+ TerminalDevice->DecSpecialGraphicsMode =3D TRUE;=0D
+ }=0D
=0D
- if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar=
)) {=0D
+ GraphicChar =3D DecChar;=0D
+ Length =3D 1;=0D
+ } else {=0D
+ if (TerminalDevice->DecSpecialGraphicsMode) {=0D
+ ModeSwitchLength =3D LENGTH_DEC_ESCAPE;=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=
=0D
+ &ModeSwitchLength,=0D
+ (UINT8 *)ExitDecModeString=
=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
+ }=0D
+=0D
+ TerminalDevice->DecSpecialGraphicsMode =3D FALSE;=0D
+ }=0D
+=0D
+ UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);=0D
+ Length =3D ValidBytes;=0D
+ }=0D
+ } else {=0D
+ if (TerminalDevice->DecSpecialGraphicsMode) {=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &ModeSwitchLength,=0D
+ (UINT8 *)ExitDecModeString=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
+ }=0D
+=0D
+ TerminalDevice->DecSpecialGraphicsMode =3D FALSE;=0D
+ }=0D
+=0D
+ GraphicChar =3D (CHAR8)*WString;=0D
+=0D
+ if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntl=
Char (GraphicChar))) {=0D
+ //=0D
+ // when this driver use the OutputString to output control strin=
g,=0D
+ // TerminalDevice->OutputEscChar is set to let the Esc char=0D
+ // to be output to the terminal emulation software.=0D
+ //=0D
+ if ((GraphicChar =3D=3D 27) && TerminalDevice->OutputEscChar) {=
=0D
+ GraphicChar =3D 27;=0D
+ Length =3D 1;=0D
+ } else {=0D
+ UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);=0D
+ Length =3D ValidBytes;=0D
+ }=0D
+ } else {=0D
+ Length =3D 1;=0D
+ }=0D
+ }=0D
+=0D
+ if (ValidBytes) {=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &Length,=0D
+ (UINT8 *)&Utf8Char=0D
+ );=0D
+ ValidBytes =3D 0;=0D
+ } else {=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &Length,=0D
+ &GraphicChar=0D
+ );=0D
+ }=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
+ }=0D
+=0D
+ break;=0D
+ case TerminalTypeVt100:=0D
+ case TerminalTypeTtyTerm:=0D
+ if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar=
, NULL)) {=0D
//=0D
// If it's not a graphic character convert Unicode to ASCII.=0D
//=0D
@@ -248,14 +371,70 @@ TerminalConOutOutputString (
}=0D
=0D
AsciiChar =3D GraphicChar;=0D
-=0D
}=0D
=0D
- if (TerminalDevice->TerminalType !=3D TerminalTypePcAnsi) {=0D
- GraphicChar =3D AsciiChar;=0D
+ GraphicChar =3D AsciiChar;=0D
+=0D
+ Length =3D 1;=0D
+=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &Length,=0D
+ &GraphicChar=0D
+ );=0D
+=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
}=0D
=0D
+ break;=0D
+ case TerminalTypeVt100Plus:=0D
+ case TerminalTypeVt400:=0D
Length =3D 1;=0D
+ if (TerminalIsValidTextGraphics (*WString, NULL, NULL, &DecChar)) {=
=0D
+ if (!TerminalDevice->DecSpecialGraphicsMode) {=0D
+ ModeSwitchLength =3D LENGTH_DEC_ESCAPE;=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &ModeSwitchLength,=0D
+ (UINT8 *)SetDecModeString=0D
+ );=0D
+ TerminalDevice->DecSpecialGraphicsMode =3D TRUE;=0D
+ }=0D
+=0D
+ GraphicChar =3D DecChar;=0D
+ } else {=0D
+ if (TerminalDevice->DecSpecialGraphicsMode) {=0D
+ ModeSwitchLength =3D LENGTH_DEC_ESCAPE;=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &ModeSwitchLength,=0D
+ (UINT8 *)ExitDecModeString=0D
+ );=0D
+=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
+ }=0D
+=0D
+ TerminalDevice->DecSpecialGraphicsMode =3D FALSE;=0D
+ }=0D
+=0D
+ GraphicChar =3D (CHAR8)*WString;=0D
+=0D
+ if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntl=
Char (GraphicChar))) {=0D
+ //=0D
+ // when this driver use the OutputString to output control strin=
g,=0D
+ // TerminalDevice->OutputEscChar is set to let the Esc char=0D
+ // to be output to the terminal emulation software.=0D
+ //=0D
+ if ((GraphicChar =3D=3D 27) && TerminalDevice->OutputEscChar) {=
=0D
+ GraphicChar =3D 27;=0D
+ } else {=0D
+ GraphicChar =3D '?';=0D
+ Warning =3D TRUE;=0D
+ }=0D
+ }=0D
+ }=0D
=0D
Status =3D TerminalDevice->SerialIo->Write (=0D
TerminalDevice->SerialIo,=0D
@@ -268,7 +447,7 @@ TerminalConOutOutputString (
}=0D
=0D
break;=0D
-=0D
+ case TerminalTypeLinux:=0D
case TerminalTypeVtUtf8:=0D
UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);=0D
Length =3D ValidBytes;=0D
@@ -280,8 +459,10 @@ TerminalConOutOutputString (
if (EFI_ERROR (Status)) {=0D
goto OutputError;=0D
}=0D
+=0D
break;=0D
}=0D
+=0D
//=0D
// Update cursor position.=0D
//=0D
@@ -875,7 +1056,8 @@ BOOLEAN
TerminalIsValidTextGraphics (=0D
IN CHAR16 Graphic,=0D
OUT CHAR8 *PcAnsi, OPTIONAL=0D
- OUT CHAR8 *Ascii OPTIONAL=0D
+ OUT CHAR8 *Ascii, OPTIONAL=0D
+ OUT CHAR8 *DecSpecialGraphics OPTIONAL=0D
)=0D
{=0D
UNICODE_TO_CHAR *Table;=0D
@@ -897,6 +1079,9 @@ TerminalIsValidTextGraphics (
if (Ascii !=3D NULL) {=0D
*Ascii =3D Table->Ascii;=0D
}=0D
+ if (DecSpecialGraphics !=3D NULL){=0D
+ *DecSpecialGraphics =3D Table->DecSpecialGraphics;=0D
+ }=0D
=0D
return TRUE;=0D
}=0D
--=20
2.32.0


[PATCH v2 0/1] MdeModulePkg/Console: Improve encoding of box drawing characters

Caden Kline
 

Improved encoding of box drawing characters for different terminal types.
This includes Dec special graphics mode and more utf8.
According to this table https://github.com/tianocore/tianocore.github.io/wiki/Tasks-Terminal-driver-improvements

v1 mail:https://edk2.groups.io/g/devel/message/78390
v1 github: https://github.com/Pokemod97/edk2/tree/terminal-driver-characters
v2 github: https://github.com/Pokemod97/edk2/tree/terminal-driver-characters-v2

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Caden Kline <cadenkline9@gmail.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

Caden Kline (1):
MdeModulePkg/Console: Improve encoding of box drawing characters

MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h | 26 +-
MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c | 2 +-
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c | 321 +++++++++++++++-----
3 files changed, 271 insertions(+), 78 deletions(-)

--
2.32.0


Re: [PATCH 04/23] MdePkg: Add Tdx.h

Min Xu
 

Thanks for the reminder. I will add the link in the header in next version.

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@intel.com>
Sent: Friday, August 13, 2021 4:52 AM
To: Xu, Min M <min.m.xu@intel.com>; devel@edk2.groups.io; Kinney, Michael
D <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>; Liu, Zhiguang
<zhiguang.liu@intel.com>
Subject: RE: [PATCH 04/23] MdePkg: Add Tdx.h

Hi Min,

Please add the link to the public documentation to the Tdx.h file header

Thanks,

Mike

-----Original Message-----
From: Xu, Min M <min.m.xu@intel.com>
Sent: Thursday, August 12, 2021 4:57 AM
To: devel@edk2.groups.io
Cc: Xu, Min M <min.m.xu@intel.com>; Kinney, Michael D
<michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
Liu, Zhiguang <zhiguang.liu@intel.com>
Subject: [PATCH 04/23] MdePkg: Add Tdx.h

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

Tdx.h includes the Intel Trust Domain Extension definitions.

Detailed information can be found in below document:
https://software.intel.com/content/dam/develop/external/us/en/
documents/tdx-module-1eas-v0.85.039.pdf

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
---
MdePkg/Include/IndustryStandard/Tdx.h | 200
++++++++++++++++++++++++++
1 file changed, 200 insertions(+)
create mode 100644 MdePkg/Include/IndustryStandard/Tdx.h

diff --git a/MdePkg/Include/IndustryStandard/Tdx.h
b/MdePkg/Include/IndustryStandard/Tdx.h
new file mode 100644
index 000000000000..c50470708b56
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Tdx.h
@@ -0,0 +1,200 @@
+/** @file
+ Intel Trust Domain Extension definitions
+
+ Copyright (c) 2020 - 2021, Intel Corporation. All rights
+ reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef MDE_PKG_TDX_H_
+#define MDE_PKG_TDX_H_
+
+#define EXIT_REASON_EXTERNAL_INTERRUPT 1
+#define EXIT_REASON_TRIPLE_FAULT 2
+
+#define EXIT_REASON_PENDING_INTERRUPT 7
+#define EXIT_REASON_NMI_WINDOW 8
+#define EXIT_REASON_TASK_SWITCH 9
+#define EXIT_REASON_CPUID 10
+#define EXIT_REASON_HLT 12
+#define EXIT_REASON_INVD 13
+#define EXIT_REASON_INVLPG 14
+#define EXIT_REASON_RDPMC 15
+#define EXIT_REASON_RDTSC 16
+#define EXIT_REASON_VMCALL 18
+#define EXIT_REASON_VMCLEAR 19
+#define EXIT_REASON_VMLAUNCH 20
+#define EXIT_REASON_VMPTRLD 21
+#define EXIT_REASON_VMPTRST 22
+#define EXIT_REASON_VMREAD 23
+#define EXIT_REASON_VMRESUME 24
+#define EXIT_REASON_VMWRITE 25
+#define EXIT_REASON_VMOFF 26
+#define EXIT_REASON_VMON 27
+#define EXIT_REASON_CR_ACCESS 28
+#define EXIT_REASON_DR_ACCESS 29
+#define EXIT_REASON_IO_INSTRUCTION 30
+#define EXIT_REASON_MSR_READ 31
+#define EXIT_REASON_MSR_WRITE 32
+#define EXIT_REASON_INVALID_STATE 33
+#define EXIT_REASON_MSR_LOAD_FAIL 34
+#define EXIT_REASON_MWAIT_INSTRUCTION 36
+#define EXIT_REASON_MONITOR_TRAP_FLAG 37
+#define EXIT_REASON_MONITOR_INSTRUCTION 39
+#define EXIT_REASON_PAUSE_INSTRUCTION 40
+#define EXIT_REASON_MCE_DURING_VMENTRY 41 #define
+EXIT_REASON_TPR_BELOW_THRESHOLD 43
+#define EXIT_REASON_APIC_ACCESS 44
+#define EXIT_REASON_EOI_INDUCED 45
+#define EXIT_REASON_GDTR_IDTR 46
+#define EXIT_REASON_LDTR_TR 47
+#define EXIT_REASON_EPT_VIOLATION 48
+#define EXIT_REASON_EPT_MISCONFIG 49
+#define EXIT_REASON_INVEPT 50
+#define EXIT_REASON_RDTSCP 51
+#define EXIT_REASON_PREEMPTION_TIMER 52
+#define EXIT_REASON_INVVPID 53
+#define EXIT_REASON_WBINVD 54
+#define EXIT_REASON_XSETBV 55
+#define EXIT_REASON_APIC_WRITE 56
+#define EXIT_REASON_RDRAND 57
+#define EXIT_REASON_INVPCID 58
+#define EXIT_REASON_VMFUNC 59
+#define EXIT_REASON_ENCLS 60
+#define EXIT_REASON_RDSEED 61
+#define EXIT_REASON_PML_FULL 62
+#define EXIT_REASON_XSAVES 63
+#define EXIT_REASON_XRSTORS 64
+
+// TDCALL API Function Completion Status Codes
+#define TDX_EXIT_REASON_SUCCESS 0x0000000000000000
+#define TDX_EXIT_REASON_PAGE_ALREADY_ACCEPTED
0x00000B0A00000000
+#define TDX_EXIT_REASON_PAGE_SIZE_MISMATCH
0xC0000B0B00000000
+#define TDX_EXIT_REASON_OPERAND_INVALID 0xC000010000000000
+#define TDX_EXIT_REASON_OPERAND_BUSY 0x8000020000000000
+
+// TDCALL [TDG.MEM.PAGE.ACCEPT] page size
+#define TDCALL_ACCEPT_PAGE_SIZE_4K 0
+#define TDCALL_ACCEPT_PAGE_SIZE_2M 1
+#define TDCALL_ACCEPT_PAGE_SIZE_1G 2
+
+#define TDCALL_TDVMCALL 0
+#define TDCALL_TDINFO 1
+#define TDCALL_TDEXTENDRTMR 2
+#define TDCALL_TDGETVEINFO 3
+#define TDCALL_TDREPORT 4
+#define TDCALL_TDSETCPUIDVE 5
+#define TDCALL_TDACCEPTPAGE 6
+
+#define TDVMCALL_CPUID 0x0000a
+#define TDVMCALL_HALT 0x0000c
+#define TDVMCALL_IO 0x0001e
+#define TDVMCALL_RDMSR 0x0001f
+#define TDVMCALL_WRMSR 0x00020
+#define TDVMCALL_MMIO 0x00030
+#define TDVMCALL_PCONFIG 0x00041
+
+#define TDVMCALL_GET_TDVMCALL_INFO 0x10000
+#define TDVMCALL_MAPGPA 0x10001
+#define TDVMCALL_GET_QUOTE 0x10002
+#define TDVMCALL_REPORT_FATAL_ERR 0x10003
+#define TDVMCALL_SETUP_EVENT_NOTIFY 0x10004
+
+#pragma pack(1)
+typedef struct {
+ UINT64 Data[6];
+} TDCALL_GENERIC_RETURN_DATA;
+
+typedef struct {
+ UINT64 Gpaw;
+ UINT64 Attributes;
+ UINT32 MaxVcpus;
+ UINT32 NumVcpus;
+ UINT64 Resv[3];
+} TDCALL_INFO_RETURN_DATA;
+
+typedef union {
+ UINT64 Val;
+ struct {
+ UINT32 Size:3;
+ UINT32 Direction:1;
+ UINT32 String:1;
+ UINT32 Rep:1;
+ UINT32 Encoding:1;
+ UINT32 Resv:9;
+ UINT32 Port:16;
+ UINT32 Resv2;
+ } Io;
+} VMX_EXIT_QUALIFICATION;
+
+typedef struct {
+ UINT32 ExitReason;
+ UINT32 Resv;
+ VMX_EXIT_QUALIFICATION ExitQualification;
+ UINT64 GuestLA;
+ UINT64 GuestPA;
+ UINT32 ExitInstructionLength;
+ UINT32 ExitInstructionInfo;
+ UINT32 Resv1;
+} TDCALL_VEINFO_RETURN_DATA;
+
+typedef union {
+ TDCALL_GENERIC_RETURN_DATA Generic;
+ TDCALL_INFO_RETURN_DATA TdInfo;
+ TDCALL_VEINFO_RETURN_DATA VeInfo;
+} TD_RETURN_DATA;
+
+/* data structure used in TDREPORT_STRUCT */ typedef struct {
+ UINT8 Type;
+ UINT8 Subtype;
+ UINT8 Version;
+ UINT8 Rsvd;
+} TD_REPORT_TYPE;
+
+typedef struct {
+ TD_REPORT_TYPE ReportType;
+ UINT8 Rsvd1[12];
+ UINT8 CpuSvn[16];
+ UINT8 TeeTcbInfoHash[48];
+ UINT8 TeeInfoHash[48];
+ UINT8 ReportData[64];
+ UINT8 Rsvd2[32];
+ UINT8 Mac[32];
+} REPORTMACSTRUCT;
+
+typedef struct {
+ UINT8 Seam[2];
+ UINT8 Rsvd[14];
+} TEE_TCB_SVN;
+
+typedef struct {
+ UINT8 Valid[8];
+ TEE_TCB_SVN TeeTcbSvn;
+ UINT8 Mrseam[48];
+ UINT8 Mrsignerseam[48];
+ UINT8 Attributes[8];
+ UINT8 Rsvd[111];
+} TEE_TCB_INFO;
+
+typedef struct {
+ UINT8 Attributes[8];
+ UINT8 Xfam[8];
+ UINT8 Mrtd[48];
+ UINT8 Mrconfigid[48];
+ UINT8 Mrowner[48];
+ UINT8 Mrownerconfig[48];
+ UINT8 Rtmrs[4][48];
+ UINT8 Rsvd[112];
+} TDINFO;
+
+typedef struct {
+ REPORTMACSTRUCT ReportMacStruct;
+ TEE_TCB_INFO TeeTcbInfo;
+ UINT8 Rsvd[17];
+ TDINFO Tdinfo;
+} TDREPORT_STRUCT;
+
+#pragma pack()
+
+#endif
--
2.29.2.windows.2


Re: [PATCH 0/3] Add support for gdb and lldb

Andrew Fish
 

Rebecca,

Sorry I may have been a commit or 2 behind on the private branch.

On Aug 11, 2021, at 5:30 PM, Rebecca Cran <rebecca@nuviainc.com> wrote:

I should note my comments are against https://github.com/ajfish/edk2/tree/BZ3500-gdb, not the patches you sent out.

AARCH64 is working great! The only thing I noticed that doesn't look quite right is the following message on startup when running gdb -ex "target remote localhost:1234" -ex "source efi_gdb.py" -ex "efi":


Traceback (most recent call last):
File "efi_gdb.py", line 804, in invoke
self.restore_user_state()
File "efi_gdb.py", line 690, in restore_user_state
self.user_selected_frame.select()
gdb.error: Frame is invalid.
Traceback (most recent call last):
File "efi_gdb.py", line 822, in invoke
gdb.execute('efi symbols --extended')
gdb.error: Error occurred in Python: Frame is invalid.
Error occurred in Python: Error occurred in Python: Frame is invalid.

Can you try again? I think I fixed this? The `efi symbols` command is saving user context, so it can restore the context. If there is not a valid target it can fail.

Also thanks for testing on AARCH64!!!!

Running `bt` shows the full set of frames except for the last one which as expected is shown as ??.
I noticed the stack unwind in the gdb builds can be a little wonky at times, I had to add some code to filter out the cruft.

Thanks,

Andrew Fish


--

Rebecca Cran


On 8/11/21 5:22 PM, Andrew Fish wrote:

On Aug 11, 2021, at 3:11 PM, Rebecca Cran <rebecca@nuviainc.com> wrote:

I realized the Arm gcc 10.3 aarch64 download from https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads uses Python 2.7.18 and not Python 3, so the f-Strings and likely more cause problems. I suspect at this point there's little point putting effort into supporting Python 2.
I’ve not tested on ARM yet, so please let me know if it works. I’d like to avoid Python 2.7 support is possible given it is passed its best by date.

I noticed a couple of issues though: in efi_debugging.py the Attributes text is partially underlined with the non-ASCII characters '——————' instead of '----------'.
Thanks did not notice that.

Attributes
——————----
_dict_ : dictionay


There are also a couple of typos of 'dictionary':


_dict_ : dictionay
Shoot though I fixed those




Thanks,

Andrew Fish

--
Rebecca Cran


On 8/8/21 3:46 PM, Andrew Fish via groups.io wrote:
This patch set adds debugging support for gdb and lldb.
It also adds generic debugging classes that use a file like object to
make it easy to import into any debugger that supports Python.

Since these debugging scripts don't depend on any EFI code I was thinking
we could place them in the root of the repo to be easy to discover.

I've tested gdb on Ubuntu and lldb on macOS for IA32 and X64.

Andrew Fish (3):
efi_debugging.py: - Add debugger agnostic debugging Python Classes
efi_gdb.py: - Add gdb EFI commands and pretty Print
efi_lldb.py: - Add lldb EFI commands and pretty Print

efi_debugging.py | 2187 ++++++++++++++++++++++++++++++++++++++++++++++
efi_gdb.py | 918 +++++++++++++++++++
efi_lldb.py | 1044 ++++++++++++++++++++++
3 files changed, 4149 insertions(+)
create mode 100755 efi_debugging.py
create mode 100755 efi_gdb.py
create mode 100755 efi_lldb.py


Re: [PATCH v2 1/2] BaseTools: Define the read-only data section name per toolchain

Andrew Fish
 

On Aug 12, 2021, at 12:26 AM, Marvin Häuser <mhaeuser@posteo.de> wrote:

On 11/08/2021 19:19, Andrew Fish wrote:


On Aug 11, 2021, at 1:11 AM, Marvin Häuser <mhaeuser@posteo.de <mailto:mhaeuser@posteo.de>> wrote:

On 10/08/2021 23:58, Andrew Fish wrote:

On Aug 10, 2021, at 2:30 PM, Marvin Häuser <mhaeuser@posteo.de <mailto:mhaeuser@posteo.de>> wrote:

On 10/08/2021 21:35, Andrew Fish via groups.io <http://groups.io> wrote:

On Aug 10, 2021, at 1:27 AM, Marvin Häuser <mhaeuser@posteo.de <mailto:mhaeuser@posteo.de> <mailto:mhaeuser@posteo.de <mailto:mhaeuser@posteo.de>>> wrote:

On 10/08/2021 06:19, Andrew Fish via groups.io <http://groups.io> <http://groups.io <http://groups.io>> wrote:

On Aug 9, 2021, at 2:51 AM, Marvin Häuser <mhaeuser@posteo.de <mailto:mhaeuser@posteo.de> <mailto:mhaeuser@posteo.de <mailto:mhaeuser@posteo.de>> <mailto:mhaeuser@posteo.de <mailto:mhaeuser@posteo.de> <mailto:mhaeuser@posteo.de <mailto:mhaeuser@posteo.de>>>> wrote:

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3318 <https://bugzilla.tianocore.org/show_bug.cgi?id=3318> <https://bugzilla.tianocore.org/show_bug.cgi?id=3318 <https://bugzilla.tianocore.org/show_bug.cgi?id=3318>> <https://bugzilla.tianocore.org/show_bug.cgi?id=3318 <https://bugzilla.tianocore.org/show_bug.cgi?id=3318> <https://bugzilla.tianocore.org/show_bug.cgi?id=3318 <https://bugzilla.tianocore.org/show_bug.cgi?id=3318>>>

Different toolchains of the EDK II build system may generate ELF or
Mach-O files, which use the ".rodata" naming convention, or PE/COFF
files, which use the ".rdata" naming convention. Section permissions
are chosen based on this name per file format by NASM. To harden
image permission security, and to save space by avoiding both
".rdata" and ".rodata" sections being emitted, expose the appropriate
name as a preprocessor constant.

Cc: Bob Feng <bob.c.feng@intel.com <mailto:bob.c.feng@intel.com> <mailto:bob.c.feng@intel.com <mailto:bob.c.feng@intel.com>> <mailto:bob.c.feng@intel.com <mailto:bob.c.feng@intel.com> <mailto:bob.c.feng@intel.com <mailto:bob.c.feng@intel.com>>>>
Cc: Liming Gao <gaoliming@byosoft.com.cn <mailto:gaoliming@byosoft.com.cn> <mailto:gaoliming@byosoft.com.cn <mailto:gaoliming@byosoft.com.cn>> <mailto:gaoliming@byosoft.com.cn <mailto:gaoliming@byosoft.com.cn> <mailto:gaoliming@byosoft.com.cn <mailto:gaoliming@byosoft.com.cn>>>>
Cc: Yuwei Chen <yuwei.chen@intel.com <mailto:yuwei.chen@intel.com> <mailto:yuwei.chen@intel.com <mailto:yuwei.chen@intel.com>> <mailto:yuwei.chen@intel.com <mailto:yuwei.chen@intel.com> <mailto:yuwei.chen@intel.com <mailto:yuwei.chen@intel.com>>>>
Cc: Vitaly Cheptsov <vit9696@protonmail.com <mailto:vit9696@protonmail.com> <mailto:vit9696@protonmail.com <mailto:vit9696@protonmail.com>> <mailto:vit9696@protonmail.com <mailto:vit9696@protonmail.com> <mailto:vit9696@protonmail.com <mailto:vit9696@protonmail.com>>>>
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de <mailto:mhaeuser@posteo.de> <mailto:mhaeuser@posteo.de <mailto:mhaeuser@posteo.de>> <mailto:mhaeuser@posteo.de <mailto:mhaeuser@posteo.de> <mailto:mhaeuser@posteo.de <mailto:mhaeuser@posteo.de>>>>
---
BaseTools/Conf/tools_def.template | 172 ++++++++++----------
1 file changed, 86 insertions(+), 86 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 2e6b382ab623..84d464916c4d 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -463,9 +463,9 @@ NOOPT_VS2008_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
RELEASE_VS2008_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2008_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2008_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2008_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2008_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2008_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2008_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2008_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2008_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2008_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -495,9 +495,9 @@ NOOPT_VS2008_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /G
RELEASE_VS2008_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2008_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2008_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2008_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2008_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2008_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2008_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2008_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2008_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2008_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -574,9 +574,9 @@ NOOPT_VS2008x86_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
RELEASE_VS2008x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2008x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2008x86_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2008x86_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2008x86_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2008x86_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2008x86_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2008x86_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2008x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2008x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -605,9 +605,9 @@ NOOPT_VS2008x86_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
RELEASE_VS2008x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2008x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2008x86_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2008x86_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2008x86_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2008x86_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2008x86_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2008x86_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2008x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2008x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -688,9 +688,9 @@ NOOPT_VS2010_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
RELEASE_VS2010_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2010_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2010_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2010_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2010_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2010_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2010_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2010_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2010_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2010_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -720,9 +720,9 @@ NOOPT_VS2010_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /G
RELEASE_VS2010_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2010_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2010_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2010_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2010_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2010_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2010_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2010_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2010_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2010_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -799,9 +799,9 @@ NOOPT_VS2010x86_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
RELEASE_VS2010x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2010x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2010x86_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2010x86_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2010x86_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2010x86_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2010x86_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2010x86_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2010x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2010x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -831,9 +831,9 @@ NOOPT_VS2010x86_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
RELEASE_VS2010x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2010x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2010x86_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2010x86_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2010x86_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2010x86_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2010x86_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2010x86_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2010x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2010x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -913,9 +913,9 @@ NOOPT_VS2012_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768
RELEASE_VS2012_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2012_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2012_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2012_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2012_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2012_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2012_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2012_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2012_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2012_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -945,9 +945,9 @@ NOOPT_VS2012_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /G
RELEASE_VS2012_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2012_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2012_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2012_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2012_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2012_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2012_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2012_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2012_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2012_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1024,9 +1024,9 @@ NOOPT_VS2012x86_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768
RELEASE_VS2012x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2012x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2012x86_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2012x86_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2012x86_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2012x86_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2012x86_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2012x86_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2012x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2012x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1056,9 +1056,9 @@ NOOPT_VS2012x86_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
RELEASE_VS2012x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2012x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2012x86_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2012x86_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2012x86_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2012x86_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2012x86_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2012x86_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2012x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2012x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1138,9 +1138,9 @@ NOOPT_VS2013_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768
RELEASE_VS2013_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2013_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2013_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2013_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2013_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2013_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2013_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2013_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2013_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2013_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1170,9 +1170,9 @@ NOOPT_VS2013_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /G
RELEASE_VS2013_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2013_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2013_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2013_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2013_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2013_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2013_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2013_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2013_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2013_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1249,9 +1249,9 @@ NOOPT_VS2013x86_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768
RELEASE_VS2013x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2013x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2013x86_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2013x86_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2013x86_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2013x86_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2013x86_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2013x86_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2013x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2013x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1281,9 +1281,9 @@ NOOPT_VS2013x86_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
RELEASE_VS2013x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2013x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2013x86_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2013x86_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2013x86_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2013x86_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2013x86_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2013x86_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2013x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2013x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1364,9 +1364,9 @@ NOOPT_VS2015_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768
RELEASE_VS2015_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2015_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2015_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2015_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2015_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2015_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2015_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2015_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2015_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2015_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1396,9 +1396,9 @@ NOOPT_VS2015_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /G
RELEASE_VS2015_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2015_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2015_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2015_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2015_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2015_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2015_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2015_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2015_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2015_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1476,9 +1476,9 @@ NOOPT_VS2015x86_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768
RELEASE_VS2015x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2015x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2015x86_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2015x86_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2015x86_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2015x86_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2015x86_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2015x86_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2015x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2015x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1508,9 +1508,9 @@ NOOPT_VS2015x86_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
RELEASE_VS2015x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2015x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2015x86_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2015x86_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2015x86_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2015x86_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2015x86_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2015x86_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2015x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2015x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1586,9 +1586,9 @@ NOOPT_VS2017_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768 /D
RELEASE_VS2017_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2017_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2017_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2017_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2017_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2017_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2017_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2017_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2017_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2017_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1616,9 +1616,9 @@ NOOPT_VS2017_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /G
RELEASE_VS2017_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2017_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2017_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2017_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2017_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2017_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2017_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2017_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1744,9 +1744,9 @@ NOOPT_VS2019_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768 /D
RELEASE_VS2019_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd

NOOPT_VS2019_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi



- DEBUG_VS2019_IA32_NASM_FLAGS = -Ox -f win32 -g

-RELEASE_VS2019_IA32_NASM_FLAGS = -Ox -f win32

-NOOPT_VS2019_IA32_NASM_FLAGS = -O0 -f win32 -g

+ DEBUG_VS2019_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2019_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2019_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2019_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2019_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -1774,9 +1774,9 @@ NOOPT_VS2019_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /G
RELEASE_VS2019_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd

NOOPT_VS2019_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi



- DEBUG_VS2019_X64_NASM_FLAGS = -Ox -f win64 -g

-RELEASE_VS2019_X64_NASM_FLAGS = -Ox -f win64

-NOOPT_VS2019_X64_NASM_FLAGS = -O0 -f win64 -g

+ DEBUG_VS2019_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata

+RELEASE_VS2019_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata

+NOOPT_VS2019_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata



DEBUG_VS2019_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG

RELEASE_VS2019_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data

@@ -2030,7 +2030,7 @@ DEFINE GCC_PP_FLAGS = -E -x assembler-with-cpp -include A
*_GCC48_IA32_DLINK2_FLAGS = DEF(GCC48_IA32_DLINK2_FLAGS)

*_GCC48_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)

*_GCC48_IA32_OBJCOPY_FLAGS =

-*_GCC48_IA32_NASM_FLAGS = -f elf32

+*_GCC48_IA32_NASM_FLAGS = -f elf32 -DRODATA_SECTION_NAME=.rodata



DEBUG_GCC48_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS) -Os

RELEASE_GCC48_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS) -Os -Wno-unused-but-set-variable

@@ -2058,7 +2058,7 @@ RELEASE_GCC48_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS) -Os -Wno-unused-but
*_GCC48_X64_DLINK2_FLAGS = DEF(GCC48_X64_DLINK2_FLAGS)

*_GCC48_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)

*_GCC48_X64_OBJCOPY_FLAGS =

-*_GCC48_X64_NASM_FLAGS = -f elf64

+*_GCC48_X64_NASM_FLAGS = -f elf64 -DRODATA_SECTION_NAME=.rodata



DEBUG_GCC48_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS) -Os

RELEASE_GCC48_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS) -Os -Wno-unused-but-set-variable

@@ -2170,7 +2170,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS = DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
*_GCC49_IA32_DLINK2_FLAGS = DEF(GCC49_IA32_DLINK2_FLAGS)

*_GCC49_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)

*_GCC49_IA32_OBJCOPY_FLAGS =

-*_GCC49_IA32_NASM_FLAGS = -f elf32

+*_GCC49_IA32_NASM_FLAGS = -f elf32 -DRODATA_SECTION_NAME=.rodata



DEBUG_GCC49_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) -Os

RELEASE_GCC49_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) -Os -Wno-unused-but-set-variable -Wno-unused-const-variable

@@ -2198,7 +2198,7 @@ RELEASE_GCC49_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) -Os -Wno-unused-but
*_GCC49_X64_DLINK2_FLAGS = DEF(GCC49_X64_DLINK2_FLAGS)

*_GCC49_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)

*_GCC49_X64_OBJCOPY_FLAGS =

-*_GCC49_X64_NASM_FLAGS = -f elf64

+*_GCC49_X64_NASM_FLAGS = -f elf64 -DRODATA_SECTION_NAME=.rodata



DEBUG_GCC49_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -Os

RELEASE_GCC49_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -Os -Wno-unused-but-set-variable -Wno-unused-const-variable

@@ -2316,7 +2316,7 @@ RELEASE_GCC49_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
*_GCC5_IA32_DLINK2_FLAGS = DEF(GCC5_IA32_DLINK2_FLAGS) -no-pie

*_GCC5_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)

*_GCC5_IA32_OBJCOPY_FLAGS =

-*_GCC5_IA32_NASM_FLAGS = -f elf32

+*_GCC5_IA32_NASM_FLAGS = -f elf32 -DRODATA_SECTION_NAME=.rodata



DEBUG_GCC5_IA32_CC_FLAGS = DEF(GCC5_IA32_CC_FLAGS) -flto -Os

DEBUG_GCC5_IA32_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Os -Wl,-m,elf_i386,--oformat=elf32-i386

@@ -2348,7 +2348,7 @@ RELEASE_GCC5_IA32_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Os -Wl,
*_GCC5_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS)

*_GCC5_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)

*_GCC5_X64_OBJCOPY_FLAGS =

-*_GCC5_X64_NASM_FLAGS = -f elf64

+*_GCC5_X64_NASM_FLAGS = -f elf64 -DRODATA_SECTION_NAME=.rodata



DEBUG_GCC5_X64_CC_FLAGS = DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO -Os

DEBUG_GCC5_X64_DLINK_FLAGS = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os

@@ -2589,7 +2589,7 @@ DEFINE CLANG38_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANG38_WARNIN
*_CLANG38_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386 DEF(CLANG38_IA32_TARGET)

*_CLANG38_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)

*_CLANG38_IA32_OBJCOPY_FLAGS =

-*_CLANG38_IA32_NASM_FLAGS = -f elf32

+*_CLANG38_IA32_NASM_FLAGS = -f elf32 -DRODATA_SECTION_NAME=.rodata

*_CLANG38_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG38_IA32_TARGET)

*_CLANG38_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_IA32_TARGET)

*_CLANG38_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_IA32_TARGET)

@@ -2626,7 +2626,7 @@ NOOPT_CLANG38_IA32_DLINK2_FLAGS = DEF(GCC5_IA32_DLINK2_FLAGS) -O0
*_CLANG38_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64 DEF(CLANG38_X64_TARGET)

*_CLANG38_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)

*_CLANG38_X64_OBJCOPY_FLAGS =

-*_CLANG38_X64_NASM_FLAGS = -f elf64

+*_CLANG38_X64_NASM_FLAGS = -f elf64 -DRODATA_SECTION_NAME=.rodata

*_CLANG38_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG38_X64_TARGET)

*_CLANG38_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_X64_TARGET)

*_CLANG38_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_X64_TARGET)

@@ -2777,7 +2777,7 @@ DEFINE CLANGPDB_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANGPDB_WARN
*_CLANGPDB_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto DEF(CLANGPDB_IA32_TARGET)

*_CLANGPDB_IA32_ASM_FLAGS = DEF(GCC_ASM_FLAGS) -m32 -march=i386 DEF(CLANGPDB_IA32_TARGET)

*_CLANGPDB_IA32_OBJCOPY_FLAGS =

-*_CLANGPDB_IA32_NASM_FLAGS = -f win32

+*_CLANGPDB_IA32_NASM_FLAGS = -f win32 -DRODATA_SECTION_NAME=.rdata

*_CLANGPDB_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGPDB_IA32_TARGET)

*_CLANGPDB_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGPDB_IA32_TARGET)

*_CLANGPDB_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB_IA32_TARGET)

@@ -2811,7 +2811,7 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS =
*_CLANGPDB_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64 -fno-lto DEF(CLANGPDB_X64_TARGET)

*_CLANGPDB_X64_ASM_FLAGS = DEF(GCC_ASM_FLAGS) -m64 DEF(CLANGPDB_X64_TARGET)

*_CLANGPDB_X64_OBJCOPY_FLAGS =

-*_CLANGPDB_X64_NASM_FLAGS = -f win64

+*_CLANGPDB_X64_NASM_FLAGS = -f win64 -DRODATA_SECTION_NAME=.rdata

*_CLANGPDB_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGPDB_X64_TARGET)

*_CLANGPDB_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGPDB_X64_TARGET)

*_CLANGPDB_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB_X64_TARGET)

@@ -2878,7 +2878,7 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x22
*_CLANGDWARF_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386 DEF(CLANG38_IA32_TARGET)

*_CLANGDWARF_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)

*_CLANGDWARF_IA32_OBJCOPY_FLAGS =

-*_CLANGDWARF_IA32_NASM_FLAGS = -f elf32

+*_CLANGDWARF_IA32_NASM_FLAGS = -f elf32 -DRODATA_SECTION_NAME=.rodata

*_CLANGDWARF_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG38_IA32_TARGET)

*_CLANGDWARF_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_IA32_TARGET)

*_CLANGDWARF_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_IA32_TARGET)

@@ -2914,7 +2914,7 @@ NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -
*_CLANGDWARF_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64 DEF(CLANG38_X64_TARGET)

*_CLANGDWARF_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)

*_CLANGDWARF_X64_OBJCOPY_FLAGS =

-*_CLANGDWARF_X64_NASM_FLAGS = -f elf64

+*_CLANGDWARF_X64_NASM_FLAGS = -f elf64 -DRODATA_SECTION_NAME=.rodata

*_CLANGDWARF_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG38_X64_TARGET)

*_CLANGDWARF_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_X64_TARGET)

*_CLANGDWARF_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_X64_TARGET)

@@ -2985,7 +2985,7 @@ RELEASE_XCODE5_IA32_DLINK_FLAGS = -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$
DEBUG_XCODE5_IA32_ASM_FLAGS = -arch i386 -g

NOOPT_XCODE5_IA32_ASM_FLAGS = -arch i386 -g

RELEASE_XCODE5_IA32_ASM_FLAGS = -arch i386

- *_XCODE5_IA32_NASM_FLAGS = -f macho32

+ *_XCODE5_IA32_NASM_FLAGS = -f macho32 -DRODATA_SECTION_NAME=.rodata


An EFI Mach-O file does not contain a .rodata section. A Mach-O contains a __DATA segment that is broken up into sections. For a typical EFI image there are __const, __data, __bss sections in the __DATA segment [1].
Yes, and ".rodata" is almost a synonym for "__DATA,__const", with a small exception [1]. Maybe it'd be clearer if the macro was renamed to "NASM_RODATA_SECTION_NAME", to indicate this is not just a "raw" name, but NASM gives it a semantic meaning?

The mtoc [2] tool used to convert mach-O to PE/COFF converts the entire __DATA segment (__const, __data, and __bss) into the .data section. Thus adding any kind of new data section is a no-op at best.
This is a part I missed, because I do not have an Xcode toolchain at hand, so thanks for investigating. However this, in my opinion, is a flaw with Mach-O/mtoc and not with my patch. It seems like the only difference between __TEXT,__const and __DATA,__const is whether the data is targeted by a relocation or not. Such a concept does not exist for PE/COFF (and I think not even for ELF, but I'm not too familiar with it), thus the logical PE/COFF section __DATA,__const should be merged into is .rdata (and .rdata may or may not be merged into .text in an earlier step, I assume transitivity). I could change the macro definition to explicitly declare __TEXT,__const, but that would still put the compiler-emitted data in the wrong section. Does Xcode provide anything remotely similar to GNU linker scripts which we can use to move the section?

Please also note that .rodata is used for Xcode-based toolchains already (in fact, all toolchains, and this is the issue), I'm not regressing anything. I just expected it to work fine as-is. This patch mainly fixed PE/COFF-based toolchains, which get both .rdata from the compiler and .rodata with RX permissions from NASM, because ".rodata" only has a semantic meaning for ELF and Mach-O outputs, but not for PE/COFF.

If you want something to be read only for Xcode/clang you are better off putting it in the __TEXT section [3]. The __TEXT section is read only and for X64 can not even contain relocations.
Well, this kind of is an issue. We would need to introduce an arbitrary constraint on the relocation part that holds only for Xcode-based toolchains. Does the compiler emit an error when data in __TEXT,__const is targeted by a relocation?
The Xcode linker emits a fatal error on X64 for a relocation in the __TEXT section, everything needs to be RIP relative and the compiler does that for free. We generally only run into this for hand coded assembler and the fix is to use RIP relative addressing in the assembly.
Good, thanks for confirming! Still, this would be a bit of an awkward constraints for Xcode only.
It is a physics problem we can’t fix, so I end up writing some patches to fix other peoples assembler from time to time. The CI building with Xcode helps with this a lot.
(I think all open ends of the other threads are in here too, so let's drop them and go on only here?)

Right, ok, thanks!

Also see above regarding compiler-emitted __DATA,__const.
OK so the current nasm `SECTION .rodata`[1] gets mapped to __TEXT,__const[2] for Xcode clang, and this is done by nasm (I dumped the object file). GenFw and mtoc only run on executables, also they tend to be conservative as they need to keep the layout the same and the relative layout between sections the same, but in this case it is nasm placing the data in the text section.

So what I’d like to see in the patch is to define RODATA_SECTION_NAME to match what is actually happening. So for XCODE that would be `__TEXT,__const` not `.rodata`.
We can do that, but what to do about compiler-emitted __DATA,__const?
Sorry I don’t understand what RODATA_SECTION_NAME has to do with the compiler? I thought it was for nasm?
Yes, it is for NASM. My point is, the actual issue is not that my macro uses __DATA,__const, but that __DATA,__const is not merged into .text, but into .data. Fixing the macro fixes where the NASM definitions go, but what about the C definitions? I cannot test it, as I said, because I don't have an Xcode machine, but let's say we have a stupid example like this:

volatile UINT32 a;
volatile UINT32 *CONST p = &a;
In this case p ends up in a __DATA__,__const section since &a requires a relocation.
OK, good, thanks!



The value of p is constant, so it can be placed in a constant data section. p points to a global variable, so if the compiler does not manage to somehow turn this into relative addressing (let's assume it does not), it needs to generate a relocation. This means the compiler cannot put it in __TEXT,__const, so it has to put it in __DATA,__const (of course it could put it in other __DATA sections, but let's assume the compiler agrees this should be read-only). The very same issue will arise and no matter the choice of the compiler, this will end up in .data. Do you agree? Or do we have some guarantee that Apple Clang cannot emit __DATA,__const?
I don’t see your bigger point. The compiler is free to implement as it sees fit. Which section some code ends up in is more of an implementation detail for the compiler, and we can’t really depend on that?
Your point, rightfully, was that things that we request to be read-only (may) end up being read-write. My issue is that, if the compiler requests this pointer to be read-only (it may not, but also it may), our PE executable does not honour it either. __DATA,__const is a section for constant data, and we put it into a read-write section. The bigger point is, whenever the compile stack wants something read-only (be that NASM or be that Apple Clang, anything really), we should actually ensure it is read-only. I can do that for only NASM by forcing the __TEXT,__const section name (at the cost of prohibiting relocs), but I do not know how to do it for Apple Clang. At worst we could take a hacked-ish solution, where all Mach-O segments are converted to PE/COFF sections - with the exception of the __DATA,__const section, which, if aligned on a segment alignment boundary, can be inserted between the two other parts .data is split into. I read in the XNU source that the ARM protection code does something roughly like this [1], but I'm really far from well-versed in the deep details of macOS.

Sorry for this not being "integrated" in above text, but I found two more things while looking for citation 1.

1) Mach-O sections can be renamed, including the preceding segment name [2]. According to the very next line, the example actually creates a new segment. Does it allow merging into another, existing segment? What if I did something like:

-Wl,-rename_section,__DATA,__const,__TEXT,__const2

or even

-Wl,-rename_section,__DATA,__const,__TEXT,__const

i.e. can it merge two sections together? if __DATA,__const had data with relocs, would the renaming trigger the "no relocs" error of __TEXT, or does that happen before section renaming? Any chance it can be turned off?

1.1) Actually, for the standalone .rodata section, we can just rename it to __DATA_CONST,__const, as I have seen elsewhere in XNU. No hacked-ish solution needed. :)

2) We actually can force the compiler to put data in the constant data segment [3]. This is of course not used in EDK II, and probably neither portable nor necessary, but an interesting detail. I really think we should honour it either way.

I will likely try to get my hands on some sort of Apple development environment soon, but I cannot promise much right now. I think it really is better if I can test through all toolchains myself. If you release Apple Clang for Linux, I also won't complain of course. :)
When I ask compiler questions to my compiler peeps they sometime answer via: https://godbolt.org. You can pas -emit-llvm, -S, or actually run code all from the webpage. It lets you compare the output of lots of versions of clang and compare it with other compilers too. You might find that useful for your research.

For EFI/EDKII clang is mostly just clang (strange triple for x86_64). It is ld64 that is macOS specific, and there is not cross version of ld64 that I know about.

FYI I worked really closely with the owner of ld64, Nick, when we got EFI working. What looks like the strange set of args is what is required to make ld64 “do the right thing”. The biggest portability issue with ld64 is it does not support the GCC ld linker scripts.


I think I’ve forgotten to mention one, relevant, historical point. One of the reasons that sections got collapsed together was to save size. This is the same reason you see the page size/section alignment set to 0x20 (32 bytes). 32 bytes was the smallest alignment the VC++ would support back in the day. In recent times the runtime code got converted to 4K section alignment so the OS could provide better page based protection. That ended up not being too bad as all that code is stored compressed, and it compresses well. Usually the biggest size risk is PEI as it is common for chunks of that code to run directly from ROM, and you would be surprised how much complexity can be involved in turning on DRAM, and that makes for larger PEIMs.

Thanks,

Andrew Fish



We should double check what is happening for ELF on x86, ARM, RiskV, etc. and do the same thing. I assume all the tools that generate PE/COFF directly are good with .rodata?
They are not, that is the whole point of the patch in its current shape. .rodata is valid for ELF and Mach-O, PE/COFF needs .rdata.

I think it is likely as simple as dumping the EFL object file in objdump or gdb for the given toolchain (like my Xcode example).

TL;DR It looks to me like nasm does some SECTION translations under the hood to make code portable, and I’d like to make sure we capture those in the new NASM_RODATA_SECTION_NAME. If some one is doing a security review having NASM_RODATA_SECTION_NAME is going to imply that a .rodata section is being used by that specific toolchain, and I think that is much worse than the current “magic” behavior in nasm. We are much better off explaining what is really happening, since it is not very obvious.
I feel like I'm too tired to get the point. Do you mean you want comments whenever this section name is used? Or comments in tools_def?
I think I’d settle for a more descriptive commit comment that better defines what the define means like I mentioned in the other mail.
Hmm no, we can do that too, but in that case I really want comments in the code. tools_def is not really documented at all, maybe it is time to introduce an example comment so at least new things get commented? Maybe just the start of a macro list. Relying on "git blame" to figure out simple things is rather awful.

One more thing from another thread: Yes, the new macro should refer to object file section naming. I want this patch to get object file sections proper and sound. From there on we can fix the linking stage to emit proper and sound executables in a later patch.
OK then please refactor the commit message to make it clear that this patch is to get the correct section in the object files, and work is still need to get this into executable images.
Sure.


For Xcode you can make it __DATA__,__const since that is the closest thing to read only data and I think that is your intent.
I would like to do that, but only if we can ensure __DATA,__const is merged into .text, or is a separate RNX section.


GenFW is part of EDKII BaseTools and mtoc is part of the open source CCTOOLS project and both those tools would need to be modified to create a .rodata section in PE/COFF.
Yes, that should not be a big problem. Remaining issues for me:
1) How to merge __DATA,__const into .text, or how to emit a standalone .rodata section, for Xcode-based toolchains? (Some ideas above, will ping Vitaly soon as well)
2) How to submit modified mtoc? Any chance it could be maintained in EDK II like GenFw? (Would be nice if you could provide some insight)
3) How to merge .rdata into .text for MSVC? (I will try to research this soon-ish, but no promises)
4) How to design a toggle for the platform maintainer to choose between .text merge and standalone .rodata?

Please note that I'm not asking you to research any of those questions (but 2) would be nice :) ), this is merely a summary of open points till the second stage (correct executables, not just correct object sections) can be properly approached.

Thanks for your time and insight!

Best regards,
Marvin


[1] https://github.com/apple/darwin-xnu/blob/a1babec6b135d1f35b2590a1990af3c5c5393479/osfmk/arm/arm_vm_init.c#L318-L324

[2] https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/makedefs/MakeInc.def#L578

[3] https://github.com/apple/darwin-xnu/blob/8f02f2a044b9bb1ad951987ef5bab20ec9486310/libsa/lastkerneldataconst.c#L48


Thanks,

Andrew Fish

Best regards,
Marvin


Thanks,

Andrew Fish

Best regards,
Marvin

[1] https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm#L14 <https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm#L14> <https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm#L14 <https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm#L14>>

[2] $otool -V -s __TEXT __constBuild/OvmfX64/DEBUG_XCODE5/X64/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib/OUTPUT/X64/InitializeFpu.obj
Build//OvmfX64/DEBUG_XCODE5/X64/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib/OUTPUT/X64/InitializeFpu.obj:
Contents of (__TEXT,__const) section
0000001d 7f 03 80 1f 00 00

$ otool -l Build//OvmfX64/DEBUG_XCODE5/X64/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib/OUTPUT/X64/InitializeFpu.obj
Build/OvmfX64/DEBUG_XCODE5/X64/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib/OUTPUT/X64/InitializeFpu.obj:
Load command 0
cmd LC_SEGMENT_64
cmdsize 232
segname
vmaddr 0x0000000000000000
vmsize 0x0000000000000026
fileoff 288
filesize 38
maxprot 0x00000007
initprot 0x00000007
nsects 2
flags 0x0
Section
sectname __text
segname __TEXT
addr 0x0000000000000000
size 0x000000000000001d
offset 288
align 2^0 (1)
reloff 328
nreloc 2
flags 0x80000500
reserved1 0
reserved2 0
Section
sectname __const
segname __TEXT
addr 0x000000000000001d
size 0x0000000000000006
offset 320
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Load command 1
cmd LC_SYMTAB
cmdsize 24
symoff 344
nsyms 3
stroff 392
strsize 63

Thanks,

Andrew Fish


Thanks for your notes and insight!

Best regards,
Marvin


[1]
"For compatibility with other Unix platforms, the following standard names are also supported:
[...]
.rodata = __DATA,__const data
[...]
If the .rodata section contains no relocations, it is instead put into the __TEXT,__const section unless this section has already been specified explicitly."
https://www.nasm.us/xdoc/2.13.01/html/nasmdoc7.html <https://www.nasm.us/xdoc/2.13.01/html/nasmdoc7.html> <https://www.nasm.us/xdoc/2.13.01/html/nasmdoc7.html <https://www.nasm.us/xdoc/2.13.01/html/nasmdoc7.html>>

[1] otool -lh DxeCore.dll
...
Load command 1
cmd LC_SEGMENT_64
cmdsize 312
segname __DATA
vmaddr 0x000000000002b000
vmsize 0x0000000000147000
fileoff 180224
filesize 8192
maxprot 0x00000003
initprot 0x00000003
nsects 3
flags 0x0
Section
sectname __const
segname __DATA
addr 0x000000000002b000
size 0x0000000000000718
offset 180224
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __data
segname __DATA
addr 0x000000000002b720
size 0x00000000000014f0
offset 182048
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __bss
segname __DATA
addr 0x000000000002cc10
size 0x0000000000144e11
offset 0
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000001
reserved1 0
reserved2 0


[2] https://opensource.apple.com/source/cctools/cctools-698/efitools/mtoc.c.auto.html <https://opensource.apple.com/source/cctools/cctools-698/efitools/mtoc.c.auto.html> <https://opensource.apple.com/source/cctools/cctools-698/efitools/mtoc.c.auto.html <https://opensource.apple.com/source/cctools/cctools-698/efitools/mtoc.c.auto.html>>

[3] otool more output…
Load command 0
cmd LC_SEGMENT_64
cmdsize 392
segname __TEXT
vmaddr 0x0000000000000240
vmsize 0x00000000000296c0
fileoff 1184
filesize 169664
maxprot 0x00000005
initprot 0x00000005
nsects 4
flags 0x0
Section
sectname __text
segname __TEXT
addr 0x0000000000000240
size 0x000000000002489f
offset 1184
align 2^3 (8)
reloff 0
nreloc 0
flags 0x80000400
reserved1 0
reserved2 0
Section
sectname __cstring
segname __TEXT
addr 0x0000000000024ae0
size 0x000000000000496d
offset 150848
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000002
reserved1 0
reserved2 0
Section
sectname __ustring
segname __TEXT
addr 0x000000000002944e
size 0x0000000000000048
offset 169646
align 2^1 (2)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __const
segname __TEXT
addr 0x00000000000294a0
size 0x0000000000000448
offset 169728
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0

Thanks,

Andrew Fish


DEBUG_XCODE5_IA32_CC_FLAGS = -arch i386 -c -g -Os -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang $(PLATFORM_FLAGS)

@@ -3003,7 +3003,7 @@ RELEASE_XCODE5_X64_DLINK_FLAGS = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _
DEBUG_XCODE5_X64_ASM_FLAGS = -arch x86_64 -g

NOOPT_XCODE5_X64_ASM_FLAGS = -arch x86_64 -g

RELEASE_XCODE5_X64_ASM_FLAGS = -arch x86_64

- *_XCODE5_X64_NASM_FLAGS = -f macho64

+ *_XCODE5_X64_NASM_FLAGS = -f macho64 -DRODATA_SECTION_NAME=.rodata

*_XCODE5_*_PP_FLAGS = -E -x assembler-with-cpp -include AutoGen.h

*_XCODE5_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE -include $(MODULE_NAME)StrDefs.h



--
2.31.1











Re: [PATCH v4 1/6] OvmfPkg/TPM: Import PeiDxeTpmPlatformHierarchyLib.c from edk2-platforms

Stefan Berger
 

On 8/12/21 4:59 PM, Sean Brogan wrote:
This seems like a bad place for a general purpose lib that many other platforms may take a dependency on.

In v1 this was SecurityPkg.  OvmfPkg is a platform package and therefore not a good place to define broad interfaces.

What caused this to move here?

Option 2 from this message: https://listman.redhat.com/archives/edk2-devel-archive/2021-August/msg00398.html

  Stefan



Thanks
Sean


Re: [PATCH v4 1/6] OvmfPkg/TPM: Import PeiDxeTpmPlatformHierarchyLib.c from edk2-platforms

Sean
 

This seems like a bad place for a general purpose lib that many other platforms may take a dependency on.

In v1 this was SecurityPkg. OvmfPkg is a platform package and therefore not a good place to define broad interfaces.

What caused this to move here?

Thanks
Sean

On 8/12/2021 9:59 AM, Stefan Berger wrote:
Import PeiDxeTpmPlatformHierarchyLib.c from edk2-platforms. Fix some bugs
from the original code and simplify parts of it.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
.../Include/Library/TpmPlatformHierarchyLib.h | 27 +++
.../PeiDxeTpmPlatformHierarchyLib.c | 200 ++++++++++++++++++
.../PeiDxeTpmPlatformHierarchyLib.inf | 40 ++++
3 files changed, 267 insertions(+)
create mode 100644 OvmfPkg/Include/Library/TpmPlatformHierarchyLib.h
create mode 100644 OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c
create mode 100644 OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
diff --git a/OvmfPkg/Include/Library/TpmPlatformHierarchyLib.h b/OvmfPkg/Include/Library/TpmPlatformHierarchyLib.h
new file mode 100644
index 0000000000..a872fa09dc
--- /dev/null
+++ b/OvmfPkg/Include/Library/TpmPlatformHierarchyLib.h
@@ -0,0 +1,27 @@
+/** @file
+ TPM Platform Hierarchy configuration library.
+
+ This library provides functions for customizing the TPM's Platform Hierarchy
+ Authorization Value (platformAuth) and Platform Hierarchy Authorization
+ Policy (platformPolicy) can be defined through this function.
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _TPM_PLATFORM_HIERARCHY_LIB_H_
+#define _TPM_PLATFORM_HIERARCHY_LIB_H_
+
+/**
+ This service will perform the TPM Platform Hierarchy configuration at the SmmReadyToLock event.
+
+**/
+VOID
+EFIAPI
+ConfigureTpmPlatformHierarchy (
+ VOID
+ );
+
+#endif
diff --git a/OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c b/OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c
new file mode 100644
index 0000000000..a0dc848abd
--- /dev/null
+++ b/OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c
@@ -0,0 +1,200 @@
+/** @file
+ TPM Platform Hierarchy configuration library.
+
+ This library provides functions for customizing the TPM's Platform Hierarchy
+ Authorization Value (platformAuth) and Platform Hierarchy Authorization
+ Policy (platformPolicy) can be defined through this function.
+
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) Microsoft Corporation.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Specification Reference:
+ https://trustedcomputinggroup.org/resource/tcg-tpm-v2-0-provisioning-guidance/
+**/
+
+#include <Uefi.h>
+
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/RngLib.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+
+//
+// The authorization value may be no larger than the digest produced by the hash
+// algorithm used for context integrity.
+//
+
+UINT16 mAuthSize;
+
+/**
+ Generate high-quality entropy source through RDRAND.
+
+ @param[in] Length Size of the buffer, in bytes, to fill with.
+ @param[out] Entropy Pointer to the buffer to store the entropy data.
+
+ @retval EFI_SUCCESS Entropy generation succeeded.
+ @retval EFI_NOT_READY Failed to request random data.
+
+**/
+EFI_STATUS
+EFIAPI
+RdRandGenerateEntropy (
+ IN UINTN Length,
+ OUT UINT8 *Entropy
+ )
+{
+ EFI_STATUS Status;
+ UINTN BlockCount;
+ UINT64 Seed[2];
+ UINT8 *Ptr;
+
+ Status = EFI_NOT_READY;
+ BlockCount = Length / sizeof(Seed);
+ Ptr = (UINT8 *)Entropy;
+
+ //
+ // Generate high-quality seed for DRBG Entropy
+ //
+ while (BlockCount > 0) {
+ Status = GetRandomNumber128 (Seed);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ CopyMem (Ptr, Seed, sizeof(Seed));
+
+ BlockCount--;
+ Ptr = Ptr + sizeof(Seed);
+ }
+
+ //
+ // Populate the remained data as request.
+ //
+ Status = GetRandomNumber128 (Seed);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ CopyMem (Ptr, Seed, (Length % sizeof(Seed)));
+
+ return Status;
+}
+
+/**
+ This function returns the maximum size of TPM2B_AUTH; this structure is used for an authorization value
+ and limits an authValue to being no larger than the largest digest produced by a TPM.
+
+ @param[out] AuthSize Tpm2 Auth size
+
+ @retval EFI_SUCCESS Auth size returned.
+ @retval EFI_DEVICE_ERROR Can not return platform auth due to device error.
+
+**/
+EFI_STATUS
+EFIAPI
+GetAuthSize (
+ OUT UINT16 *AuthSize
+ )
+{
+ EFI_STATUS Status;
+ TPML_PCR_SELECTION Pcrs;
+ UINTN Index;
+ UINT16 DigestSize;
+
+ Status = EFI_SUCCESS;
+
+ while (mAuthSize == 0) {
+
+ mAuthSize = SHA1_DIGEST_SIZE;
+ ZeroMem (&Pcrs, sizeof (TPML_PCR_SELECTION));
+ Status = Tpm2GetCapabilityPcrs (&Pcrs);
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Tpm2GetCapabilityPcrs fail!\n"));
+ break;
+ }
+
+ DEBUG ((DEBUG_ERROR, "Tpm2GetCapabilityPcrs - %08x\n", Pcrs.count));
+
+ for (Index = 0; Index < Pcrs.count; Index++) {
+ DEBUG ((DEBUG_ERROR, "alg - %x\n", Pcrs.pcrSelections[Index].hash));
+
+ switch (Pcrs.pcrSelections[Index].hash) {
+ case TPM_ALG_SHA1:
+ DigestSize = SHA1_DIGEST_SIZE;
+ break;
+ case TPM_ALG_SHA256:
+ DigestSize = SHA256_DIGEST_SIZE;
+ break;
+ case TPM_ALG_SHA384:
+ DigestSize = SHA384_DIGEST_SIZE;
+ break;
+ case TPM_ALG_SHA512:
+ DigestSize = SHA512_DIGEST_SIZE;
+ break;
+ case TPM_ALG_SM3_256:
+ DigestSize = SM3_256_DIGEST_SIZE;
+ break;
+ default:
+ DigestSize = SHA1_DIGEST_SIZE;
+ break;
+ }
+
+ if (DigestSize > mAuthSize) {
+ mAuthSize = DigestSize;
+ }
+ }
+ break;
+ }
+
+ *AuthSize = mAuthSize;
+ return Status;
+}
+
+/**
+ Set PlatformAuth to random value.
+**/
+VOID
+RandomizePlatformAuth (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINT16 AuthSize;
+ TPM2B_AUTH NewPlatformAuth;
+
+ //
+ // Send Tpm2HierarchyChange Auth with random value to avoid PlatformAuth being null
+ //
+
+ GetAuthSize (&AuthSize);
+
+ NewPlatformAuth.size = AuthSize;
+
+ //
+ // Create the random bytes in the destination buffer
+ //
+
+ RdRandGenerateEntropy (NewPlatformAuth.size, NewPlatformAuth.buffer);
+
+ //
+ // Send Tpm2HierarchyChangeAuth command with the new Auth value
+ //
+ Status = Tpm2HierarchyChangeAuth (TPM_RH_PLATFORM, NULL, &NewPlatformAuth);
+ DEBUG ((DEBUG_INFO, "Tpm2HierarchyChangeAuth Result: - %r\n", Status));
+ ZeroMem (NewPlatformAuth.buffer, AuthSize);
+}
+
+/**
+ This service defines the configuration of the Platform Hierarchy Authorization Value (platformAuth)
+ and Platform Hierarchy Authorization Policy (platformPolicy)
+
+**/
+VOID
+EFIAPI
+ConfigureTpmPlatformHierarchy (
+ )
+{
+ RandomizePlatformAuth ();
+}
diff --git a/OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf b/OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
new file mode 100644
index 0000000000..a413e02302
--- /dev/null
+++ b/OvmfPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
@@ -0,0 +1,40 @@
+### @file
+#
+# TPM Platform Hierarchy configuration library.
+#
+# This library provides functions for customizing the TPM's Platform Hierarchy
+# Authorization Value (platformAuth) and Platform Hierarchy Authorization
+# Policy (platformPolicy) can be defined through this function.
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) Microsoft Corporation.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+###
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiDxeTpmPlatformHierarchyLib
+ FILE_GUID = 7794F92C-4E8E-4E57-9E4A-49A0764C7D73
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TpmPlatformHierarchyLib|PEIM DXE_DRIVER
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ MemoryAllocationLib
+ RngLib
+ Tpm2CommandLib
+ Tpm2DeviceLib
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ SecurityPkg/SecurityPkg.dec
+ CryptoPkg/CryptoPkg.dec
+
+[Sources]
+ PeiDxeTpmPlatformHierarchyLib.c

6841 - 6860 of 85992