]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkPkg/Library/FrameworkUefiLib/Console.c
Remove IntelFrameworkPkg
[mirror_edk2.git] / IntelFrameworkPkg / Library / FrameworkUefiLib / Console.c
diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/Console.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/Console.c
deleted file mode 100644 (file)
index 74ce192..0000000
+++ /dev/null
@@ -1,470 +0,0 @@
-/** @file\r
-  This module provide help function for displaying unicode string.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-\r
-\r
-\r
-#include "UefiLibInternal.h"\r
-\r
-typedef struct {\r
-  CHAR16  WChar;\r
-  UINT32  Width;\r
-} UNICODE_WIDTH_ENTRY;\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED CONST UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {\r
-  //\r
-  // General script area\r
-  //\r
-  {(CHAR16)0x1FFF,  1},\r
-  /*\r
-   * Merge the blocks and replace them with the above entry as they fall to\r
-   * the same category and they are all narrow glyph. This will reduce search\r
-   * time and table size. The merge will omit the reserved code.\r
-   *\r
-   * Remove the above item if below is un-commented.\r
-   *\r
-  {(CHAR16)0x007F,  1},       // C0 controls and basic Latin. 0x0000-0x007F\r
-  {(CHAR16)0x00FF,  1},       // C1 controls and Latin-1 support. 0x0080-0x00FF\r
-  {(CHAR16)0x017F,  1},       // Latin extended-A. 0x0100-0x017F\r
-  {(CHAR16)0x024F,  1},       // Latin extended-B. 0x0180-0x024F\r
-  {(CHAR16)0x02AF,  1},       // IPA extensions. 0x0250-0x02AF\r
-  {(CHAR16)0x02FF,  1},       // Spacing modifier letters. 0x02B0-0x02FF\r
-  {(CHAR16)0x036F,  1},       // Combining diacritical marks. 0x0300-0x036F\r
-  {(CHAR16)0x03FF,  1},       // Greek. 0x0370-0x03FF\r
-  {(CHAR16)0x04FF,  1},       // Cyrillic. 0x0400-0x04FF\r
-  {(CHAR16)0x052F,  0},       // Unassigned. As Armenian in ver3.0. 0x0500-0x052F\r
-  {(CHAR16)0x058F,  1},       // Armenian. 0x0530-0x058F\r
-  {(CHAR16)0x05FF,  1},       // Hebrew. 0x0590-0x05FF\r
-  {(CHAR16)0x06FF,  1},       // Arabic. 0x0600-0x06FF\r
-  {(CHAR16)0x08FF,  0},       // Unassigned. 0x0700-0x08FF\r
-  {(CHAR16)0x097F,  1},       // Devanagari. 0x0900-0x097F\r
-  {(CHAR16)0x09FF,  1},       // Bengali. 0x0980-0x09FF\r
-  {(CHAR16)0x0A7F,  1},       // Gurmukhi. 0x0A00-0x0A7F\r
-  {(CHAR16)0x0AFF,  1},       // Gujarati. 0x0A80-0x0AFF\r
-  {(CHAR16)0x0B7F,  1},       // Oriya. 0x0B00-0x0B7F\r
-  {(CHAR16)0x0BFF,  1},       // Tamil. (See page 7-92). 0x0B80-0x0BFF\r
-  {(CHAR16)0x0C7F,  1},       // Telugu. 0x0C00-0x0C7F\r
-  {(CHAR16)0x0CFF,  1},       // Kannada. (See page 7-100). 0x0C80-0x0CFF\r
-  {(CHAR16)0x0D7F,  1},       // Malayalam (See page 7-104). 0x0D00-0x0D7F\r
-  {(CHAR16)0x0DFF,  0},       // Unassigned. 0x0D80-0x0DFF\r
-  {(CHAR16)0x0E7F,  1},       // Thai. 0x0E00-0x0E7F\r
-  {(CHAR16)0x0EFF,  1},       // Lao. 0x0E80-0x0EFF\r
-  {(CHAR16)0x0FBF,  1},       // Tibetan. 0x0F00-0x0FBF\r
-  {(CHAR16)0x109F,  0},       // Unassigned. 0x0FC0-0x109F\r
-  {(CHAR16)0x10FF,  1},       // Georgian. 0x10A0-0x10FF\r
-  {(CHAR16)0x11FF,  1},       // Hangul Jamo. 0x1100-0x11FF\r
-  {(CHAR16)0x1DFF,  0},       // Unassigned. 0x1200-0x1DFF\r
-  {(CHAR16)0x1EFF,  1},       // Latin extended additional. 0x1E00-0x1EFF\r
-  {(CHAR16)0x1FFF,  1},       // Greek extended. 0x1F00-0x1FFF\r
-  *\r
-  */\r
-\r
-  //\r
-  // Symbol area\r
-  //\r
-  {(CHAR16)0x2FFF,  1},\r
-  /*\r
-   * Merge the blocks and replace them with the above entry as they fall to\r
-   * the same category and they are all narrow glyph. This will reduce search\r
-   * time and table size. The merge will omit the reserved code.\r
-   *\r
-   * Remove the above item if below is un-commented.\r
-   *\r
-  {(CHAR16)0x206F,  1},       // General punctuation. (See page7-154). 0x200-0x206F\r
-  {(CHAR16)0x209F,  1},       // Superscripts and subscripts. 0x2070-0x209F\r
-  {(CHAR16)0x20CF,  1},       // Currency symbols. 0x20A0-0x20CF\r
-  {(CHAR16)0x20FF,  1},       // Combining diacritical marks for symbols. 0x20D0-0x20FF\r
-  {(CHAR16)0x214F,  1},       // Letterlike sympbols. 0x2100-0x214F\r
-  {(CHAR16)0x218F,  1},       // Number forms. 0x2150-0x218F\r
-  {(CHAR16)0x21FF,  1},       // Arrows. 0x2190-0x21FF\r
-  {(CHAR16)0x22FF,  1},       // Mathematical operators. 0x2200-0x22FF\r
-  {(CHAR16)0x23FF,  1},       // Miscellaneous technical. 0x2300-0x23FF\r
-  {(CHAR16)0x243F,  1},       // Control pictures. 0x2400-0x243F\r
-  {(CHAR16)0x245F,  1},       // Optical character recognition. 0x2440-0x245F\r
-  {(CHAR16)0x24FF,  1},       // Enclosed alphanumerics. 0x2460-0x24FF\r
-  {(CHAR16)0x257F,  1},       // Box drawing. 0x2500-0x257F\r
-  {(CHAR16)0x259F,  1},       // Block elements. 0x2580-0x259F\r
-  {(CHAR16)0x25FF,  1},       // Geometric shapes. 0x25A0-0x25FF\r
-  {(CHAR16)0x26FF,  1},       // Miscellaneous symbols. 0x2600-0x26FF\r
-  {(CHAR16)0x27BF,  1},       // Dingbats. 0x2700-0x27BF\r
-  {(CHAR16)0x2FFF,  0},       // Reserved. 0x27C0-0x2FFF\r
-  *\r
-  */\r
-\r
-  //\r
-  // CJK phonetics and symbol area\r
-  //\r
-  {(CHAR16)0x33FF,  2},\r
-  /*\r
-   * Merge the blocks and replace them with the above entry as they fall to\r
-   * the same category and they are all wide glyph. This will reduce search\r
-   * time and table size. The merge will omit the reserved code.\r
-   *\r
-   * Remove the above item if below is un-commented.\r
-   *\r
-  {(CHAR16)0x303F,  2},       // CJK symbols and punctuation. 0x3000-0x303F\r
-  {(CHAR16)0x309F,  2},       // Hiragana. 0x3040-0x309F\r
-  {(CHAR16)0x30FF,  2},       // Katakana. 0x30A0-0x30FF\r
-  {(CHAR16)0x312F,  2},       // Bopomofo. 0x3100-0x312F\r
-  {(CHAR16)0x318F,  2},       // Hangul compatibility jamo. 0x3130-0x318F\r
-  {(CHAR16)0x319F,  2},       // Kanbun. 0x3190-0x319F\r
-  {(CHAR16)0x31FF,  0},       // Reserved. As Bopomofo extended in ver3.0. 0x31A0-0x31FF\r
-  {(CHAR16)0x32FF,  2},       // Enclosed CJK letters and months. 0x3200-0x32FF\r
-  {(CHAR16)0x33FF,  2},       // CJK compatibility. 0x3300-0x33FF\r
-  *\r
-  */\r
-\r
-  //\r
-  // CJK ideograph area\r
-  //\r
-  {(CHAR16)0x9FFF,  2},\r
-  /*\r
-   * Merge the blocks and replace them with the above entry as they fall to\r
-   * the same category and they are all wide glyph. This will reduce search\r
-   * time and table size. The merge will omit the reserved code.\r
-   *\r
-   * Remove the above item if below is un-commented.\r
-   *\r
-  {(CHAR16)0x4DFF,  0},       // Reserved. 0x3400-0x4DBF as CJK unified ideographs\r
-                      // extension A in ver3.0. 0x3400-0x4DFF\r
-  {(CHAR16)0x9FFF,  2},       // CJK unified ideographs. 0x4E00-0x9FFF\r
-  *\r
-  */\r
-\r
-  //\r
-  // Reserved\r
-  //\r
-  {(CHAR16)0xABFF,  0},       // Reserved. 0xA000-0xA490 as Yi syllables. 0xA490-0xA4D0\r
-  // as Yi radicals in ver3.0. 0xA000-0xABFF\r
-  //\r
-  // Hangul syllables\r
-  //\r
-  {(CHAR16)0xD7FF,  2},\r
-  /*\r
-   * Merge the blocks and replace them with the above entry as they fall to\r
-   * the same category and they are all wide glyph. This will reduce search\r
-   * time and table size. The merge will omit the reserved code.\r
-   *\r
-   * Remove the above item if below is un-commented.\r
-   *\r
-  {(CHAR16)0xD7A3,  2},       // Hangul syllables. 0xAC00-0xD7A3\r
-  {(CHAR16)0xD7FF,  0},       // Reserved. 0xD7A3-0xD7FF\r
-  *\r
-  */\r
-\r
-  //\r
-  // Surrogates area\r
-  //\r
-  {(CHAR16)0xDFFF,  0},       // Surrogates, not used now. 0xD800-0xDFFF\r
-\r
-  //\r
-  // Private use area\r
-  //\r
-  {(CHAR16)0xF8FF,  0},       // Private use area. 0xE000-0xF8FF\r
-\r
-  //\r
-  // Compatibility area and specials\r
-  //\r
-  {(CHAR16)0xFAFF,  2},       // CJK compatibility ideographs. 0xF900-0xFAFF\r
-  {(CHAR16)0xFB4F,  1},       // Alphabetic presentation forms. 0xFB00-0xFB4F\r
-  {(CHAR16)0xFDFF,  1},       // Arabic presentation forms-A. 0xFB50-0xFDFF\r
-  {(CHAR16)0xFE1F,  0},       // Reserved. As variation selectors in ver3.0. 0xFE00-0xFE1F\r
-  {(CHAR16)0xFE2F,  1},       // Combining half marks. 0xFE20-0xFE2F\r
-  {(CHAR16)0xFE4F,  2},       // CJK compatibility forms. 0xFE30-0xFE4F\r
-  {(CHAR16)0xFE6F,  1},       // Small Form Variants. 0xFE50-0xFE6F\r
-  {(CHAR16)0xFEFF,  1},       // Arabic presentation forms-B. 0xFE70-0xFEFF\r
-  {(CHAR16)0xFFEF,  1},       // Half width and full width forms. 0xFF00-0xFFEF\r
-  {(CHAR16)0xFFFF,  0},       // Speicials. 0xFFF0-0xFFFF\r
-};\r
-\r
-/**\r
-  Retrieves the width of a Unicode character.\r
-\r
-  This function computes and returns the width of the Unicode character specified\r
-  by UnicodeChar.\r
-\r
-  @param  UnicodeChar   A Unicode character.\r
-\r
-  @retval 0             The width if UnicodeChar could not be determined.\r
-  @retval 1             UnicodeChar is a narrow glyph.\r
-  @retval 2             UnicodeChar is a wide glyph.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-GetGlyphWidth (\r
-  IN CHAR16                         UnicodeChar\r
-  )\r
-{\r
-  UINTN                             Index;\r
-  UINTN                             Low;\r
-  UINTN                             High;\r
-  CONST UNICODE_WIDTH_ENTRY         *Item;\r
-\r
-  Item  = NULL;\r
-  Low   = 0;\r
-  High  = (sizeof (mUnicodeWidthTable)) / (sizeof (UNICODE_WIDTH_ENTRY)) - 1;\r
-  while (Low <= High) {\r
-    Index = (Low + High) >> 1;\r
-    Item  = &(mUnicodeWidthTable[Index]);\r
-    if (Index == 0) {\r
-      if (UnicodeChar <= Item->WChar) {\r
-        break;\r
-      }\r
-\r
-      return 0;\r
-    }\r
-\r
-    if (UnicodeChar > Item->WChar) {\r
-      Low = Index + 1;\r
-    } else if (UnicodeChar <= mUnicodeWidthTable[Index - 1].WChar) {\r
-      High = Index - 1;\r
-    } else {\r
-      //\r
-      // Index - 1 < UnicodeChar <= Index. Found\r
-      //\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (Low <= High) {\r
-    return Item->Width;\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-/**\r
-  Computes the display length of a Null-terminated Unicode String.\r
-\r
-  This function computes and returns the display length of the Null-terminated Unicode\r
-  string specified by String.  If String is NULL then 0 is returned. If any of the widths\r
-  of the Unicode characters in String can not be determined, then 0 is returned. The display\r
-  width of String can be computed by summing the display widths of each Unicode character\r
-  in String.  Unicode characters that are narrow glyphs have a width of 1, and Unicode\r
-  characters that are width glyphs have a width of 2.\r
-  If String is not aligned on a 16-bit boundary, then ASSERT().\r
-\r
-  @param  String   A pointer to a Null-terminated Unicode string.\r
-\r
-  @return          The display length of the Null-terminated Unicode string specified by String.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-UnicodeStringDisplayLength (\r
-  IN CONST CHAR16                   *String\r
-  )\r
-{\r
-  UINTN                             Length;\r
-  UINTN                             Width;\r
-\r
-  if (String == NULL) {\r
-    return 0;\r
-  }\r
-\r
-  Length = 0;\r
-  while (*String != 0) {\r
-    Width = GetGlyphWidth (*String);\r
-    if (Width == 0) {\r
-      return 0;\r
-    }\r
-\r
-    Length += Width;\r
-    String++;\r
-  }\r
-\r
-  return Length;\r
-}\r
-\r
-/**\r
-  Draws a dialog box to the console output device specified by\r
-  ConOut defined in the EFI_SYSTEM_TABLE and waits for a keystroke\r
-  from the console input device specified by ConIn defined in the\r
-  EFI_SYSTEM_TABLE.\r
-\r
-  If there are no strings in the variable argument list, then ASSERT().\r
-  If all the strings in the variable argument list are empty, then ASSERT().\r
-\r
-  @param[in]   Attribute  Specifies the foreground and background color of the popup.\r
-  @param[out]  Key        A pointer to the EFI_KEY value of the key that was\r
-                          pressed.  This is an optional parameter that may be NULL.\r
-                          If it is NULL then no wait for a keypress will be performed.\r
-  @param[in]  ...         The variable argument list that contains pointers to Null-\r
-                          terminated Unicode strings to display in the dialog box.\r
-                          The variable argument list is terminated by a NULL.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-CreatePopUp (\r
-  IN  UINTN          Attribute,\r
-  OUT EFI_INPUT_KEY  *Key,      OPTIONAL\r
-  ...\r
-  )\r
-{\r
-  EFI_STATUS                       Status;\r
-  VA_LIST                          Args;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *ConOut;\r
-  EFI_SIMPLE_TEXT_OUTPUT_MODE      SavedConsoleMode;\r
-  UINTN                            Columns;\r
-  UINTN                            Rows;\r
-  UINTN                            Column;\r
-  UINTN                            Row;\r
-  UINTN                            NumberOfLines;\r
-  UINTN                            MaxLength;\r
-  CHAR16                           *String;\r
-  UINTN                            Length;\r
-  CHAR16                           *Line;\r
-  UINTN                            EventIndex;\r
-\r
-  //\r
-  // Determine the length of the longest line in the popup and the the total\r
-  // number of lines in the popup\r
-  //\r
-  VA_START (Args, Key);\r
-  MaxLength = 0;\r
-  NumberOfLines = 0;\r
-  while ((String = VA_ARG (Args, CHAR16 *)) != NULL) {\r
-    MaxLength = MAX (MaxLength, StrLen (String));\r
-    NumberOfLines++;\r
-  }\r
-  VA_END (Args);\r
-\r
-  //\r
-  // If the total number of lines in the popup is zero, then ASSERT()\r
-  //\r
-  ASSERT (NumberOfLines != 0);\r
-\r
-  //\r
-  // If the maximum length of all the strings is zero, then ASSERT()\r
-  //\r
-  ASSERT (MaxLength != 0);\r
-\r
-  //\r
-  // Cache a pointer to the Simple Text Output Protocol in the EFI System Table\r
-  //\r
-  ConOut = gST->ConOut;\r
-\r
-  //\r
-  // Save the current console cursor position and attributes\r
-  //\r
-  CopyMem (&SavedConsoleMode, ConOut->Mode, sizeof (SavedConsoleMode));\r
-\r
-  //\r
-  // Retrieve the number of columns and rows in the current console mode\r
-  //\r
-  ConOut->QueryMode (ConOut, SavedConsoleMode.Mode, &Columns, &Rows);\r
-\r
-  //\r
-  // Disable cursor and set the foreground and background colors specified by Attribute\r
-  //\r
-  ConOut->EnableCursor (ConOut, FALSE);\r
-  ConOut->SetAttribute (ConOut, Attribute);\r
-\r
-  //\r
-  // Limit NumberOfLines to height of the screen minus 3 rows for the box itself\r
-  //\r
-  NumberOfLines = MIN (NumberOfLines, Rows - 3);\r
-\r
-  //\r
-  // Limit MaxLength to width of the screen minus 2 columns for the box itself\r
-  //\r
-  MaxLength = MIN (MaxLength, Columns - 2);\r
-\r
-  //\r
-  // Compute the starting row and starting column for the popup\r
-  //\r
-  Row    = (Rows - (NumberOfLines + 3)) / 2;\r
-  Column = (Columns - (MaxLength + 2)) / 2;\r
-\r
-  //\r
-  // Allocate a buffer for a single line of the popup with borders and a Null-terminator\r
-  //\r
-  Line = AllocateZeroPool ((MaxLength + 3) * sizeof (CHAR16));\r
-  ASSERT (Line != NULL);\r
-\r
-  //\r
-  // Draw top of popup box\r
-  //\r
-  SetMem16 (Line, (MaxLength + 2) * 2, BOXDRAW_HORIZONTAL);\r
-  Line[0]             = BOXDRAW_DOWN_RIGHT;\r
-  Line[MaxLength + 1] = BOXDRAW_DOWN_LEFT;\r
-  Line[MaxLength + 2] = L'\0';\r
-  ConOut->SetCursorPosition (ConOut, Column, Row++);\r
-  ConOut->OutputString (ConOut, Line);\r
-\r
-  //\r
-  // Draw middle of the popup with strings\r
-  //\r
-  VA_START (Args, Key);\r
-  while ((String = VA_ARG (Args, CHAR16 *)) != NULL && NumberOfLines > 0) {\r
-    Length = StrLen (String);\r
-    SetMem16 (Line, (MaxLength + 2) * 2, L' ');\r
-    if (Length <= MaxLength) {\r
-      //\r
-      // Length <= MaxLength\r
-      //\r
-      CopyMem (Line + 1 + (MaxLength - Length) / 2, String , Length * sizeof (CHAR16));\r
-    } else {\r
-      //\r
-      // Length > MaxLength\r
-      //\r
-      CopyMem (Line + 1, String + (Length - MaxLength) / 2 , MaxLength * sizeof (CHAR16));\r
-    }\r
-    Line[0]             = BOXDRAW_VERTICAL;\r
-    Line[MaxLength + 1] = BOXDRAW_VERTICAL;\r
-    Line[MaxLength + 2] = L'\0';\r
-    ConOut->SetCursorPosition (ConOut, Column, Row++);\r
-    ConOut->OutputString (ConOut, Line);\r
-    NumberOfLines--;\r
-  }\r
-  VA_END (Args);\r
-\r
-  //\r
-  // Draw bottom of popup box\r
-  //\r
-  SetMem16 (Line, (MaxLength + 2) * 2, BOXDRAW_HORIZONTAL);\r
-  Line[0]             = BOXDRAW_UP_RIGHT;\r
-  Line[MaxLength + 1] = BOXDRAW_UP_LEFT;\r
-  Line[MaxLength + 2] = L'\0';\r
-  ConOut->SetCursorPosition (ConOut, Column, Row++);\r
-  ConOut->OutputString (ConOut, Line);\r
-\r
-  //\r
-  // Free the allocated line buffer\r
-  //\r
-  FreePool (Line);\r
-\r
-  //\r
-  // Restore the cursor visibility, position, and attributes\r
-  //\r
-  ConOut->EnableCursor      (ConOut, SavedConsoleMode.CursorVisible);\r
-  ConOut->SetCursorPosition (ConOut, SavedConsoleMode.CursorColumn, SavedConsoleMode.CursorRow);\r
-  ConOut->SetAttribute      (ConOut, SavedConsoleMode.Attribute);\r
-\r
-  //\r
-  // Wait for a keystroke\r
-  //\r
-  if (Key != NULL) {\r
-    while (TRUE) {\r
-      Status = gST->ConIn->ReadKeyStroke (gST->ConIn, Key);\r
-      if (!EFI_ERROR (Status)) {\r
-        break;\r
-      }\r
-\r
-      //\r
-      // If we encounter error, continue to read another key in.\r
-      //\r
-      if (Status != EFI_NOT_READY) {\r
-        continue;\r
-      }\r
-      gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
-    }\r
-  }\r
-}\r