From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5979881B44 for ; Tue, 10 Jan 2017 00:39:08 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 10 Jan 2017 00:39:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,343,1477983600"; d="scan'208";a="211598989" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga004.fm.intel.com with ESMTP; 10 Jan 2017 00:39:07 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Star Zeng , Feng Tian Date: Tue, 10 Jan 2017 16:38:57 +0800 Message-Id: <20170110083904.34104-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 In-Reply-To: <20170110083904.34104-1-ruiyu.ni@intel.com> References: <20170110083904.34104-1-ruiyu.ni@intel.com> Subject: [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2017 08:39:08 -0000 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Feng Tian --- .../Universal/Console/TerminalDxe/Terminal.c | 50 ++++++------ .../Universal/Console/TerminalDxe/Terminal.h | 14 ++-- .../Universal/Console/TerminalDxe/TerminalConIn.c | 88 +++++++++++----------- .../Universal/Console/TerminalDxe/TerminalConOut.c | 28 +++---- 4 files changed, 91 insertions(+), 89 deletions(-) diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c index a209bf3..1c1f5e1 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c @@ -2,7 +2,7 @@ Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and Simple Text Output Protocol upon Serial IO Protocol. -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -270,23 +270,23 @@ BuildTerminalDevpath ( } else if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) { - TerminalType = PCANSITYPE; + TerminalType = TerminalTypePcAnsi; } else if (CompareGuid (&Node->Guid, &gEfiVT100Guid)) { - TerminalType = VT100TYPE; + TerminalType = TerminalTypeVt100; } else if (CompareGuid (&Node->Guid, &gEfiVT100PlusGuid)) { - TerminalType = VT100PLUSTYPE; + TerminalType = TerminalTypeVt100Plus; } else if (CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) { - TerminalType = VTUTF8TYPE; + TerminalType = TerminalTypeVtUtf8; } else if (CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) { - TerminalType = TTYTERMTYPE; + TerminalType = TerminalTypeTtyTerm; } else { return NULL; @@ -713,9 +713,9 @@ TerminalDriverBindingStart ( if (RemainingDevicePath == NULL) { TerminalType = PcdGet8 (PcdDefaultTerminalType); // - // Must be between PCANSITYPE (0) and TTYTERMTYPE (4) + // Must be between TerminalTypePcAnsi (0) and TerminalTypeTtyTerm (4) // - ASSERT (TerminalType <= TTYTERMTYPE); + ASSERT (TerminalType <= TerminalTypeTtyTerm); } else if (!IsDevicePathEnd (RemainingDevicePath)) { // // If RemainingDevicePath isn't the End of Device Path Node, @@ -723,15 +723,15 @@ TerminalDriverBindingStart ( // Node = (VENDOR_DEVICE_PATH *)RemainingDevicePath; if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) { - TerminalType = PCANSITYPE; + TerminalType = TerminalTypePcAnsi; } else if (CompareGuid (&Node->Guid, &gEfiVT100Guid)) { - TerminalType = VT100TYPE; + TerminalType = TerminalTypeVt100; } else if (CompareGuid (&Node->Guid, &gEfiVT100PlusGuid)) { - TerminalType = VT100PLUSTYPE; + TerminalType = TerminalTypeVt100Plus; } else if (CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) { - TerminalType = VTUTF8TYPE; + TerminalType = TerminalTypeVtUtf8; } else if (CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) { - TerminalType = TTYTERMTYPE; + TerminalType = TerminalTypeTtyTerm; } else { goto Error; } @@ -863,7 +863,7 @@ TerminalDriverBindingStart ( // TerminalDevice->ControllerNameTable = NULL; switch (TerminalDevice->TerminalType) { - case PCANSITYPE: + case TerminalTypePcAnsi: AddUnicodeString2 ( "eng", gTerminalComponentName.SupportedLanguages, @@ -881,7 +881,7 @@ TerminalDriverBindingStart ( break; - case VT100TYPE: + case TerminalTypeVt100: AddUnicodeString2 ( "eng", gTerminalComponentName.SupportedLanguages, @@ -899,7 +899,7 @@ TerminalDriverBindingStart ( break; - case VT100PLUSTYPE: + case TerminalTypeVt100Plus: AddUnicodeString2 ( "eng", gTerminalComponentName.SupportedLanguages, @@ -917,7 +917,7 @@ TerminalDriverBindingStart ( break; - case VTUTF8TYPE: + case TerminalTypeVtUtf8: AddUnicodeString2 ( "eng", gTerminalComponentName.SupportedLanguages, @@ -935,7 +935,7 @@ TerminalDriverBindingStart ( break; - case TTYTERMTYPE: + case TerminalTypeTtyTerm: AddUnicodeString2 ( "eng", gTerminalComponentName.SupportedLanguages, @@ -1473,7 +1473,7 @@ TerminalUpdateConsoleDevVariable ( // // Append terminal device path onto the variable. // - for (TerminalType = PCANSITYPE; TerminalType <= TTYTERMTYPE; TerminalType++) { + for (TerminalType = TerminalTypePcAnsi; TerminalType <= TerminalTypeTtyTerm; TerminalType++) { SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath); NewVariable = AppendDevicePathInstance (Variable, TempDevicePath); ASSERT (NewVariable != NULL); @@ -1586,7 +1586,7 @@ TerminalRemoveConsoleDevVariable ( // Loop through all the terminal types that this driver supports // Match = FALSE; - for (TerminalType = PCANSITYPE; TerminalType <= TTYTERMTYPE; TerminalType++) { + for (TerminalType = TerminalTypePcAnsi; TerminalType <= TerminalTypeTtyTerm; TerminalType++) { SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath); @@ -1674,23 +1674,23 @@ SetTerminalDevicePath ( // switch (TerminalType) { - case PCANSITYPE: + case TerminalTypePcAnsi: CopyGuid (&Node.Guid, &gEfiPcAnsiGuid); break; - case VT100TYPE: + case TerminalTypeVt100: CopyGuid (&Node.Guid, &gEfiVT100Guid); break; - case VT100PLUSTYPE: + case TerminalTypeVt100Plus: CopyGuid (&Node.Guid, &gEfiVT100PlusGuid); break; - case VTUTF8TYPE: + case TerminalTypeVtUtf8: CopyGuid (&Node.Guid, &gEfiVTUTF8Guid); break; - case TTYTERMTYPE: + case TerminalTypeTtyTerm: CopyGuid (&Node.Guid, &gEfiTtyTermGuid); break; diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h index e16b89c..fff3281 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h @@ -1,7 +1,7 @@ /** @file Header file for Terminal driver. -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -139,11 +139,13 @@ typedef union { UINT8 Utf8_3[3]; } UTF8_CHAR; -#define PCANSITYPE 0 -#define VT100TYPE 1 -#define VT100PLUSTYPE 2 -#define VTUTF8TYPE 3 -#define TTYTERMTYPE 4 +typedef enum { + TerminalTypePcAnsi, + TerminalTypeVt100, + TerminalTypeVt100Plus, + TerminalTypeVtUtf8, + TerminalTypeTtyTerm +} TERMINAL_TYPE; #define LEFTOPENBRACKET 0x5b // '[' #define ACAP 0x41 diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c index 0162410..1392f16 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c @@ -2,7 +2,7 @@ Implementation for EFI_SIMPLE_TEXT_INPUT_PROTOCOL protocol. (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -453,15 +453,15 @@ TranslateRawDataToEfiKey ( { switch (TerminalDevice->TerminalType) { - case PCANSITYPE: - case VT100TYPE: - case VT100PLUSTYPE: - case TTYTERMTYPE: + case TerminalTypePcAnsi: + case TerminalTypeVt100: + case TerminalTypeVt100Plus: + case TerminalTypeTtyTerm: AnsiRawDataToUnicode (TerminalDevice); UnicodeToEfiKey (TerminalDevice); break; - case VTUTF8TYPE: + case TerminalTypeVtUtf8: // // Process all the raw data in the RawFIFO, // put the processed key into UnicodeFIFO. @@ -1405,8 +1405,8 @@ UnicodeToEfiKey ( continue; } - if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == VT100TYPE || - TerminalDevice->TerminalType == TTYTERMTYPE)) { + if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == TerminalTypeVt100 || + TerminalDevice->TerminalType == TerminalTypeTtyTerm)) { TerminalDevice->InputState |= INPUT_STATE_O; TerminalDevice->ResetState = RESET_STATE_DEFAULT; continue; @@ -1414,8 +1414,8 @@ UnicodeToEfiKey ( Key.ScanCode = SCAN_NULL; - if (TerminalDevice->TerminalType == VT100PLUSTYPE || - TerminalDevice->TerminalType == VTUTF8TYPE) { + if (TerminalDevice->TerminalType == TerminalTypeVt100Plus || + TerminalDevice->TerminalType == TerminalTypeVtUtf8) { switch (UnicodeChar) { case '1': Key.ScanCode = SCAN_F1; @@ -1519,7 +1519,7 @@ UnicodeToEfiKey ( Key.ScanCode = SCAN_NULL; - if (TerminalDevice->TerminalType == VT100TYPE) { + if (TerminalDevice->TerminalType == TerminalTypeVt100) { switch (UnicodeChar) { case 'P': Key.ScanCode = SCAN_F1; @@ -1554,7 +1554,7 @@ UnicodeToEfiKey ( default : break; } - } else if (TerminalDevice->TerminalType == TTYTERMTYPE) { + } else if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) { /* Also accept VT100 escape codes for F1-F4, HOME and END for TTY term */ switch (UnicodeChar) { case 'P': @@ -1596,11 +1596,11 @@ UnicodeToEfiKey ( Key.ScanCode = SCAN_NULL; - if (TerminalDevice->TerminalType == PCANSITYPE || - TerminalDevice->TerminalType == VT100TYPE || - TerminalDevice->TerminalType == VT100PLUSTYPE || - TerminalDevice->TerminalType == VTUTF8TYPE || - TerminalDevice->TerminalType == TTYTERMTYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi || + TerminalDevice->TerminalType == TerminalTypeVt100 || + TerminalDevice->TerminalType == TerminalTypeVt100Plus || + TerminalDevice->TerminalType == TerminalTypeVtUtf8 || + TerminalDevice->TerminalType == TerminalTypeTtyTerm) { switch (UnicodeChar) { case 'A': Key.ScanCode = SCAN_UP; @@ -1615,104 +1615,104 @@ UnicodeToEfiKey ( Key.ScanCode = SCAN_LEFT; break; case 'H': - if (TerminalDevice->TerminalType == PCANSITYPE || - TerminalDevice->TerminalType == VT100TYPE || - TerminalDevice->TerminalType == TTYTERMTYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi || + TerminalDevice->TerminalType == TerminalTypeVt100 || + TerminalDevice->TerminalType == TerminalTypeTtyTerm) { Key.ScanCode = SCAN_HOME; } break; case 'F': - if (TerminalDevice->TerminalType == PCANSITYPE || - TerminalDevice->TerminalType == TTYTERMTYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi || + TerminalDevice->TerminalType == TerminalTypeTtyTerm) { Key.ScanCode = SCAN_END; } break; case 'K': - if (TerminalDevice->TerminalType == VT100TYPE) { + if (TerminalDevice->TerminalType == TerminalTypeVt100) { Key.ScanCode = SCAN_END; } break; case 'L': case '@': - if (TerminalDevice->TerminalType == PCANSITYPE || - TerminalDevice->TerminalType == VT100TYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi || + TerminalDevice->TerminalType == TerminalTypeVt100) { Key.ScanCode = SCAN_INSERT; } break; case 'X': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_DELETE; } break; case 'P': - if (TerminalDevice->TerminalType == VT100TYPE) { + if (TerminalDevice->TerminalType == TerminalTypeVt100) { Key.ScanCode = SCAN_DELETE; - } else if (TerminalDevice->TerminalType == PCANSITYPE) { + } else if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_F4; } break; case 'I': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_PAGE_UP; } break; case 'V': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_F10; } break; case '?': - if (TerminalDevice->TerminalType == VT100TYPE) { + if (TerminalDevice->TerminalType == TerminalTypeVt100) { Key.ScanCode = SCAN_PAGE_UP; } break; case 'G': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_PAGE_DOWN; } break; case 'U': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_F9; } break; case '/': - if (TerminalDevice->TerminalType == VT100TYPE) { + if (TerminalDevice->TerminalType == TerminalTypeVt100) { Key.ScanCode = SCAN_PAGE_DOWN; } break; case 'M': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_F1; } break; case 'N': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_F2; } break; case 'O': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_F3; } break; case 'Q': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_F5; } break; case 'R': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_F6; } break; case 'S': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_F7; } break; case 'T': - if (TerminalDevice->TerminalType == PCANSITYPE) { + if (TerminalDevice->TerminalType == TerminalTypePcAnsi) { Key.ScanCode = SCAN_F8; } break; @@ -1726,7 +1726,7 @@ UnicodeToEfiKey ( * numeric codes, and there are no ambiguous prefixes shared with * other terminal types. */ - if (TerminalDevice->TerminalType == TTYTERMTYPE && + if (TerminalDevice->TerminalType == TerminalTypeTtyTerm && Key.ScanCode == SCAN_NULL && UnicodeChar >= '0' && UnicodeChar <= '9') { @@ -1755,7 +1755,7 @@ UnicodeToEfiKey ( * state is only used by the TTY terminal type. */ Key.ScanCode = SCAN_NULL; - if (TerminalDevice->TerminalType == TTYTERMTYPE) { + if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) { if (UnicodeChar == '~' && TerminalDevice->TtyEscapeIndex <= 2) { UINT16 EscCode; @@ -1851,7 +1851,7 @@ UnicodeToEfiKey ( } if (UnicodeChar == DEL) { - if (TerminalDevice->TerminalType == TTYTERMTYPE) { + if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) { Key.ScanCode = SCAN_NULL; Key.UnicodeChar = CHAR_BACKSPACE; } diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c index c9b4ffc..e677a76 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c @@ -1,7 +1,7 @@ /** @file Implementation for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL protocol. -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -224,10 +224,10 @@ TerminalConOutOutputString ( switch (TerminalDevice->TerminalType) { - case PCANSITYPE: - case VT100TYPE: - case VT100PLUSTYPE: - case TTYTERMTYPE: + case TerminalTypePcAnsi: + case TerminalTypeVt100: + case TerminalTypeVt100Plus: + case TerminalTypeTtyTerm: if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) { // @@ -253,7 +253,7 @@ TerminalConOutOutputString ( } - if (TerminalDevice->TerminalType != PCANSITYPE) { + if (TerminalDevice->TerminalType != TerminalTypePcAnsi) { GraphicChar = AsciiChar; } @@ -271,7 +271,7 @@ TerminalConOutOutputString ( break; - case VTUTF8TYPE: + case TerminalTypeVtUtf8: UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes); Length = ValidBytes; Status = TerminalDevice->SerialIo->Write ( @@ -317,7 +317,7 @@ TerminalConOutOutputString ( Mode->CursorRow++; } - if (TerminalDevice->TerminalType == TTYTERMTYPE && + if (TerminalDevice->TerminalType == TerminalTypeTtyTerm && !TerminalDevice->OutputEscChar) { // // We've written the last character on the line. The @@ -398,14 +398,14 @@ TerminalConOutTestString ( switch (TerminalDevice->TerminalType) { - case PCANSITYPE: - case VT100TYPE: - case VT100PLUSTYPE: - case TTYTERMTYPE: + case TerminalTypePcAnsi: + case TerminalTypeVt100: + case TerminalTypeVt100Plus: + case TerminalTypeTtyTerm: Status = AnsiTestString (TerminalDevice, WString); break; - case VTUTF8TYPE: + case TerminalTypeVtUtf8: Status = VTUTF8TestString (TerminalDevice, WString); break; @@ -791,7 +791,7 @@ TerminalConOutSetCursorPosition ( // within the current line if possible, and don't output anyting if // it isn't necessary. // - if (TerminalDevice->TerminalType == TTYTERMTYPE && + if (TerminalDevice->TerminalType == TerminalTypeTtyTerm && (UINTN)Mode->CursorRow == Row) { if ((UINTN)Mode->CursorColumn > Column) { mCursorBackwardString[FW_BACK_OFFSET + 0] = (CHAR16) ('0' + ((Mode->CursorColumn - Column) / 10)); -- 2.9.0.windows.1