* [PATCH 1/2] MdePkg: UiLib library. Add UiLib. Update UefiLib.
@ 2016-11-09 15:44 Felix Poludov
0 siblings, 0 replies; only message in thread
From: Felix Poludov @ 2016-11-09 15:44 UTC (permalink / raw)
To: edk2-devel@lists.01.org
1. New UiLib library class is added to MdePkg.
The library is intended for functions that produce UI elements.
The patch introduces two functions that produce a popup window:
UiCreatePopUp and UiCreatePopUpVaList.
2. An instance of UiLib library class is added to MdePkg.
Popup implementation is copied from UefiLib
(CreatePopUp function in UefiLib/Console.c).
3. MdePkg/UefiLib library is updated to implement CreatePopUp
by calling UiCreatePopUpVaList.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Felix Polyudov <felixp@ami.com>
---
MdePkg/Include/Library/UiLib.h | 71 +++++++
MdePkg/Library/UefiLib/Console.c | 252 +----------------------
MdePkg/Library/UefiLib/UefiLib.inf | 1 +
MdePkg/Library/UefiLib/UefiLibInternal.h | 1 +
MdePkg/Library/UiLib/UiLib.c | 334 +++++++++++++++++++++++++++++++
MdePkg/Library/UiLib/UiLib.inf | 38 ++++
MdePkg/Library/UiLib/UiLib.uni | 21 ++
MdePkg/MdePkg.dec | 3 +
8 files changed, 470 insertions(+), 251 deletions(-)
create mode 100644 MdePkg/Include/Library/UiLib.h
create mode 100644 MdePkg/Library/UiLib/UiLib.c
create mode 100644 MdePkg/Library/UiLib/UiLib.inf
create mode 100644 MdePkg/Library/UiLib/UiLib.uni
diff --git a/MdePkg/Include/Library/UiLib.h b/MdePkg/Include/Library/UiLib.h
new file mode 100644
index 0000000..0f6b687
--- /dev/null
+++ b/MdePkg/Include/Library/UiLib.h
@@ -0,0 +1,71 @@
+/** @file
+ Provides library functions to construct UI elements.
+
+Copyright (c) 2016, American Megatrends, Inc. All rights reserved.<BR>
+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 __UI_LIB_H__
+#define __UI_LIB_H__
+
+/**
+ Draws a dialog box to the console output device specified by
+ ConOut defined in the EFI_SYSTEM_TABLE and waits for a keystroke
+ from the console input device specified by ConIn defined in the
+ EFI_SYSTEM_TABLE.
+
+ If there are no strings in the variable argument list, then ASSERT().
+ If all the strings in the variable argument list are empty, then ASSERT().
+
+ @param[in] Attribute Specifies the foreground and background color of the popup.
+ @param[out] Key A pointer to the EFI_KEY value of the key that was
+ pressed. This is an optional parameter that may be NULL.
+ If it is NULL then no wait for a keypress will be performed.
+ @param[in] ... The variable argument list that contains pointers to Null-
+ terminated Unicode strings to display in the dialog box.
+ The variable argument list is terminated by a NULL.
+
+**/
+VOID
+EFIAPI
+UiCreatePopUp (
+ IN UINTN Attribute,
+ OUT EFI_INPUT_KEY *Key, OPTIONAL
+ ...
+ );
+
+/**
+ Draws a dialog box to the console output device specified by
+ ConOut defined in the EFI_SYSTEM_TABLE and waits for a keystroke
+ from the console input device specified by ConIn defined in the
+ EFI_SYSTEM_TABLE.
+
+ If there are no strings in the variable argument list, then ASSERT().
+ If all the strings in the variable argument list are empty, then ASSERT().
+
+ @param[in] Attribute Specifies the foreground and background color of the popup.
+ @param[out] Key A pointer to the EFI_KEY value of the key that was
+ pressed. This is an optional parameter that may be NULL.
+ If it is NULL then no wait for a keypress will be performed.
+ @param[in] Args VA_LIST marker for the variable argument list that contains
+ pointers to Null-terminated Unicode strings to display
+ in the dialog box.
+ The variable argument list is terminated by a NULL.
+
+**/
+VOID
+EFIAPI
+UiCreatePopUpVaList (
+ IN UINTN Attribute,
+ OUT EFI_INPUT_KEY *Key, OPTIONAL
+ IN VA_LIST Args
+ );
+
+#endif
diff --git a/MdePkg/Library/UefiLib/Console.c b/MdePkg/Library/UefiLib/Console.c
index ecaf425..8e7e986 100644
--- a/MdePkg/Library/UefiLib/Console.c
+++ b/MdePkg/Library/UefiLib/Console.c
@@ -22,9 +22,6 @@ typedef struct {
UINT32 Width;
} UNICODE_WIDTH_ENTRY;
-#define NARROW_CHAR 0xFFF0
-#define WIDE_CHAR 0xFFF1
-
GLOBAL_REMOVE_IF_UNREFERENCED CONST UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {
//
// General script area
@@ -292,89 +289,6 @@ UnicodeStringDisplayLength (
}
/**
- Count the storage space of a Unicode string.
-
- This function handles the Unicode string with NARROW_CHAR
- and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
- does not count in the resultant output. If a WIDE_CHAR is
- hit, then 2 Unicode character will consume an output storage
- space with size of CHAR16 till a NARROW_CHAR is hit.
-
- @param String The input string to be counted.
- @param LimitLen Whether need to limit the string length.
- @param MaxWidth The max length this function supported.
- @param Offset The max index of the string can be show out.
-
- @return Storage space for the input string.
-
-**/
-UINTN
-UefiLibGetStringWidth (
- IN CHAR16 *String,
- IN BOOLEAN LimitLen,
- IN UINTN MaxWidth,
- OUT UINTN *Offset
- )
-{
- UINTN Index;
- UINTN Count;
- UINTN IncrementValue;
-
- if (String == NULL) {
- return 0;
- }
-
- Index = 0;
- Count = 0;
- IncrementValue = 1;
-
- do {
- //
- // Advance to the null-terminator or to the first width directive
- //
- for (;(String[Index] != NARROW_CHAR) && (String[Index] != WIDE_CHAR) && (String[Index] != 0); Index++) {
- Count = Count + IncrementValue;
-
- if (LimitLen && Count > MaxWidth) {
- break;
- }
- }
-
- //
- // We hit the null-terminator, we now have a count
- //
- if (String[Index] == 0) {
- break;
- }
-
- if (LimitLen && Count > MaxWidth) {
- *Offset = Index;
- break;
- }
-
- //
- // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
- // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
- //
- if (String[Index] == NARROW_CHAR) {
- //
- // Skip to the next character
- //
- Index++;
- IncrementValue = 1;
- } else {
- //
- // Skip to the next character
- //
- Index++;
- IncrementValue = 2;
- }
- } while (String[Index] != 0);
-
- return Count * sizeof (CHAR16);
-}
-
-/**
Draws a dialog box to the console output device specified by
ConOut defined in the EFI_SYSTEM_TABLE and waits for a keystroke
from the console input device specified by ConIn defined in the
@@ -400,173 +314,9 @@ CreatePopUp (
...
)
{
- EFI_STATUS Status;
VA_LIST Args;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
- EFI_SIMPLE_TEXT_OUTPUT_MODE SavedConsoleMode;
- UINTN Columns;
- UINTN Rows;
- UINTN Column;
- UINTN Row;
- UINTN NumberOfLines;
- UINTN MaxLength;
- CHAR16 *String;
- UINTN Length;
- CHAR16 *Line;
- UINTN EventIndex;
- CHAR16 *TmpString;
-
- //
- // Determine the length of the longest line in the popup and the the total
- // number of lines in the popup
- //
- VA_START (Args, Key);
- MaxLength = 0;
- NumberOfLines = 0;
- while ((String = VA_ARG (Args, CHAR16 *)) != NULL) {
- MaxLength = MAX (MaxLength, UefiLibGetStringWidth (String, FALSE, 0, NULL) / 2);
- NumberOfLines++;
- }
- VA_END (Args);
-
- //
- // If the total number of lines in the popup is zero, then ASSERT()
- //
- ASSERT (NumberOfLines != 0);
-
- //
- // If the maximum length of all the strings is zero, then ASSERT()
- //
- ASSERT (MaxLength != 0);
-
- //
- // Cache a pointer to the Simple Text Output Protocol in the EFI System Table
- //
- ConOut = gST->ConOut;
-
- //
- // Save the current console cursor position and attributes
- //
- CopyMem (&SavedConsoleMode, ConOut->Mode, sizeof (SavedConsoleMode));
-
- //
- // Retrieve the number of columns and rows in the current console mode
- //
- ConOut->QueryMode (ConOut, SavedConsoleMode.Mode, &Columns, &Rows);
-
- //
- // Disable cursor and set the foreground and background colors specified by Attribute
- //
- ConOut->EnableCursor (ConOut, FALSE);
- ConOut->SetAttribute (ConOut, Attribute);
-
- //
- // Limit NumberOfLines to height of the screen minus 3 rows for the box itself
- //
- NumberOfLines = MIN (NumberOfLines, Rows - 3);
-
- //
- // Limit MaxLength to width of the screen minus 2 columns for the box itself
- //
- MaxLength = MIN (MaxLength, Columns - 2);
-
- //
- // Compute the starting row and starting column for the popup
- //
- Row = (Rows - (NumberOfLines + 3)) / 2;
- Column = (Columns - (MaxLength + 2)) / 2;
-
- //
- // Allocate a buffer for a single line of the popup with borders and a Null-terminator
- //
- Line = AllocateZeroPool ((MaxLength + 3) * sizeof (CHAR16));
- ASSERT (Line != NULL);
- //
- // Draw top of popup box
- //
- SetMem16 (Line, (MaxLength + 2) * 2, BOXDRAW_HORIZONTAL);
- Line[0] = BOXDRAW_DOWN_RIGHT;
- Line[MaxLength + 1] = BOXDRAW_DOWN_LEFT;
- Line[MaxLength + 2] = L'\0';
- ConOut->SetCursorPosition (ConOut, Column, Row++);
- ConOut->OutputString (ConOut, Line);
-
- //
- // Draw middle of the popup with strings
- //
VA_START (Args, Key);
- while ((String = VA_ARG (Args, CHAR16 *)) != NULL && NumberOfLines > 0) {
- SetMem16 (Line, (MaxLength + 2) * 2, L' ');
- Line[0] = BOXDRAW_VERTICAL;
- Line[MaxLength + 1] = BOXDRAW_VERTICAL;
- Line[MaxLength + 2] = L'\0';
- ConOut->SetCursorPosition (ConOut, Column, Row);
- ConOut->OutputString (ConOut, Line);
- Length = UefiLibGetStringWidth (String, FALSE, 0, NULL) / 2;
- if (Length <= MaxLength) {
- //
- // Length <= MaxLength
- //
- ConOut->SetCursorPosition (ConOut, Column + 1 + (MaxLength - Length) / 2, Row++);
- ConOut->OutputString (ConOut, String);
- } else {
- //
- // Length > MaxLength
- //
- UefiLibGetStringWidth (String, TRUE, MaxLength, &Length);
- TmpString = AllocateZeroPool ((Length + 1) * sizeof (CHAR16));
- ASSERT (TmpString != NULL);
- StrnCpyS (TmpString, Length + 1, String, Length - 3);
- StrCatS (TmpString, Length + 1, L"...");
-
- ConOut->SetCursorPosition (ConOut, Column + 1, Row++);
- ConOut->OutputString (ConOut, TmpString);
- FreePool (TmpString);
- }
- NumberOfLines--;
- }
+ UiCreatePopUpVaList(Attribute, Key, Args);
VA_END (Args);
-
- //
- // Draw bottom of popup box
- //
- SetMem16 (Line, (MaxLength + 2) * 2, BOXDRAW_HORIZONTAL);
- Line[0] = BOXDRAW_UP_RIGHT;
- Line[MaxLength + 1] = BOXDRAW_UP_LEFT;
- Line[MaxLength + 2] = L'\0';
- ConOut->SetCursorPosition (ConOut, Column, Row++);
- ConOut->OutputString (ConOut, Line);
-
- //
- // Free the allocated line buffer
- //
- FreePool (Line);
-
- //
- // Restore the cursor visibility, position, and attributes
- //
- ConOut->EnableCursor (ConOut, SavedConsoleMode.CursorVisible);
- ConOut->SetCursorPosition (ConOut, SavedConsoleMode.CursorColumn, SavedConsoleMode.CursorRow);
- ConOut->SetAttribute (ConOut, SavedConsoleMode.Attribute);
-
- //
- // Wait for a keystroke
- //
- if (Key != NULL) {
- while (TRUE) {
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, Key);
- if (!EFI_ERROR (Status)) {
- break;
- }
-
- //
- // If we encounter error, continue to read another key in.
- //
- if (Status != EFI_NOT_READY) {
- continue;
- }
- gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
- }
- }
}
diff --git a/MdePkg/Library/UefiLib/UefiLib.inf b/MdePkg/Library/UefiLib/UefiLib.inf
index 8284dc5..0767aff 100644
--- a/MdePkg/Library/UefiLib/UefiLib.inf
+++ b/MdePkg/Library/UefiLib/UefiLib.inf
@@ -57,6 +57,7 @@
UefiBootServicesTableLib
DevicePathLib
UefiRuntimeServicesTableLib
+ UiLib
[Guids]
gEfiEventReadyToBootGuid ## SOMETIMES_CONSUMES ## Event
diff --git a/MdePkg/Library/UefiLib/UefiLibInternal.h b/MdePkg/Library/UefiLib/UefiLibInternal.h
index 2311f27..96c6e88 100644
--- a/MdePkg/Library/UefiLib/UefiLibInternal.h
+++ b/MdePkg/Library/UefiLib/UefiLibInternal.h
@@ -40,6 +40,7 @@
#include <Library/PcdLib.h>
#include <Library/PrintLib.h>
#include <Library/DevicePathLib.h>
+#include <Library/UiLib.h>
/**
An empty function to pass error checking of CreateEventEx ().
diff --git a/MdePkg/Library/UiLib/UiLib.c b/MdePkg/Library/UiLib/UiLib.c
new file mode 100644
index 0000000..823dd0a
--- /dev/null
+++ b/MdePkg/Library/UiLib/UiLib.c
@@ -0,0 +1,334 @@
+/** @file
+ The UI Library provides functions that are used to construct UI elements.
+
+ Copyright (c) 2016, American Megatrends, Inc. All rights reserved.<BR>
+ Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
+ 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
+ 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.
+
+**/
+
+#include <Protocol/SimpleTextIn.h>
+#include <Protocol/SimpleTextOut.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#define NARROW_CHAR 0xFFF0
+#define WIDE_CHAR 0xFFF1
+
+/**
+ Count the storage space of a Unicode string.
+
+ This function handles the Unicode string with NARROW_CHAR
+ and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
+ does not count in the resultant output. If a WIDE_CHAR is
+ hit, then 2 Unicode character will consume an output storage
+ space with size of CHAR16 till a NARROW_CHAR is hit.
+
+ @param String The input string to be counted.
+ @param LimitLen Whether need to limit the string length.
+ @param MaxWidth The max length this function supported.
+ @param Offset The max index of the string can be show out.
+
+ @return Storage space for the input string.
+
+**/
+UINTN
+UefiLibGetStringWidth (
+ IN CHAR16 *String,
+ IN BOOLEAN LimitLen,
+ IN UINTN MaxWidth,
+ OUT UINTN *Offset
+ )
+{
+ UINTN Index;
+ UINTN Count;
+ UINTN IncrementValue;
+
+ if (String == NULL) {
+ return 0;
+ }
+
+ Index = 0;
+ Count = 0;
+ IncrementValue = 1;
+
+ do {
+ //
+ // Advance to the null-terminator or to the first width directive
+ //
+ for (;(String[Index] != NARROW_CHAR) && (String[Index] != WIDE_CHAR) && (String[Index] != 0); Index++) {
+ Count = Count + IncrementValue;
+
+ if (LimitLen && Count > MaxWidth) {
+ break;
+ }
+ }
+
+ //
+ // We hit the null-terminator, we now have a count
+ //
+ if (String[Index] == 0) {
+ break;
+ }
+
+ if (LimitLen && Count > MaxWidth) {
+ *Offset = Index;
+ break;
+ }
+
+ //
+ // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
+ // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
+ //
+ if (String[Index] == NARROW_CHAR) {
+ //
+ // Skip to the next character
+ //
+ Index++;
+ IncrementValue = 1;
+ } else {
+ //
+ // Skip to the next character
+ //
+ Index++;
+ IncrementValue = 2;
+ }
+ } while (String[Index] != 0);
+
+ return Count * sizeof (CHAR16);
+}
+
+/**
+ Draws a dialog box to the console output device specified by
+ ConOut defined in the EFI_SYSTEM_TABLE and waits for a keystroke
+ from the console input device specified by ConIn defined in the
+ EFI_SYSTEM_TABLE.
+
+ If there are no strings in the variable argument list, then ASSERT().
+ If all the strings in the variable argument list are empty, then ASSERT().
+
+ @param[in] Attribute Specifies the foreground and background color of the popup.
+ @param[out] Key A pointer to the EFI_KEY value of the key that was
+ pressed. This is an optional parameter that may be NULL.
+ If it is NULL then no wait for a keypress will be performed.
+ @param[in] Args VA_LIST marker for the variable argument list that contains
+ pointers to Null-terminated Unicode strings to display
+ in the dialog box.
+ The variable argument list is terminated by a NULL.
+
+**/
+VOID
+EFIAPI
+UiCreatePopUpVaList (
+ IN UINTN Attribute,
+ OUT EFI_INPUT_KEY *Key, OPTIONAL
+ IN VA_LIST Args
+ )
+{
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
+ EFI_SIMPLE_TEXT_OUTPUT_MODE SavedConsoleMode;
+ UINTN Columns;
+ UINTN Rows;
+ UINTN Column;
+ UINTN Row;
+ UINTN NumberOfLines;
+ UINTN MaxLength;
+ CHAR16 *String;
+ UINTN Length;
+ CHAR16 *Line;
+ UINTN EventIndex;
+ CHAR16 *TmpString;
+
+ //
+ // Determine the length of the longest line in the popup and the the total
+ // number of lines in the popup
+ //
+ MaxLength = 0;
+ NumberOfLines = 0;
+ while ((String = VA_ARG (Args, CHAR16 *)) != NULL) {
+ MaxLength = MAX (MaxLength, UefiLibGetStringWidth (String, FALSE, 0, NULL) / 2);
+ NumberOfLines++;
+ }
+
+ //
+ // If the total number of lines in the popup is zero, then ASSERT()
+ //
+ ASSERT (NumberOfLines != 0);
+
+ //
+ // If the maximum length of all the strings is zero, then ASSERT()
+ //
+ ASSERT (MaxLength != 0);
+
+ //
+ // Cache a pointer to the Simple Text Output Protocol in the EFI System Table
+ //
+ ConOut = gST->ConOut;
+
+ //
+ // Save the current console cursor position and attributes
+ //
+ CopyMem (&SavedConsoleMode, ConOut->Mode, sizeof (SavedConsoleMode));
+
+ //
+ // Retrieve the number of columns and rows in the current console mode
+ //
+ ConOut->QueryMode (ConOut, SavedConsoleMode.Mode, &Columns, &Rows);
+
+ //
+ // Disable cursor and set the foreground and background colors specified by Attribute
+ //
+ ConOut->EnableCursor (ConOut, FALSE);
+ ConOut->SetAttribute (ConOut, Attribute);
+
+ //
+ // Limit NumberOfLines to height of the screen minus 3 rows for the box itself
+ //
+ NumberOfLines = MIN (NumberOfLines, Rows - 3);
+
+ //
+ // Limit MaxLength to width of the screen minus 2 columns for the box itself
+ //
+ MaxLength = MIN (MaxLength, Columns - 2);
+
+ //
+ // Compute the starting row and starting column for the popup
+ //
+ Row = (Rows - (NumberOfLines + 3)) / 2;
+ Column = (Columns - (MaxLength + 2)) / 2;
+
+ //
+ // Allocate a buffer for a single line of the popup with borders and a Null-terminator
+ //
+ Line = AllocateZeroPool ((MaxLength + 3) * sizeof (CHAR16));
+ ASSERT (Line != NULL);
+
+ //
+ // Draw top of popup box
+ //
+ SetMem16 (Line, (MaxLength + 2) * 2, BOXDRAW_HORIZONTAL);
+ Line[0] = BOXDRAW_DOWN_RIGHT;
+ Line[MaxLength + 1] = BOXDRAW_DOWN_LEFT;
+ Line[MaxLength + 2] = L'\0';
+ ConOut->SetCursorPosition (ConOut, Column, Row++);
+ ConOut->OutputString (ConOut, Line);
+
+ //
+ // Draw middle of the popup with strings
+ //
+ while ((String = VA_ARG (Args, CHAR16 *)) != NULL && NumberOfLines > 0) {
+ SetMem16 (Line, (MaxLength + 2) * 2, L' ');
+ Line[0] = BOXDRAW_VERTICAL;
+ Line[MaxLength + 1] = BOXDRAW_VERTICAL;
+ Line[MaxLength + 2] = L'\0';
+ ConOut->SetCursorPosition (ConOut, Column, Row);
+ ConOut->OutputString (ConOut, Line);
+ Length = UefiLibGetStringWidth (String, FALSE, 0, NULL) / 2;
+ if (Length <= MaxLength) {
+ //
+ // Length <= MaxLength
+ //
+ ConOut->SetCursorPosition (ConOut, Column + 1 + (MaxLength - Length) / 2, Row++);
+ ConOut->OutputString (ConOut, String);
+ } else {
+ //
+ // Length > MaxLength
+ //
+ UefiLibGetStringWidth (String, TRUE, MaxLength, &Length);
+ TmpString = AllocateZeroPool ((Length + 1) * sizeof (CHAR16));
+ ASSERT (TmpString != NULL);
+ StrnCpyS (TmpString, Length + 1, String, Length - 3);
+ StrCatS (TmpString, Length + 1, L"...");
+
+ ConOut->SetCursorPosition (ConOut, Column + 1, Row++);
+ ConOut->OutputString (ConOut, TmpString);
+ FreePool (TmpString);
+ }
+ NumberOfLines--;
+ }
+
+ //
+ // Draw bottom of popup box
+ //
+ SetMem16 (Line, (MaxLength + 2) * 2, BOXDRAW_HORIZONTAL);
+ Line[0] = BOXDRAW_UP_RIGHT;
+ Line[MaxLength + 1] = BOXDRAW_UP_LEFT;
+ Line[MaxLength + 2] = L'\0';
+ ConOut->SetCursorPosition (ConOut, Column, Row++);
+ ConOut->OutputString (ConOut, Line);
+
+ //
+ // Free the allocated line buffer
+ //
+ FreePool (Line);
+
+ //
+ // Restore the cursor visibility, position, and attributes
+ //
+ ConOut->EnableCursor (ConOut, SavedConsoleMode.CursorVisible);
+ ConOut->SetCursorPosition (ConOut, SavedConsoleMode.CursorColumn, SavedConsoleMode.CursorRow);
+ ConOut->SetAttribute (ConOut, SavedConsoleMode.Attribute);
+
+ //
+ // Wait for a keystroke
+ //
+ if (Key != NULL) {
+ while (TRUE) {
+ Status = gST->ConIn->ReadKeyStroke (gST->ConIn, Key);
+ if (!EFI_ERROR (Status)) {
+ break;
+ }
+
+ //
+ // If we encounter error, continue to read another key in.
+ //
+ if (Status != EFI_NOT_READY) {
+ continue;
+ }
+ gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
+ }
+ }
+}
+
+/**
+ Draws a dialog box to the console output device specified by
+ ConOut defined in the EFI_SYSTEM_TABLE and waits for a keystroke
+ from the console input device specified by ConIn defined in the
+ EFI_SYSTEM_TABLE.
+
+ If there are no strings in the variable argument list, then ASSERT().
+ If all the strings in the variable argument list are empty, then ASSERT().
+
+ @param[in] Attribute Specifies the foreground and background color of the popup.
+ @param[out] Key A pointer to the EFI_KEY value of the key that was
+ pressed. This is an optional parameter that may be NULL.
+ If it is NULL then no wait for a keypress will be performed.
+ @param[in] ... The variable argument list that contains pointers to Null-
+ terminated Unicode strings to display in the dialog box.
+ The variable argument list is terminated by a NULL.
+
+**/
+VOID
+EFIAPI
+UiCreatePopUp (
+ IN UINTN Attribute,
+ OUT EFI_INPUT_KEY *Key, OPTIONAL
+ ...
+ )
+{
+ VA_LIST Args;
+
+ VA_START (Args, Key);
+ UiCreatePopUpVaList(Attribute, Key, Args);
+ VA_END (Args);
+}
diff --git a/MdePkg/Library/UiLib/UiLib.inf b/MdePkg/Library/UiLib/UiLib.inf
new file mode 100644
index 0000000..056b9bf
--- /dev/null
+++ b/MdePkg/Library/UiLib/UiLib.inf
@@ -0,0 +1,38 @@
+## @file
+# Instance of UI Library.
+#
+# The UI Library provides functions that are used to construct UI elements.
+#
+# Copyright (c) 2016, American Megatrends, Inc. All rights reserved.<BR>
+#
+# 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
+# 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.
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = UiLib
+ MODULE_UNI_FILE = UiLib.uni
+ FILE_GUID = ffea9b78-9bb6-4ed8-bc61-bcd0a07c3e83
+ MODULE_TYPE = UEFI_DRIVER
+ LIBRARY_CLASS = UiLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
+
+
+[Sources]
+ UiLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ MemoryAllocationLib
+ DebugLib
+ BaseMemoryLib
+ UefiLib
+ UefiBootServicesTableLib
diff --git a/MdePkg/Library/UiLib/UiLib.uni b/MdePkg/Library/UiLib/UiLib.uni
new file mode 100644
index 0000000..87089e7
--- /dev/null
+++ b/MdePkg/Library/UiLib/UiLib.uni
@@ -0,0 +1,21 @@
+// /** @file
+// Instance of UI Library.
+//
+// The UI Library provides functions that are used to construct UI elements.
+//
+// Copyright (c) 2016, American Megatrends, Inc. All rights reserved.<BR>
+//
+// 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
+// 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.
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT #language en-US "Instance of UI Library"
+
+#string STR_MODULE_DESCRIPTION #language en-US "The UI Library provides functions that are used to construct UI elements."
+
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 3e08bed..a8a0a0f 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -233,6 +233,9 @@
## @libraryclass provides EFI_FILE_HANDLE services
FileHandleLib|Include/Library/FileHandleLib.h
+ ## @libraryclass provides functions to construct UI elements.
+ UiLib|Include/Library/CustomizedUiLib.h
+
[LibraryClasses.IA32, LibraryClasses.X64]
## @libraryclass Abstracts both S/W SMI generation and detection.
##
--
2.10.0.windows.1
Please consider the environment before printing this email.
The information contained in this message may be confidential and proprietary to American Megatrends, Inc. This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-11-09 15:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-09 15:44 [PATCH 1/2] MdePkg: UiLib library. Add UiLib. Update UefiLib Felix Poludov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox