Discussion:
[edk2] [PATCH V3 1/5] Add "TtyTerm" terminal type to TerminalDxe
Roy Franz
2015-07-08 00:44:14 UTC
Permalink
This patch a adds new terminal type, TtyTerm, to TerminalDxe. This terminal
type provides a place to add support for various *nix terminals that don't
behave like standard VT terminals. The goal is to 'just work' with as many
terminals as possible, rather than properly emulating any one specific
terminal.

Signed-off-by: Roy Franz <***@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Ard Biesheuvel <***@linaro.org>
---
MdeModulePkg/Include/Guid/TtyTerm.h | 25 +++++++++++
MdeModulePkg/MdeModulePkg.dec | 3 ++
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c | 44 ++++++++++++++++----
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h | 2 +
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c | 4 +-
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c | 2 +
MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf | 1 +
7 files changed, 73 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/Include/Guid/TtyTerm.h b/MdeModulePkg/Include/Guid/TtyTerm.h
new file mode 100644
index 0000000..900e5af
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/TtyTerm.h
@@ -0,0 +1,25 @@
+/** @file
+GUID definition for TtyTerm terminal type. The TtyTerm terminal aims to
+provide support for modern *nix terminals.
+
+
+Copyright (c) 2015 Linaro Ltd.
+This program and the accompanying materials are licensed and made
+available under the terms and conditions of the BSD License that
+accompanies this distribution. The full text of the license may be found
+at http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __TTYTERM_H__
+#define __TTYTERM_H__
+
+#define EFI_TTY_TERM_GUID \
+ {0x7d916d80, 0x5bb1, 0x458c, {0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94 } }
+
+extern EFI_GUID gEfiTtyTermGuid;
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 414b13e..9ad106c 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -304,6 +304,9 @@
# Include/Guid/LzmaDecompress.h
gLzmaCustomDecompressGuid = { 0xEE4E5898, 0x3914, 0x4259, { 0x9D, 0x6E, 0xDC, 0x7B, 0xD7, 0x94, 0x03, 0xCF }}
gLzmaF86CustomDecompressGuid = { 0xD42AE6BD, 0x1352, 0x4bfb, { 0x90, 0x9A, 0xCA, 0x72, 0xA6, 0xEA, 0xE8, 0x89 }}
+
+ ## Include/Guid/TtyTerm.h
+ gEfiTtyTermGuid = { 0x7d916d80, 0x5bb1, 0x458c, {0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94 }}

[Ppis]
## Include/Ppi/AtaController.h
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 966fb79..babb097 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -33,7 +33,8 @@ EFI_GUID *gTerminalType[] = {
&gEfiPcAnsiGuid,
&gEfiVT100Guid,
&gEfiVT100PlusGuid,
- &gEfiVTUTF8Guid
+ &gEfiVTUTF8Guid,
+ &gEfiTtyTermGuid
};


@@ -152,12 +153,13 @@ TerminalDriverBindingSupported (

}
//
- // only supports PC ANSI, VT100, VT100+ and VT-UTF8 terminal types
+ // only supports PC ANSI, VT100, VT100+, VT-UTF8, and TtyTerm terminal types
//
if (!CompareGuid (&Node->Guid, &gEfiPcAnsiGuid) &&
!CompareGuid (&Node->Guid, &gEfiVT100Guid) &&
!CompareGuid (&Node->Guid, &gEfiVT100PlusGuid) &&
- !CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {
+ !CompareGuid (&Node->Guid, &gEfiVTUTF8Guid) &&
+ !CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {

return EFI_UNSUPPORTED;
}
@@ -275,6 +277,10 @@ BuildTerminalDevpath (

TerminalType = VTUTF8TYPE;

+ } else if (CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {
+
+ TerminalType = TTYTERMTYPE;
+
} else {
return NULL;
}
@@ -708,9 +714,9 @@ TerminalDriverBindingStart (

TerminalType = PcdGet8 (PcdDefaultTerminalType);
//
- // Must be between PCANSITYPE (0) and VTUTF8TYPE (3)
+ // Must be between PCANSITYPE (0) and TTYTERMTYPE (4)
//
- ASSERT (TerminalType <= VTUTF8TYPE);
+ ASSERT (TerminalType <= TTYTERMTYPE);

CopyMem (&DefaultNode->Guid, gTerminalType[TerminalType], sizeof (EFI_GUID));
RemainingDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DefaultNode;
@@ -728,6 +734,8 @@ TerminalDriverBindingStart (
TerminalType = VT100PLUSTYPE;
} else if (CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {
TerminalType = VTUTF8TYPE;
+ } else if (CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {
+ TerminalType = TTYTERMTYPE;
} else {
goto Error;
}
@@ -926,6 +934,24 @@ TerminalDriverBindingStart (
);

break;
+
+ case TTYTERMTYPE:
+ AddUnicodeString2 (
+ "eng",
+ gTerminalComponentName.SupportedLanguages,
+ &TerminalDevice->ControllerNameTable,
+ (CHAR16 *)L"Tty Terminal Serial Console",
+ TRUE
+ );
+ AddUnicodeString2 (
+ "en",
+ gTerminalComponentName2.SupportedLanguages,
+ &TerminalDevice->ControllerNameTable,
+ (CHAR16 *)L"Tty Terminal Serial Console",
+ FALSE
+ );
+
+ break;
}

//
@@ -1441,7 +1467,7 @@ TerminalUpdateConsoleDevVariable (
//
// Append terminal device path onto the variable.
//
- for (TerminalType = PCANSITYPE; TerminalType <= VTUTF8TYPE; TerminalType++) {
+ for (TerminalType = PCANSITYPE; TerminalType <= TTYTERMTYPE; TerminalType++) {
SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);
NewVariable = AppendDevicePathInstance (Variable, TempDevicePath);
ASSERT (NewVariable != NULL);
@@ -1554,7 +1580,7 @@ TerminalRemoveConsoleDevVariable (
// Loop through all the terminal types that this driver supports
//
Match = FALSE;
- for (TerminalType = PCANSITYPE; TerminalType <= VTUTF8TYPE; TerminalType++) {
+ for (TerminalType = PCANSITYPE; TerminalType <= TTYTERMTYPE; TerminalType++) {

SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);

@@ -1658,6 +1684,10 @@ SetTerminalDevicePath (
CopyGuid (&Node.Guid, &gEfiVTUTF8Guid);
break;

+ case TTYTERMTYPE:
+ CopyGuid (&Node.Guid, &gEfiTtyTermGuid);
+ break;
+
default:
return EFI_UNSUPPORTED;
}
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index d393acb..03542a4 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

#include <Guid/GlobalVariable.h>
#include <Guid/PcAnsi.h>
+#include <Guid/TtyTerm.h>
#include <Guid/StatusCodeDataTypeVariable.h>

#include <Protocol/SimpleTextOut.h>
@@ -136,6 +137,7 @@ typedef union {
#define VT100TYPE 1
#define VT100PLUSTYPE 2
#define VTUTF8TYPE 3
+#define TTYTERMTYPE 4

#define LEFTOPENBRACKET 0x5b // '['
#define ACAP 0x41
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 4a008c9..17a1244 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -454,6 +454,7 @@ TranslateRawDataToEfiKey (
case PCANSITYPE:
case VT100TYPE:
case VT100PLUSTYPE:
+ case TTYTERMTYPE:
AnsiRawDataToUnicode (TerminalDevice);
UnicodeToEfiKey (TerminalDevice);
break;
@@ -1393,7 +1394,8 @@ UnicodeToEfiKey (
if (TerminalDevice->TerminalType == PCANSITYPE ||
TerminalDevice->TerminalType == VT100TYPE ||
TerminalDevice->TerminalType == VT100PLUSTYPE ||
- TerminalDevice->TerminalType == VTUTF8TYPE) {
+ TerminalDevice->TerminalType == VTUTF8TYPE ||
+ TerminalDevice->TerminalType == TTYTERMTYPE) {
switch (UnicodeChar) {
case 'A':
Key.ScanCode = SCAN_UP;
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
index affb3ae..9fa952a 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
@@ -223,6 +223,7 @@ TerminalConOutOutputString (
case PCANSITYPE:
case VT100TYPE:
case VT100PLUSTYPE:
+ case TTYTERMTYPE:

if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) {
//
@@ -371,6 +372,7 @@ TerminalConOutTestString (
case PCANSITYPE:
case VT100TYPE:
case VT100PLUSTYPE:
+ case TTYTERMTYPE:
Status = AnsiTestString (TerminalDevice, WString);
break;

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
index 1d86388..0780296 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
@@ -73,6 +73,7 @@
gEfiVT100Guid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
gEfiVT100PlusGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
gEfiPcAnsiGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
+ gEfiTtyTermGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID

[Protocols]
--
2.1.4
Roy Franz
2015-07-08 00:44:15 UTC
Permalink
Treat ASCII 0x7F as backspace, rather than delete, for TTY terminals. This
better matches the default Linux terminal settings that are used when connecting
to a simulated platform using xterm or a similar terminal program.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Roy Franz <***@linaro.org>
Reviewed-by: Ard Biesheuvel <***@linaro.org>
---
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 17a1244..227df85 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -1561,8 +1561,14 @@ UnicodeToEfiKey (
}

if (UnicodeChar == DEL) {
- Key.ScanCode = SCAN_DELETE;
- Key.UnicodeChar = 0;
+ if (TerminalDevice->TerminalType == TTYTERMTYPE) {
+ Key.ScanCode = SCAN_NULL;
+ Key.UnicodeChar = CHAR_BACKSPACE;
+ }
+ else {
+ Key.ScanCode = SCAN_DELETE;
+ Key.UnicodeChar = 0;
+ }
} else {
Key.ScanCode = SCAN_NULL;
Key.UnicodeChar = UnicodeChar;
--
2.1.4
Roy Franz
2015-07-08 00:44:16 UTC
Permalink
Accept the VT220 escape code [3~ as backspace for TtyTerm terminals. This is
sent by many Linux terminals by default. Also accept VT220 function keys
F1-F12, and VT100 F1-F4 keys as these are commonly sent by Linux terminals.
The VT220 escape codes are longer, and variable length so a new state is added
to the state machine along with a variable to construct the multibyte escape
sequence.
There are currently no ambiguous escape sequence prefixes accepted, so the TTY
terminal accepts escape sequences for a variety of terminals. The goal is to
'just work' with as many terminals as possible, rather than properly emulating
any specific terminal. Backspace, Del, and F10 have been tested on xterm,
rxvt, tmux, and screen.
Note: The existing vt100 function key handling does not match the vt100
documentation that I found, so I added the TTY terminal handling
of VT100 F1-F4 (really PF1-PF4 on vt100) separately. The vt100
has no F5-F10 keys, so I don't know what the current vt100 code
is based on.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Roy Franz <***@linaro.org>
---
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c | 6 ++
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h | 3 +
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c | 93 +++++++++++++++++++-
3 files changed, 101 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index babb097..597b15d 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -81,6 +81,12 @@ TERMINAL_DEV mTerminalDevTemplate = {
NULL, // TwoSecondTimeOut
INPUT_STATE_DEFAULT,
RESET_STATE_DEFAULT,
+ {
+ 0,
+ 0,
+ 0
+ },
+ 0,
FALSE,
{ // SimpleTextInputEx
TerminalConInResetEx,
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index 03542a4..269d2ae 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -99,6 +99,8 @@ typedef struct {
EFI_EVENT TwoSecondTimeOut;
UINT32 InputState;
UINT32 ResetState;
+ UINT16 TtyEscapeStr[3];
+ INTN TtyEscapeIndex;

//
// Esc could not be output to the screen by user,
@@ -118,6 +120,7 @@ typedef struct {
#define INPUT_STATE_LEFTOPENBRACKET 0x04
#define INPUT_STATE_O 0x08
#define INPUT_STATE_2 0x10
+#define INPUT_STATE_LEFTOPENBRACKET_2 0x20

#define RESET_STATE_DEFAULT 0x00
#define RESET_STATE_ESC_R 0x01
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 227df85..fbaf33b 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -1223,7 +1223,8 @@ UnicodeToEfiKey (
continue;
}

- if (UnicodeChar == 'O' && TerminalDevice->TerminalType == VT100TYPE) {
+ if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == VT100TYPE ||
+ TerminalDevice->TerminalType == TTYTERMTYPE)) {
TerminalDevice->InputState |= INPUT_STATE_O;
TerminalDevice->ResetState = RESET_STATE_DEFAULT;
continue;
@@ -1371,6 +1372,22 @@ UnicodeToEfiKey (
default :
break;
}
+ } else if (TerminalDevice->TerminalType == TTYTERMTYPE) {
+ /* Also accept VT100 escape codes for F1-F4 for TTY term */
+ switch (UnicodeChar) {
+ case 'P':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case 'Q':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case 'R':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case 'S':
+ Key.ScanCode = SCAN_F4;
+ break;
+ }
}

if (Key.ScanCode != SCAN_NULL) {
@@ -1514,6 +1531,21 @@ UnicodeToEfiKey (
}
}

+ /*
+ * The VT220 escape codes that the TTY terminal accepts all have
+ * numeric codes, and there are no ambiguous prefixes shared with
+ * other terminal types.
+ */
+ if (TerminalDevice->TerminalType == TTYTERMTYPE &&
+ Key.ScanCode == SCAN_NULL &&
+ UnicodeChar >= '0' &&
+ UnicodeChar <= '9') {
+ TerminalDevice->TtyEscapeStr[0] = UnicodeChar;
+ TerminalDevice->TtyEscapeIndex = 1;
+ TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_2;
+ continue;
+ }
+
if (Key.ScanCode != SCAN_NULL) {
Key.UnicodeChar = 0;
EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
@@ -1527,6 +1559,65 @@ UnicodeToEfiKey (
break;


+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_2:
+ /*
+ * Here we handle the VT220 escape codes that we accept. This
+ * state is only used by the TTY terminal type.
+ */
+ Key.ScanCode = SCAN_NULL;
+ if (TerminalDevice->TerminalType == TTYTERMTYPE) {
+
+ if (UnicodeChar == '~' && TerminalDevice->TtyEscapeIndex <= 2) {
+ UINTN EscCode;
+ TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex] = 0; /* Terminate string */
+ EscCode = StrDecimalToUintn(TerminalDevice->TtyEscapeStr);
+ switch (EscCode) {
+ case 3:
+ Key.ScanCode = SCAN_DELETE;
+ break;
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ Key.ScanCode = SCAN_F1 + EscCode - 11;
+ break;
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ case 21:
+ Key.ScanCode = SCAN_F6 + EscCode - 17;
+ break;
+ case 23:
+ case 24:
+ Key.ScanCode = SCAN_F11 + EscCode - 23;
+ break;
+ default:
+ break;
+ }
+ } else if (TerminalDevice->TtyEscapeIndex == 1){
+ /* 2 character escape code */
+ TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex++] = UnicodeChar;
+ continue;
+ }
+ else {
+ DEBUG ((EFI_D_ERROR, "Unexpected state in escape2\n"));
+ }
+ }
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;
+
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
+ }
+
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ break;
+
default:
//
// Invalid state. This should never happen.
--
2.1.4
Roy Franz
2015-07-08 00:44:17 UTC
Permalink
From: Laszlo Ersek <***@redhat.com>

Add a fixed pointer PCD to allow build-time selection of VT100 or TTY terminal
type. The default remains VT100 emulation.
Add support for building the ARM QEMU platforms with the TTY terminal
with the "-D TTY_TERMINAL" build option.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <***@redhat.com>
[Roy Franz: minor edits: add TtyTerminal GUID, rename LINUX_TERMINAL to TTY_TERMINAL]
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Roy Franz <***@linaro.org>
Reviewed-by: Ard Biesheuvel <***@linaro.org>
---
ArmVirtPkg/ArmVirt.dsc.inc | 6 ++++++
ArmVirtPkg/ArmVirtPkg.dec | 7 +++++++
ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 12 ++++++++----
ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf | 4 ++++
4 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 7ec0de4..2feebd3 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -15,6 +15,7 @@

[Defines]
DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x8000004F
+ DEFINE TTY_TERMINAL = FALSE

[LibraryClasses.common]
!if $(TARGET) == RELEASE
@@ -359,6 +360,11 @@
gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0x04
!endif

+!if $(TTY_TERMINAL) == TRUE
+ # Set terminal type to TtyTerm, the value encoded is EFI_TTY_TERM_GUID
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 0x91, 0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94}
+!endif
+
[Components.common]
#
# Networking stack
diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
index 7bbd9ff..9833c5a 100644
--- a/ArmVirtPkg/ArmVirtPkg.dec
+++ b/ArmVirtPkg/ArmVirtPkg.dec
@@ -49,6 +49,13 @@
#
gArmVirtTokenSpaceGuid.PcdDeviceTreeAllocationPadding|256|UINT32|0x00000002

+ #
+ # Binary representation of the GUID that determines the terminal type. The
+ # size must be exactly 16 bytes. The default value corresponds to
+ # EFI_VT_100_GUID.
+ #
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x65, 0x60, 0xA6, 0xDF, 0x19, 0xB4, 0xD3, 0x11, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D}|VOID*|0x00000007
+
[PcdsDynamic, PcdsFixedAtBuild]
#
# ARM PSCI function invocations can be done either through hypervisor
diff --git a/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c b/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
index 13830cb..b242a29 100644
--- a/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
+++ b/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
@@ -35,7 +35,7 @@
typedef struct {
VENDOR_DEVICE_PATH SerialDxe;
UART_DEVICE_PATH Uart;
- VENDOR_DEFINED_DEVICE_PATH Vt100;
+ VENDOR_DEFINED_DEVICE_PATH TermType;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_SERIAL_CONSOLE;
#pragma pack ()
@@ -67,14 +67,16 @@ STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
},

//
- // VENDOR_DEFINED_DEVICE_PATH Vt100
+ // VENDOR_DEFINED_DEVICE_PATH TermType
//
{
{
MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,
DP_NODE_LEN (VENDOR_DEFINED_DEVICE_PATH)
- },
- EFI_VT_100_GUID
+ }
+ //
+ // Guid to be filled in dynamically
+ //
},

//
@@ -421,6 +423,8 @@ PlatformBdsPolicyBehavior (
//
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
//
+ CopyGuid (&mSerialConsole.TermType.Guid,
+ PcdGetPtr (PcdTerminalTypeGuidBuffer));
BdsLibUpdateConsoleVariable (L"ConIn",
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
BdsLibUpdateConsoleVariable (L"ConOut",
diff --git a/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf b/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
index d998216..9a3cfcd 100644
--- a/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+++ b/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
@@ -39,6 +39,7 @@
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
+ ArmVirtPkg/ArmVirtPkg.dec

[LibraryClasses]
BaseLib
@@ -61,6 +62,9 @@
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits

+[Pcd]
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer
+
[Guids]
gEfiFileInfoGuid
gEfiFileSystemInfoGuid
--
2.1.4
Heyi Guo
2015-07-08 02:46:09 UTC
Permalink
Hi Roy,

I have one question; please see my comments below.
Post by Roy Franz
Add a fixed pointer PCD to allow build-time selection of VT100 or TTY terminal
type. The default remains VT100 emulation.
Add support for building the ARM QEMU platforms with the TTY terminal
with the "-D TTY_TERMINAL" build option.
Contributed-under: TianoCore Contribution Agreement 1.0
[Roy Franz: minor edits: add TtyTerminal GUID, rename LINUX_TERMINAL to TTY_TERMINAL]
Contributed-under: TianoCore Contribution Agreement 1.0
---
ArmVirtPkg/ArmVirt.dsc.inc | 6 ++++++
ArmVirtPkg/ArmVirtPkg.dec | 7 +++++++
ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 12 ++++++++----
ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf | 4 ++++
4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 7ec0de4..2feebd3 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -15,6 +15,7 @@
[Defines]
DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x8000004F
+ DEFINE TTY_TERMINAL = FALSE
I see in ArmVirtQemu.dsc file (patch 5#), we are using #ifdef
TTY_TERMINAL. In my opinion the above statement will cause #ifdef
TTY_TERMINAL to be always true.
Post by Roy Franz
[LibraryClasses.common]
!if $(TARGET) == RELEASE
@@ -359,6 +360,11 @@
gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0x04
!endif
+!if $(TTY_TERMINAL) == TRUE
And I don't understand why we use "!if" here and "!ifdef" in dsc file.

I should have tested the patch directly, but I couldn't apply the mail
patches with "git am" right now (git 2.1.4 on Debian; really appreciate
if someone could tell me the reason :-) ).

Heyi Guo
Post by Roy Franz
+ # Set terminal type to TtyTerm, the value encoded is EFI_TTY_TERM_GUID
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 0x91, 0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94}
+!endif
+
[Components.common]
#
# Networking stack
diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
index 7bbd9ff..9833c5a 100644
--- a/ArmVirtPkg/ArmVirtPkg.dec
+++ b/ArmVirtPkg/ArmVirtPkg.dec
@@ -49,6 +49,13 @@
#
gArmVirtTokenSpaceGuid.PcdDeviceTreeAllocationPadding|256|UINT32|0x00000002
+ #
+ # Binary representation of the GUID that determines the terminal type. The
+ # size must be exactly 16 bytes. The default value corresponds to
+ # EFI_VT_100_GUID.
+ #
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x65, 0x60, 0xA6, 0xDF, 0x19, 0xB4, 0xD3, 0x11, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D}|VOID*|0x00000007
+
[PcdsDynamic, PcdsFixedAtBuild]
#
# ARM PSCI function invocations can be done either through hypervisor
diff --git a/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c b/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
index 13830cb..b242a29 100644
--- a/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
+++ b/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
@@ -35,7 +35,7 @@
typedef struct {
VENDOR_DEVICE_PATH SerialDxe;
UART_DEVICE_PATH Uart;
- VENDOR_DEFINED_DEVICE_PATH Vt100;
+ VENDOR_DEFINED_DEVICE_PATH TermType;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_SERIAL_CONSOLE;
#pragma pack ()
@@ -67,14 +67,16 @@ STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
},
//
- // VENDOR_DEFINED_DEVICE_PATH Vt100
+ // VENDOR_DEFINED_DEVICE_PATH TermType
//
{
{
MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,
DP_NODE_LEN (VENDOR_DEFINED_DEVICE_PATH)
- },
- EFI_VT_100_GUID
+ }
+ //
+ // Guid to be filled in dynamically
+ //
},
//
@@ -421,6 +423,8 @@ PlatformBdsPolicyBehavior (
//
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
//
+ CopyGuid (&mSerialConsole.TermType.Guid,
+ PcdGetPtr (PcdTerminalTypeGuidBuffer));
BdsLibUpdateConsoleVariable (L"ConIn",
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
BdsLibUpdateConsoleVariable (L"ConOut",
diff --git a/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf b/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
index d998216..9a3cfcd 100644
--- a/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+++ b/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
@@ -39,6 +39,7 @@
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
+ ArmVirtPkg/ArmVirtPkg.dec
[LibraryClasses]
BaseLib
@@ -61,6 +62,9 @@
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+[Pcd]
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer
+
[Guids]
gEfiFileInfoGuid
gEfiFileSystemInfoGuid
Laszlo Ersek
2015-07-08 09:46:35 UTC
Permalink
Post by Heyi Guo
Hi Roy,
I have one question; please see my comments below.
Post by Roy Franz
Add a fixed pointer PCD to allow build-time selection of VT100 or TTY terminal
type. The default remains VT100 emulation.
Add support for building the ARM QEMU platforms with the TTY terminal
with the "-D TTY_TERMINAL" build option.
Contributed-under: TianoCore Contribution Agreement 1.0
[Roy Franz: minor edits: add TtyTerminal GUID, rename LINUX_TERMINAL to TTY_TERMINAL]
Contributed-under: TianoCore Contribution Agreement 1.0
---
ArmVirtPkg/ArmVirt.dsc.inc | 6 ++++++
ArmVirtPkg/ArmVirtPkg.dec | 7 +++++++
ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 12 ++++++++----
ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf | 4 ++++
4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 7ec0de4..2feebd3 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -15,6 +15,7 @@
[Defines]
DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x8000004F
+ DEFINE TTY_TERMINAL = FALSE
I see in ArmVirtQemu.dsc file (patch 5#), we are using #ifdef
TTY_TERMINAL. In my opinion the above statement will cause #ifdef
TTY_TERMINAL to be always true.
I agree. That's my only comment for patch #5 too. Patch #5 should be
consistent with this one here, and use

!if $(TTY_TERMINAL) == TRUE
Post by Heyi Guo
Post by Roy Franz
[LibraryClasses.common]
!if $(TARGET) == RELEASE
@@ -359,6 +360,11 @@
gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0x04
!endif
+!if $(TTY_TERMINAL) == TRUE
And I don't understand why we use "!if" here and "!ifdef" in dsc file.
BTW, we have a good reason for this kind of conditional. We use

$(WHATEVER_ENABLE) == TRUE

because that allows

-D WHATEVER_ENABLE=FALSE

on a command line to *override* an earlier

-D WHATEVER_ENABLE[=TRUE]

on the same command line. The "build" utility has no -U option (for
undefining a macro).

Assume you have a build script that hardcodes

-D WHATEVER_ENABLE

because that's how you build the tree most of the time. However,
occasionally you'd like to build without that feature, and you'd like to
override the macro. If the script just appends "$@" to the build command
line, *and* the DSC files use the above kind of conditional, then you
can simply pass -D WHATEVER_ENABLE=FALSE to override the macro (but
still use the rest of your build script).

... Yes, we should have done the same with INTEL_BDS too, and we didn't.

I guess I didn't catch that because I *never* build without INTEL_BDS.

... Well, that, and because the patch that added INTEL_BDS (SVN r16208)
was never reviewed on the list.

Anyway, I digress.
Post by Heyi Guo
I should have tested the patch directly, but I couldn't apply the mail
patches with "git am" right now (git 2.1.4 on Debian; really appreciate
if someone could tell me the reason :-) ).
Sure. The edk2 project uses CRLF line endings. For that to work in the
first place (without git yelling at you all the time), you need to add
the following git config settings:

[core]
whitespace = cr-at-eol

Then, to make git-am "compatible", you further need:

[am]
keepcr = true

This will *almost* make things work, but it will still break down when
you have a patch that adds or removes files *and* has crossed MTA
boundaries. In this case, you'll have

+++ /dev/null\r

or

--- /dev/null\r

hunk headers in the patch. The am.keepcr setting (which is otherwise
necessary for the *source code* CRLFs) will prevent git-am from
stripping the \r even from the /dev/null hunk headers, and that will
trip up git-am. So you need to pre-process the /dev/null hunk headers
manually, stripping *only those* \r characters, *if* you have a patch
that adds or removes files *and* has crossed MTA boundaries. (If the
patch doesn't cross an MTA, ie. it is straight out of git format-patch,
then /dev/null will have no \r.)

Summary (I'm sure you'll appreciate a summary): if you'd like to apply
edk2 patches from the mailing list, with git-am, do the following:
(1) set "core.whitespace" to "cr-at-eol",
(2) set "am.keepcr" to "true",
(3) save the patch emails *intact* into local files (eg. *.eml)
(4) preprocess those local files with:

sed -r -i 's,^((---|\+\+\+) /dev/null)\r$,\1,' *.eml

(5) apply them with git-am.

HTH
Laszlo
Post by Heyi Guo
Heyi Guo
Post by Roy Franz
+ # Set terminal type to TtyTerm, the value encoded is EFI_TTY_TERM_GUID
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 0x91,
0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51,
0xef, 0x94}
+!endif
+
[Components.common]
#
# Networking stack
diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
index 7bbd9ff..9833c5a 100644
--- a/ArmVirtPkg/ArmVirtPkg.dec
+++ b/ArmVirtPkg/ArmVirtPkg.dec
@@ -49,6 +49,13 @@
#
gArmVirtTokenSpaceGuid.PcdDeviceTreeAllocationPadding|256|UINT32|0x00000002
+ #
+ # Binary representation of the GUID that determines the terminal type. The
+ # size must be exactly 16 bytes. The default value corresponds to
+ # EFI_VT_100_GUID.
+ #
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x65, 0x60, 0xA6,
0xDF, 0x19, 0xB4, 0xD3, 0x11, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F,
0xC1, 0x4D}|VOID*|0x00000007
+
[PcdsDynamic, PcdsFixedAtBuild]
#
# ARM PSCI function invocations can be done either through hypervisor
diff --git a/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
b/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
index 13830cb..b242a29 100644
--- a/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
+++ b/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
@@ -35,7 +35,7 @@
typedef struct {
VENDOR_DEVICE_PATH SerialDxe;
UART_DEVICE_PATH Uart;
- VENDOR_DEFINED_DEVICE_PATH Vt100;
+ VENDOR_DEFINED_DEVICE_PATH TermType;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_SERIAL_CONSOLE;
#pragma pack ()
@@ -67,14 +67,16 @@ STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
},
//
- // VENDOR_DEFINED_DEVICE_PATH Vt100
+ // VENDOR_DEFINED_DEVICE_PATH TermType
//
{
{
MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,
DP_NODE_LEN (VENDOR_DEFINED_DEVICE_PATH)
- },
- EFI_VT_100_GUID
+ }
+ //
+ // Guid to be filled in dynamically
+ //
},
//
@@ -421,6 +423,8 @@ PlatformBdsPolicyBehavior (
//
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
//
+ CopyGuid (&mSerialConsole.TermType.Guid,
+ PcdGetPtr (PcdTerminalTypeGuidBuffer));
BdsLibUpdateConsoleVariable (L"ConIn",
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
BdsLibUpdateConsoleVariable (L"ConOut",
diff --git
a/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
b/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
index d998216..9a3cfcd 100644
--- a/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+++ b/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
@@ -39,6 +39,7 @@
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
+ ArmVirtPkg/ArmVirtPkg.dec
[LibraryClasses]
BaseLib
@@ -61,6 +62,9 @@
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+[Pcd]
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer
+
[Guids]
gEfiFileInfoGuid
gEfiFileSystemInfoGuid
Roy Franz
2015-07-08 18:49:12 UTC
Permalink
Post by Laszlo Ersek
Post by Heyi Guo
Hi Roy,
I have one question; please see my comments below.
Post by Roy Franz
Add a fixed pointer PCD to allow build-time selection of VT100 or TTY terminal
type. The default remains VT100 emulation.
Add support for building the ARM QEMU platforms with the TTY terminal
with the "-D TTY_TERMINAL" build option.
Contributed-under: TianoCore Contribution Agreement 1.0
[Roy Franz: minor edits: add TtyTerminal GUID, rename LINUX_TERMINAL to TTY_TERMINAL]
Contributed-under: TianoCore Contribution Agreement 1.0
---
ArmVirtPkg/ArmVirt.dsc.inc | 6 ++++++
ArmVirtPkg/ArmVirtPkg.dec | 7 +++++++
ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 12 ++++++++----
ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf | 4 ++++
4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 7ec0de4..2feebd3 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -15,6 +15,7 @@
[Defines]
DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x8000004F
+ DEFINE TTY_TERMINAL = FALSE
I see in ArmVirtQemu.dsc file (patch 5#), we are using #ifdef
TTY_TERMINAL. In my opinion the above statement will cause #ifdef
TTY_TERMINAL to be always true.
I agree. That's my only comment for patch #5 too. Patch #5 should be
consistent with this one here, and use
!if $(TTY_TERMINAL) == TRUE
Post by Heyi Guo
Post by Roy Franz
[LibraryClasses.common]
!if $(TARGET) == RELEASE
@@ -359,6 +360,11 @@
gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0x04
!endif
+!if $(TTY_TERMINAL) == TRUE
And I don't understand why we use "!if" here and "!ifdef" in dsc file.
BTW, we have a good reason for this kind of conditional. We use
$(WHATEVER_ENABLE) == TRUE
because that allows
-D WHATEVER_ENABLE=FALSE
on a command line to *override* an earlier
-D WHATEVER_ENABLE[=TRUE]
on the same command line. The "build" utility has no -U option (for
undefining a macro).
Assume you have a build script that hardcodes
-D WHATEVER_ENABLE
because that's how you build the tree most of the time. However,
occasionally you'd like to build without that feature, and you'd like to
line, *and* the DSC files use the above kind of conditional, then you
can simply pass -D WHATEVER_ENABLE=FALSE to override the macro (but
still use the rest of your build script).
... Yes, we should have done the same with INTEL_BDS too, and we didn't.
I guess I didn't catch that because I *never* build without INTEL_BDS.
And I followed the INTEL_BDS pattern in that file :)

I have fixed this (and the INTEL_BDS define as well), and I'll send
this off shortly.

I think I have addressed all comments on the other patches.

Thanks,
Roy
Post by Laszlo Ersek
... Well, that, and because the patch that added INTEL_BDS (SVN r16208)
was never reviewed on the list.
Anyway, I digress.
Post by Heyi Guo
I should have tested the patch directly, but I couldn't apply the mail
patches with "git am" right now (git 2.1.4 on Debian; really appreciate
if someone could tell me the reason :-) ).
Sure. The edk2 project uses CRLF line endings. For that to work in the
first place (without git yelling at you all the time), you need to add
[core]
whitespace = cr-at-eol
[am]
keepcr = true
This will *almost* make things work, but it will still break down when
you have a patch that adds or removes files *and* has crossed MTA
boundaries. In this case, you'll have
+++ /dev/null\r
or
--- /dev/null\r
hunk headers in the patch. The am.keepcr setting (which is otherwise
necessary for the *source code* CRLFs) will prevent git-am from
stripping the \r even from the /dev/null hunk headers, and that will
trip up git-am. So you need to pre-process the /dev/null hunk headers
manually, stripping *only those* \r characters, *if* you have a patch
that adds or removes files *and* has crossed MTA boundaries. (If the
patch doesn't cross an MTA, ie. it is straight out of git format-patch,
then /dev/null will have no \r.)
Summary (I'm sure you'll appreciate a summary): if you'd like to apply
(1) set "core.whitespace" to "cr-at-eol",
(2) set "am.keepcr" to "true",
(3) save the patch emails *intact* into local files (eg. *.eml)
sed -r -i 's,^((---|\+\+\+) /dev/null)\r$,\1,' *.eml
(5) apply them with git-am.
HTH
Laszlo
Post by Heyi Guo
Heyi Guo
Post by Roy Franz
+ # Set terminal type to TtyTerm, the value encoded is EFI_TTY_TERM_GUID
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 0x91,
0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51,
0xef, 0x94}
+!endif
+
[Components.common]
#
# Networking stack
diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
index 7bbd9ff..9833c5a 100644
--- a/ArmVirtPkg/ArmVirtPkg.dec
+++ b/ArmVirtPkg/ArmVirtPkg.dec
@@ -49,6 +49,13 @@
#
gArmVirtTokenSpaceGuid.PcdDeviceTreeAllocationPadding|256|UINT32|0x00000002
+ #
+ # Binary representation of the GUID that determines the terminal type. The
+ # size must be exactly 16 bytes. The default value corresponds to
+ # EFI_VT_100_GUID.
+ #
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x65, 0x60, 0xA6,
0xDF, 0x19, 0xB4, 0xD3, 0x11, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F,
0xC1, 0x4D}|VOID*|0x00000007
+
[PcdsDynamic, PcdsFixedAtBuild]
#
# ARM PSCI function invocations can be done either through hypervisor
diff --git a/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
b/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
index 13830cb..b242a29 100644
--- a/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
+++ b/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
@@ -35,7 +35,7 @@
typedef struct {
VENDOR_DEVICE_PATH SerialDxe;
UART_DEVICE_PATH Uart;
- VENDOR_DEFINED_DEVICE_PATH Vt100;
+ VENDOR_DEFINED_DEVICE_PATH TermType;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_SERIAL_CONSOLE;
#pragma pack ()
@@ -67,14 +67,16 @@ STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
},
//
- // VENDOR_DEFINED_DEVICE_PATH Vt100
+ // VENDOR_DEFINED_DEVICE_PATH TermType
//
{
{
MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,
DP_NODE_LEN (VENDOR_DEFINED_DEVICE_PATH)
- },
- EFI_VT_100_GUID
+ }
+ //
+ // Guid to be filled in dynamically
+ //
},
//
@@ -421,6 +423,8 @@ PlatformBdsPolicyBehavior (
//
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
//
+ CopyGuid (&mSerialConsole.TermType.Guid,
+ PcdGetPtr (PcdTerminalTypeGuidBuffer));
BdsLibUpdateConsoleVariable (L"ConIn",
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
BdsLibUpdateConsoleVariable (L"ConOut",
diff --git
a/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
b/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
index d998216..9a3cfcd 100644
--- a/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+++ b/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
@@ -39,6 +39,7 @@
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
+ ArmVirtPkg/ArmVirtPkg.dec
[LibraryClasses]
BaseLib
@@ -61,6 +62,9 @@
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+[Pcd]
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer
+
[Guids]
gEfiFileInfoGuid
gEfiFileSystemInfoGuid
Ryan Harkin
2015-07-08 20:36:59 UTC
Permalink
Hi Laszlo,
Post by Laszlo Ersek
Post by Heyi Guo
Hi Roy,
I have one question; please see my comments below.
Post by Roy Franz
Add a fixed pointer PCD to allow build-time selection of VT100 or TTY terminal
type. The default remains VT100 emulation.
Add support for building the ARM QEMU platforms with the TTY terminal
with the "-D TTY_TERMINAL" build option.
Contributed-under: TianoCore Contribution Agreement 1.0
[Roy Franz: minor edits: add TtyTerminal GUID, rename LINUX_TERMINAL to TTY_TERMINAL]
Contributed-under: TianoCore Contribution Agreement 1.0
---
ArmVirtPkg/ArmVirt.dsc.inc | 6 ++++++
ArmVirtPkg/ArmVirtPkg.dec | 7 +++++++
ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 12 ++++++++----
ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf | 4 ++++
4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 7ec0de4..2feebd3 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -15,6 +15,7 @@
[Defines]
DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x8000004F
+ DEFINE TTY_TERMINAL = FALSE
I see in ArmVirtQemu.dsc file (patch 5#), we are using #ifdef
TTY_TERMINAL. In my opinion the above statement will cause #ifdef
TTY_TERMINAL to be always true.
I agree. That's my only comment for patch #5 too. Patch #5 should be
consistent with this one here, and use
!if $(TTY_TERMINAL) == TRUE
Post by Heyi Guo
Post by Roy Franz
[LibraryClasses.common]
!if $(TARGET) == RELEASE
@@ -359,6 +360,11 @@
gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0x04
Post by Heyi Guo
Post by Roy Franz
!endif
+!if $(TTY_TERMINAL) == TRUE
And I don't understand why we use "!if" here and "!ifdef" in dsc file.
BTW, we have a good reason for this kind of conditional. We use
$(WHATEVER_ENABLE) == TRUE
because that allows
-D WHATEVER_ENABLE=FALSE
on a command line to *override* an earlier
-D WHATEVER_ENABLE[=TRUE]
on the same command line. The "build" utility has no -U option (for
undefining a macro).
Assume you have a build script that hardcodes
-D WHATEVER_ENABLE
because that's how you build the tree most of the time. However,
occasionally you'd like to build without that feature, and you'd like to
line, *and* the DSC files use the above kind of conditional, then you
can simply pass -D WHATEVER_ENABLE=FALSE to override the macro (but
still use the rest of your build script).
... Yes, we should have done the same with INTEL_BDS too, and we didn't.
I guess I didn't catch that because I *never* build without INTEL_BDS.
... Well, that, and because the patch that added INTEL_BDS (SVN r16208)
was never reviewed on the list.
Anyway, I digress.
Post by Heyi Guo
I should have tested the patch directly, but I couldn't apply the mail
patches with "git am" right now (git 2.1.4 on Debian; really appreciate
if someone could tell me the reason :-) ).
Sure. The edk2 project uses CRLF line endings. For that to work in the
first place (without git yelling at you all the time), you need to add
[core]
whitespace = cr-at-eol
[am]
keepcr = true
This will *almost* make things work, but it will still break down when
you have a patch that adds or removes files *and* has crossed MTA
boundaries. In this case, you'll have
+++ /dev/null\r
or
--- /dev/null\r
hunk headers in the patch. The am.keepcr setting (which is otherwise
necessary for the *source code* CRLFs) will prevent git-am from
stripping the \r even from the /dev/null hunk headers, and that will
trip up git-am. So you need to pre-process the /dev/null hunk headers
manually, stripping *only those* \r characters, *if* you have a patch
that adds or removes files *and* has crossed MTA boundaries. (If the
patch doesn't cross an MTA, ie. it is straight out of git format-patch,
then /dev/null will have no \r.)
Summary (I'm sure you'll appreciate a summary): if you'd like to apply
(1) set "core.whitespace" to "cr-at-eol",
(2) set "am.keepcr" to "true",
(3) save the patch emails *intact* into local files (eg. *.eml)
sed -r -i 's,^((---|\+\+\+) /dev/null)\r$,\1,' *.eml
(5) apply them with git-am.
I have an alias in my ~/.gitconfig file:

[alias]
amm=am --ignore-whitespace --ignore-space-change


Then I use "git amm" to apply patches and that seems to work most of the
time.

But I suspect your method is doing something smarter and more complex
whereas mine is more brute force.
Post by Laszlo Ersek
HTH
Laszlo
Post by Heyi Guo
Heyi Guo
Post by Roy Franz
+ # Set terminal type to TtyTerm, the value encoded is
EFI_TTY_TERM_GUID
Post by Heyi Guo
Post by Roy Franz
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 0x91,
0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51,
0xef, 0x94}
+!endif
+
[Components.common]
#
# Networking stack
diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
index 7bbd9ff..9833c5a 100644
--- a/ArmVirtPkg/ArmVirtPkg.dec
+++ b/ArmVirtPkg/ArmVirtPkg.dec
@@ -49,6 +49,13 @@
#
gArmVirtTokenSpaceGuid.PcdDeviceTreeAllocationPadding|256|UINT32|0x00000002
Post by Heyi Guo
Post by Roy Franz
+ #
+ # Binary representation of the GUID that determines the terminal type. The
+ # size must be exactly 16 bytes. The default value corresponds to
+ # EFI_VT_100_GUID.
+ #
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x65, 0x60, 0xA6,
0xDF, 0x19, 0xB4, 0xD3, 0x11, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F,
0xC1, 0x4D}|VOID*|0x00000007
+
[PcdsDynamic, PcdsFixedAtBuild]
#
# ARM PSCI function invocations can be done either through
hypervisor
Post by Heyi Guo
Post by Roy Franz
diff --git a/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
b/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
index 13830cb..b242a29 100644
--- a/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
+++ b/ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
@@ -35,7 +35,7 @@
typedef struct {
VENDOR_DEVICE_PATH SerialDxe;
UART_DEVICE_PATH Uart;
- VENDOR_DEFINED_DEVICE_PATH Vt100;
+ VENDOR_DEFINED_DEVICE_PATH TermType;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_SERIAL_CONSOLE;
#pragma pack ()
@@ -67,14 +67,16 @@ STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
},
//
- // VENDOR_DEFINED_DEVICE_PATH Vt100
+ // VENDOR_DEFINED_DEVICE_PATH TermType
//
{
{
MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,
DP_NODE_LEN (VENDOR_DEFINED_DEVICE_PATH)
- },
- EFI_VT_100_GUID
+ }
+ //
+ // Guid to be filled in dynamically
+ //
},
//
@@ -421,6 +423,8 @@ PlatformBdsPolicyBehavior (
//
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
//
+ CopyGuid (&mSerialConsole.TermType.Guid,
+ PcdGetPtr (PcdTerminalTypeGuidBuffer));
BdsLibUpdateConsoleVariable (L"ConIn",
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
BdsLibUpdateConsoleVariable (L"ConOut",
diff --git
a/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
b/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
index d998216..9a3cfcd 100644
--- a/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+++ b/ArmVirtPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
@@ -39,6 +39,7 @@
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
+ ArmVirtPkg/ArmVirtPkg.dec
[LibraryClasses]
BaseLib
@@ -61,6 +62,9 @@
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+[Pcd]
+ gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer
+
[Guids]
gEfiFileInfoGuid
gEfiFileSystemInfoGuid
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Laszlo Ersek
2015-07-08 21:03:15 UTC
Permalink
Post by Ryan Harkin
[alias]
amm=am --ignore-whitespace --ignore-space-change
Then I use "git amm" to apply patches and that seems to work most of the
time.
But I suspect your method is doing something smarter and more complex
whereas mine is more brute force.
Right. Your command is perfect for ad-hoc testing, but it ignores more
whitespace than what would be acceptable for actually committing a patch
to SVN. For example, it would enable source files to become mixed LF and
CRLF, I think. (Because:
- git-am would strip all \r characters from the patch email,
- ignore the resultant LF <-> CRLF mismatch in the hunks' contexts,
- and add the new lines with LF only.)

BTW, Paolo had written code for git at some point that fixed this issue
within git:

http://thread.gmane.org/gmane.comp.version-control.git/260215

His idea was to armor patch emails against line terminator changes
incurred by MTAs. (Which is what makes the "sed" command necessary in my
method, for the /dev/null hunk headers.)

Although the quoted-printable and base64 transfer encodings, used for
such protection, would have resulted in human-*un*readable raw email
files, Paolo suggested a one liner back-converter for those who like to
save patch emails to regular files, for comparing them between each
other. The results would have been very useful: "git-am" would just
work, and people comparing raw patches could rely on a one-liner in
their workflow.

Alas, I'm unsure about the fate of Paolo's work. I think he didn't have
time to work on further versions of the patch set, and I had neither the
time nor the expertise.

Thanks!
Laszlo
Paolo Bonzini
2015-07-09 06:45:36 UTC
Permalink
Post by Laszlo Ersek
Post by Ryan Harkin
[alias]
amm=am --ignore-whitespace --ignore-space-change
Then I use "git amm" to apply patches and that seems to work most of the
time.
But I suspect your method is doing something smarter and more complex
whereas mine is more brute force.
Right. Your command is perfect for ad-hoc testing, but it ignores more
whitespace than what would be acceptable for actually committing a patch
to SVN. For example, it would enable source files to become mixed LF and
- git-am would strip all \r characters from the patch email,
- ignore the resultant LF <-> CRLF mismatch in the hunks' contexts,
- and add the new lines with LF only.)
BTW, Paolo had written code for git at some point that fixed this issue
http://thread.gmane.org/gmane.comp.version-control.git/260215
This was included in git 2.3.0. :)

Paolo
Post by Laszlo Ersek
His idea was to armor patch emails against line terminator changes
incurred by MTAs. (Which is what makes the "sed" command necessary in my
method, for the /dev/null hunk headers.)
Although the quoted-printable and base64 transfer encodings, used for
such protection, would have resulted in human-*un*readable raw email
files, Paolo suggested a one liner back-converter for those who like to
save patch emails to regular files, for comparing them between each
other. The results would have been very useful: "git-am" would just
work, and people comparing raw patches could rely on a one-liner in
their workflow.
Alas, I'm unsure about the fate of Paolo's work. I think he didn't have
time to work on further versions of the patch set, and I had neither the
time nor the expertise.
Thanks!
Laszlo
Laszlo Ersek
2015-07-09 06:50:55 UTC
Permalink
Post by Paolo Bonzini
Post by Laszlo Ersek
Post by Ryan Harkin
[alias]
amm=am --ignore-whitespace --ignore-space-change
Then I use "git amm" to apply patches and that seems to work most of the
time.
But I suspect your method is doing something smarter and more complex
whereas mine is more brute force.
Right. Your command is perfect for ad-hoc testing, but it ignores more
whitespace than what would be acceptable for actually committing a patch
to SVN. For example, it would enable source files to become mixed LF and
- git-am would strip all \r characters from the patch email,
- ignore the resultant LF <-> CRLF mismatch in the hunks' contexts,
- and add the new lines with LF only.)
BTW, Paolo had written code for git at some point that fixed this issue
http://thread.gmane.org/gmane.comp.version-control.git/260215
This was included in git 2.3.0. :)
Yay! \o/

Thank you! :)
Laszlo
Post by Paolo Bonzini
Paolo
Post by Laszlo Ersek
His idea was to armor patch emails against line terminator changes
incurred by MTAs. (Which is what makes the "sed" command necessary in my
method, for the /dev/null hunk headers.)
Although the quoted-printable and base64 transfer encodings, used for
such protection, would have resulted in human-*un*readable raw email
files, Paolo suggested a one liner back-converter for those who like to
save patch emails to regular files, for comparing them between each
other. The results would have been very useful: "git-am" would just
work, and people comparing raw patches could rely on a one-liner in
their workflow.
Alas, I'm unsure about the fate of Paolo's work. I think he didn't have
time to work on further versions of the patch set, and I had neither the
time nor the expertise.
Thanks!
Laszlo
Roy Franz
2015-07-08 00:44:18 UTC
Permalink
Enable selecting the TtyTerminal type for the ARM BDS build of QEMU using
the TTY_TERMINAL define.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Roy Franz <***@linaro.org>
---
ArmVirtPkg/ArmVirtQemu.dsc | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 0671469..1acd2e6 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -138,8 +138,13 @@
#
# Settings for ARM BDS -- use the serial console (ConIn & ConOut).
#
+!ifdef TTY_TERMINAL
+ gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenMsg(7D916D80-5BB1-458C-A48F-E25FDD51EF94)"
+ gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenMsg(7D916D80-5BB1-458C-A48F-E25FDD51EF94)"
+!else
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenVt100()"
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenVt100()"
+!endif
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3

#
--
2.1.4
Loading...