From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Star Zeng <star.zeng@intel.com>, Feng Tian <feng.tian@intel.com>
Subject: [PATCH 3/8] MdeModulePkg/TerminalDxe: Separate controller name init logic
Date: Tue, 10 Jan 2017 16:38:59 +0800 [thread overview]
Message-ID: <20170110083904.34104-4-ruiyu.ni@intel.com> (raw)
In-Reply-To: <20170110083904.34104-1-ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
---
.../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
next prev parent reply other threads:[~2017-01-10 8:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-10 8:38 [PATCH 0/8] Fix TerminalDxe driver model bug Ruiyu Ni
2017-01-10 8:38 ` [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types Ruiyu Ni
2017-01-11 7:32 ` Tian, Feng
2017-01-10 8:38 ` [PATCH 2/8] MdeModulePkg/TerminalDxe: Add TerminalTypeFromGuid internal function Ruiyu Ni
2017-01-10 8:38 ` Ruiyu Ni [this message]
2017-01-10 8:39 ` [PATCH 4/8] MdeModulePkg/TerminalDxe: Refine InitializeTerminalConsoleTextMode Ruiyu Ni
2017-01-12 10:41 ` Laszlo Ersek
2017-01-12 15:39 ` Ni, Ruiyu
2017-01-10 8:39 ` [PATCH 5/8] MdeModulePkg/TerminalDxe: Refine SetTerminalDevicePath Ruiyu Ni
2017-01-10 8:39 ` [PATCH 6/8] MdeModulePkg/TerminalDxe: Separate state machine start/stop logic Ruiyu Ni
2017-01-10 8:39 ` [PATCH 7/8] MdeModulePkg/TerminalDxe: Remove unnecessary NULL pointer check Ruiyu Ni
2017-01-10 8:39 ` [PATCH 8/8] MdeModulePkg/TerminalDxe: Fix driver model bug Ruiyu Ni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170110083904.34104-4-ruiyu.ni@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox