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 4D50881B4C for ; Tue, 10 Jan 2017 00:39:10 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 10 Jan 2017 00:39:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,343,1477983600"; d="scan'208";a="211599003" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga004.fm.intel.com with ESMTP; 10 Jan 2017 00:39:09 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Star Zeng , Feng Tian Date: Tue, 10 Jan 2017 16:38:59 +0800 Message-Id: <20170110083904.34104-4-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 3/8] MdeModulePkg/TerminalDxe: Separate controller name init logic 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:10 -0000 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Feng Tian --- .../Universal/Console/TerminalDxe/Terminal.c | 147 ++++++++------------- 1 file changed, 56 insertions(+), 91 deletions(-) diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c index 992d58e..f1ce12d 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c @@ -38,6 +38,14 @@ EFI_GUID *mTerminalType[] = { }; +CHAR16 *mSerialConsoleNames[] = { + L"PC-ANSI Serial Console", + L"VT-100 Serial Console", + L"VT-100+ Serial Console", + L"VT-UTF8 Serial Console", + L"Tty Terminal Serial Console" +}; + TERMINAL_DEV mTerminalDevTemplate = { TERMINAL_DEV_SIGNATURE, NULL, @@ -536,6 +544,51 @@ InitializeTerminalConsoleTextMode ( } /** + Initialize the controller name table. + + @param TerminalType The terminal type. + @param ControllerNameTable The controller name table. + + @retval EFI_SUCCESS The controller name table is initialized successfully. + @retval others Return status of AddUnicodeString2 (). +**/ +EFI_STATUS +InitializeControllerNameTable ( + TERMINAL_TYPE TerminalType, + EFI_UNICODE_STRING_TABLE **ControllerNameTable +) +{ + EFI_STATUS Status; + EFI_UNICODE_STRING_TABLE *Table; + + ASSERT (TerminalType < ARRAY_SIZE (mTerminalType)); + Table = NULL; + Status = AddUnicodeString2 ( + "eng", + gTerminalComponentName.SupportedLanguages, + &Table, + mSerialConsoleNames[TerminalType], + TRUE + ); + if (!EFI_ERROR (Status)) { + Status = AddUnicodeString2 ( + "en", + gTerminalComponentName2.SupportedLanguages, + &Table, + mSerialConsoleNames[TerminalType], + FALSE + ); + if (EFI_ERROR (Status)) { + FreeUnicodeStringTable (Table); + } + } + if (!EFI_ERROR (Status)) { + *ControllerNameTable = Table; + } + return Status; +} + +/** Start this driver on Controller by opening a Serial IO protocol, reading Device Path, and creating a child handle with a Simple Text In, Simple Text In Ex and Simple Text Out protocol, and device path protocol. @@ -864,97 +917,9 @@ TerminalDriverBindingStart ( // // Build the component name for the child device // - TerminalDevice->ControllerNameTable = NULL; - switch (TerminalDevice->TerminalType) { - case TerminalTypePcAnsi: - AddUnicodeString2 ( - "eng", - gTerminalComponentName.SupportedLanguages, - &TerminalDevice->ControllerNameTable, - (CHAR16 *)L"PC-ANSI Serial Console", - TRUE - ); - AddUnicodeString2 ( - "en", - gTerminalComponentName2.SupportedLanguages, - &TerminalDevice->ControllerNameTable, - (CHAR16 *)L"PC-ANSI Serial Console", - FALSE - ); - - break; - - case TerminalTypeVt100: - AddUnicodeString2 ( - "eng", - gTerminalComponentName.SupportedLanguages, - &TerminalDevice->ControllerNameTable, - (CHAR16 *)L"VT-100 Serial Console", - TRUE - ); - AddUnicodeString2 ( - "en", - gTerminalComponentName2.SupportedLanguages, - &TerminalDevice->ControllerNameTable, - (CHAR16 *)L"VT-100 Serial Console", - FALSE - ); - - break; - - case TerminalTypeVt100Plus: - AddUnicodeString2 ( - "eng", - gTerminalComponentName.SupportedLanguages, - &TerminalDevice->ControllerNameTable, - (CHAR16 *)L"VT-100+ Serial Console", - TRUE - ); - AddUnicodeString2 ( - "en", - gTerminalComponentName2.SupportedLanguages, - &TerminalDevice->ControllerNameTable, - (CHAR16 *)L"VT-100+ Serial Console", - FALSE - ); - - break; - - case TerminalTypeVtUtf8: - AddUnicodeString2 ( - "eng", - gTerminalComponentName.SupportedLanguages, - &TerminalDevice->ControllerNameTable, - (CHAR16 *)L"VT-UTF8 Serial Console", - TRUE - ); - AddUnicodeString2 ( - "en", - gTerminalComponentName2.SupportedLanguages, - &TerminalDevice->ControllerNameTable, - (CHAR16 *)L"VT-UTF8 Serial Console", - FALSE - ); - - break; - - case TerminalTypeTtyTerm: - 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; + Status = InitializeControllerNameTable (TerminalDevice->TerminalType, &TerminalDevice->ControllerNameTable); + if (EFI_ERROR (Status)) { + goto Error; } // -- 2.9.0.windows.1