From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=shenglei.zhang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 354A721959CB2 for ; Tue, 13 Nov 2018 00:35:30 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2018 00:35:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,498,1534834800"; d="scan'208";a="105805385" Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by fmsmga004.fm.intel.com with ESMTP; 13 Nov 2018 00:35:27 -0800 From: Shenglei Zhang To: edk2-devel@lists.01.org Cc: Liming Gao , Michael D Kinney Date: Tue, 13 Nov 2018 16:35:13 +0800 Message-Id: <20181113083518.6824-4-shenglei.zhang@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20181113083518.6824-1-shenglei.zhang@intel.com> References: <20181113083518.6824-1-shenglei.zhang@intel.com> Subject: [PATCH 3/8] IntelFrameworkPkg/FrameworkUefiLib: Remove FrameworkUefiLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Nov 2018 08:35:30 -0000 FrameworkUefiLib is not used, so it is removed. https://bugzilla.tianocore.org/show_bug.cgi?id=1190 Cc: Liming Gao Cc: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Shenglei Zhang --- .../Library/FrameworkUefiLib/Acpi.c | 88 - .../Library/FrameworkUefiLib/Console.c | 476 ----- .../FrameworkUefiLib/FrameworkUefiLib.inf | 84 - .../FrameworkUefiLib/FrameworkUefiLib.uni | 23 - .../FrameworkUefiLib/UefiDriverModel.c | 1056 --------- .../Library/FrameworkUefiLib/UefiLib.c | 1892 ----------------- .../FrameworkUefiLib/UefiLibInternal.h | 44 - .../Library/FrameworkUefiLib/UefiLibPrint.c | 822 ------- .../Library/FrameworkUefiLib/UefiNotTiano.c | 327 --- 9 files changed, 4812 deletions(-) delete mode 100644 IntelFrameworkPkg/Library/FrameworkUefiLib/Acpi.c delete mode 100644 IntelFrameworkPkg/Library/FrameworkUefiLib/Console.c delete mode 100644 IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.inf delete mode 100644 IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.uni delete mode 100644 IntelFrameworkPkg/Library/FrameworkUefiLib/UefiDriverModel.c delete mode 100644 IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c delete mode 100644 IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h delete mode 100644 IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibPrint.c delete mode 100644 IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/Acpi.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/Acpi.c deleted file mode 100644 index 4b41abd036..0000000000 --- a/IntelFrameworkPkg/Library/FrameworkUefiLib/Acpi.c +++ /dev/null @@ -1,88 +0,0 @@ -/** @file - This module provides help function for finding ACPI table. - - Copyright (c) 2018, 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 - 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 "UefiLibInternal.h" -#include - -/** - This function locates next ACPI table in XSDT/RSDT based on Signature and - previous returned Table. - - If PreviousTable is NULL: - This function will locate the first ACPI table in XSDT/RSDT based on - Signature in gEfiAcpi20TableGuid system configuration table first, and then - gEfiAcpi10TableGuid system configuration table. - This function will locate in XSDT first, and then RSDT. - For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in - FADT. - For FACS, this function will locate XFirmwareCtrl in FADT first, and then - FirmwareCtrl in FADT. - - If PreviousTable is not NULL: - 1. If it could be located in XSDT in gEfiAcpi20TableGuid system configuration - table, then this function will just locate next table in XSDT in - gEfiAcpi20TableGuid system configuration table. - 2. If it could be located in RSDT in gEfiAcpi20TableGuid system configuration - table, then this function will just locate next table in RSDT in - gEfiAcpi20TableGuid system configuration table. - 3. If it could be located in RSDT in gEfiAcpi10TableGuid system configuration - table, then this function will just locate next table in RSDT in - gEfiAcpi10TableGuid system configuration table. - - It's not supported that PreviousTable is not NULL but PreviousTable->Signature - is not same with Signature, NULL will be returned. - - @param Signature ACPI table signature. - @param PreviousTable Pointer to previous returned table to locate next - table, or NULL to locate first table. - - @return Next ACPI table or NULL if not found. - -**/ -EFI_ACPI_COMMON_HEADER * -EFIAPI -EfiLocateNextAcpiTable ( - IN UINT32 Signature, - IN EFI_ACPI_COMMON_HEADER *PreviousTable OPTIONAL - ) -{ - ASSERT (FALSE); - return NULL; -} - -/** - This function locates first ACPI table in XSDT/RSDT based on Signature. - - This function will locate the first ACPI table in XSDT/RSDT based on - Signature in gEfiAcpi20TableGuid system configuration table first, and then - gEfiAcpi10TableGuid system configuration table. - This function will locate in XSDT first, and then RSDT. - For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in - FADT. - For FACS, this function will locate XFirmwareCtrl in FADT first, and then - FirmwareCtrl in FADT. - - @param Signature ACPI table signature. - - @return First ACPI table or NULL if not found. - -**/ -EFI_ACPI_COMMON_HEADER * -EFIAPI -EfiLocateFirstAcpiTable ( - IN UINT32 Signature - ) -{ - return EfiLocateNextAcpiTable (Signature, NULL); -} diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/Console.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/Console.c deleted file mode 100644 index d32492f7cd..0000000000 --- a/IntelFrameworkPkg/Library/FrameworkUefiLib/Console.c +++ /dev/null @@ -1,476 +0,0 @@ -/** @file - This module provide help function for displaying unicode string. - - Copyright (c) 2006 - 2018, 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 - 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 "UefiLibInternal.h" - -typedef struct { - CHAR16 WChar; - UINT32 Width; -} UNICODE_WIDTH_ENTRY; - -GLOBAL_REMOVE_IF_UNREFERENCED CONST UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = { - // - // General script area - // - {(CHAR16)0x1FFF, 1}, - /* - * Merge the blocks and replace them with the above entry as they fall to - * the same category and they are all narrow glyph. This will reduce search - * time and table size. The merge will omit the reserved code. - * - * Remove the above item if below is un-commented. - * - {(CHAR16)0x007F, 1}, // C0 controls and basic Latin. 0x0000-0x007F - {(CHAR16)0x00FF, 1}, // C1 controls and Latin-1 support. 0x0080-0x00FF - {(CHAR16)0x017F, 1}, // Latin extended-A. 0x0100-0x017F - {(CHAR16)0x024F, 1}, // Latin extended-B. 0x0180-0x024F - {(CHAR16)0x02AF, 1}, // IPA extensions. 0x0250-0x02AF - {(CHAR16)0x02FF, 1}, // Spacing modifier letters. 0x02B0-0x02FF - {(CHAR16)0x036F, 1}, // Combining diacritical marks. 0x0300-0x036F - {(CHAR16)0x03FF, 1}, // Greek. 0x0370-0x03FF - {(CHAR16)0x04FF, 1}, // Cyrillic. 0x0400-0x04FF - {(CHAR16)0x052F, 0}, // Unassigned. As Armenian in ver3.0. 0x0500-0x052F - {(CHAR16)0x058F, 1}, // Armenian. 0x0530-0x058F - {(CHAR16)0x05FF, 1}, // Hebrew. 0x0590-0x05FF - {(CHAR16)0x06FF, 1}, // Arabic. 0x0600-0x06FF - {(CHAR16)0x08FF, 0}, // Unassigned. 0x0700-0x08FF - {(CHAR16)0x097F, 1}, // Devanagari. 0x0900-0x097F - {(CHAR16)0x09FF, 1}, // Bengali. 0x0980-0x09FF - {(CHAR16)0x0A7F, 1}, // Gurmukhi. 0x0A00-0x0A7F - {(CHAR16)0x0AFF, 1}, // Gujarati. 0x0A80-0x0AFF - {(CHAR16)0x0B7F, 1}, // Oriya. 0x0B00-0x0B7F - {(CHAR16)0x0BFF, 1}, // Tamil. (See page 7-92). 0x0B80-0x0BFF - {(CHAR16)0x0C7F, 1}, // Telugu. 0x0C00-0x0C7F - {(CHAR16)0x0CFF, 1}, // Kannada. (See page 7-100). 0x0C80-0x0CFF - {(CHAR16)0x0D7F, 1}, // Malayalam (See page 7-104). 0x0D00-0x0D7F - {(CHAR16)0x0DFF, 0}, // Unassigned. 0x0D80-0x0DFF - {(CHAR16)0x0E7F, 1}, // Thai. 0x0E00-0x0E7F - {(CHAR16)0x0EFF, 1}, // Lao. 0x0E80-0x0EFF - {(CHAR16)0x0FBF, 1}, // Tibetan. 0x0F00-0x0FBF - {(CHAR16)0x109F, 0}, // Unassigned. 0x0FC0-0x109F - {(CHAR16)0x10FF, 1}, // Georgian. 0x10A0-0x10FF - {(CHAR16)0x11FF, 1}, // Hangul Jamo. 0x1100-0x11FF - {(CHAR16)0x1DFF, 0}, // Unassigned. 0x1200-0x1DFF - {(CHAR16)0x1EFF, 1}, // Latin extended additional. 0x1E00-0x1EFF - {(CHAR16)0x1FFF, 1}, // Greek extended. 0x1F00-0x1FFF - * - */ - - // - // Symbol area - // - {(CHAR16)0x2FFF, 1}, - /* - * Merge the blocks and replace them with the above entry as they fall to - * the same category and they are all narrow glyph. This will reduce search - * time and table size. The merge will omit the reserved code. - * - * Remove the above item if below is un-commented. - * - {(CHAR16)0x206F, 1}, // General punctuation. (See page7-154). 0x200-0x206F - {(CHAR16)0x209F, 1}, // Superscripts and subscripts. 0x2070-0x209F - {(CHAR16)0x20CF, 1}, // Currency symbols. 0x20A0-0x20CF - {(CHAR16)0x20FF, 1}, // Combining diacritical marks for symbols. 0x20D0-0x20FF - {(CHAR16)0x214F, 1}, // Letterlike sympbols. 0x2100-0x214F - {(CHAR16)0x218F, 1}, // Number forms. 0x2150-0x218F - {(CHAR16)0x21FF, 1}, // Arrows. 0x2190-0x21FF - {(CHAR16)0x22FF, 1}, // Mathematical operators. 0x2200-0x22FF - {(CHAR16)0x23FF, 1}, // Miscellaneous technical. 0x2300-0x23FF - {(CHAR16)0x243F, 1}, // Control pictures. 0x2400-0x243F - {(CHAR16)0x245F, 1}, // Optical character recognition. 0x2440-0x245F - {(CHAR16)0x24FF, 1}, // Enclosed alphanumerics. 0x2460-0x24FF - {(CHAR16)0x257F, 1}, // Box drawing. 0x2500-0x257F - {(CHAR16)0x259F, 1}, // Block elements. 0x2580-0x259F - {(CHAR16)0x25FF, 1}, // Geometric shapes. 0x25A0-0x25FF - {(CHAR16)0x26FF, 1}, // Miscellaneous symbols. 0x2600-0x26FF - {(CHAR16)0x27BF, 1}, // Dingbats. 0x2700-0x27BF - {(CHAR16)0x2FFF, 0}, // Reserved. 0x27C0-0x2FFF - * - */ - - // - // CJK phonetics and symbol area - // - {(CHAR16)0x33FF, 2}, - /* - * Merge the blocks and replace them with the above entry as they fall to - * the same category and they are all wide glyph. This will reduce search - * time and table size. The merge will omit the reserved code. - * - * Remove the above item if below is un-commented. - * - {(CHAR16)0x303F, 2}, // CJK symbols and punctuation. 0x3000-0x303F - {(CHAR16)0x309F, 2}, // Hiragana. 0x3040-0x309F - {(CHAR16)0x30FF, 2}, // Katakana. 0x30A0-0x30FF - {(CHAR16)0x312F, 2}, // Bopomofo. 0x3100-0x312F - {(CHAR16)0x318F, 2}, // Hangul compatibility jamo. 0x3130-0x318F - {(CHAR16)0x319F, 2}, // Kanbun. 0x3190-0x319F - {(CHAR16)0x31FF, 0}, // Reserved. As Bopomofo extended in ver3.0. 0x31A0-0x31FF - {(CHAR16)0x32FF, 2}, // Enclosed CJK letters and months. 0x3200-0x32FF - {(CHAR16)0x33FF, 2}, // CJK compatibility. 0x3300-0x33FF - * - */ - - // - // CJK ideograph area - // - {(CHAR16)0x9FFF, 2}, - /* - * Merge the blocks and replace them with the above entry as they fall to - * the same category and they are all wide glyph. This will reduce search - * time and table size. The merge will omit the reserved code. - * - * Remove the above item if below is un-commented. - * - {(CHAR16)0x4DFF, 0}, // Reserved. 0x3400-0x4DBF as CJK unified ideographs - // extension A in ver3.0. 0x3400-0x4DFF - {(CHAR16)0x9FFF, 2}, // CJK unified ideographs. 0x4E00-0x9FFF - * - */ - - // - // Reserved - // - {(CHAR16)0xABFF, 0}, // Reserved. 0xA000-0xA490 as Yi syllables. 0xA490-0xA4D0 - // as Yi radicals in ver3.0. 0xA000-0xABFF - // - // Hangul syllables - // - {(CHAR16)0xD7FF, 2}, - /* - * Merge the blocks and replace them with the above entry as they fall to - * the same category and they are all wide glyph. This will reduce search - * time and table size. The merge will omit the reserved code. - * - * Remove the above item if below is un-commented. - * - {(CHAR16)0xD7A3, 2}, // Hangul syllables. 0xAC00-0xD7A3 - {(CHAR16)0xD7FF, 0}, // Reserved. 0xD7A3-0xD7FF - * - */ - - // - // Surrogates area - // - {(CHAR16)0xDFFF, 0}, // Surrogates, not used now. 0xD800-0xDFFF - - // - // Private use area - // - {(CHAR16)0xF8FF, 0}, // Private use area. 0xE000-0xF8FF - - // - // Compatibility area and specials - // - {(CHAR16)0xFAFF, 2}, // CJK compatibility ideographs. 0xF900-0xFAFF - {(CHAR16)0xFB4F, 1}, // Alphabetic presentation forms. 0xFB00-0xFB4F - {(CHAR16)0xFDFF, 1}, // Arabic presentation forms-A. 0xFB50-0xFDFF - {(CHAR16)0xFE1F, 0}, // Reserved. As variation selectors in ver3.0. 0xFE00-0xFE1F - {(CHAR16)0xFE2F, 1}, // Combining half marks. 0xFE20-0xFE2F - {(CHAR16)0xFE4F, 2}, // CJK compatibility forms. 0xFE30-0xFE4F - {(CHAR16)0xFE6F, 1}, // Small Form Variants. 0xFE50-0xFE6F - {(CHAR16)0xFEFF, 1}, // Arabic presentation forms-B. 0xFE70-0xFEFF - {(CHAR16)0xFFEF, 1}, // Half width and full width forms. 0xFF00-0xFFEF - {(CHAR16)0xFFFF, 0}, // Speicials. 0xFFF0-0xFFFF -}; - -/** - Retrieves the width of a Unicode character. - - This function computes and returns the width of the Unicode character specified - by UnicodeChar. - - @param UnicodeChar A Unicode character. - - @retval 0 The width if UnicodeChar could not be determined. - @retval 1 UnicodeChar is a narrow glyph. - @retval 2 UnicodeChar is a wide glyph. - -**/ -UINTN -EFIAPI -GetGlyphWidth ( - IN CHAR16 UnicodeChar - ) -{ - UINTN Index; - UINTN Low; - UINTN High; - CONST UNICODE_WIDTH_ENTRY *Item; - - Item = NULL; - Low = 0; - High = (sizeof (mUnicodeWidthTable)) / (sizeof (UNICODE_WIDTH_ENTRY)) - 1; - while (Low <= High) { - Index = (Low + High) >> 1; - Item = &(mUnicodeWidthTable[Index]); - if (Index == 0) { - if (UnicodeChar <= Item->WChar) { - break; - } - - return 0; - } - - if (UnicodeChar > Item->WChar) { - Low = Index + 1; - } else if (UnicodeChar <= mUnicodeWidthTable[Index - 1].WChar) { - High = Index - 1; - } else { - // - // Index - 1 < UnicodeChar <= Index. Found - // - break; - } - } - - if (Low <= High) { - return Item->Width; - } - - return 0; -} - -/** - Computes the display length of a Null-terminated Unicode String. - - This function computes and returns the display length of the Null-terminated Unicode - string specified by String. If String is NULL then 0 is returned. If any of the widths - of the Unicode characters in String can not be determined, then 0 is returned. The display - width of String can be computed by summing the display widths of each Unicode character - in String. Unicode characters that are narrow glyphs have a width of 1, and Unicode - characters that are width glyphs have a width of 2. - If String is not aligned on a 16-bit boundary, then ASSERT(). - - @param String A pointer to a Null-terminated Unicode string. - - @return The display length of the Null-terminated Unicode string specified by String. - -**/ -UINTN -EFIAPI -UnicodeStringDisplayLength ( - IN CONST CHAR16 *String - ) -{ - UINTN Length; - UINTN Width; - - if (String == NULL) { - return 0; - } - - Length = 0; - while (*String != 0) { - Width = GetGlyphWidth (*String); - if (Width == 0) { - return 0; - } - - Length += Width; - String++; - } - - return Length; -} - -/** - 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 -CreatePopUp ( - IN UINTN Attribute, - OUT EFI_INPUT_KEY *Key, OPTIONAL - ... - ) -{ - 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; - - // - // 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, StrLen (String)); - 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) { - Length = StrLen (String); - SetMem16 (Line, (MaxLength + 2) * 2, L' '); - if (Length <= MaxLength) { - // - // Length <= MaxLength - // - CopyMem (Line + 1 + (MaxLength - Length) / 2, String , Length * sizeof (CHAR16)); - } else { - // - // Length > MaxLength - // - CopyMem (Line + 1, String + (Length - MaxLength) / 2 , MaxLength * sizeof (CHAR16)); - } - Line[0] = BOXDRAW_VERTICAL; - Line[MaxLength + 1] = BOXDRAW_VERTICAL; - Line[MaxLength + 2] = L'\0'; - ConOut->SetCursorPosition (ConOut, Column, Row++); - ConOut->OutputString (ConOut, Line); - NumberOfLines--; - } - 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/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.inf b/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.inf deleted file mode 100644 index 086d898ee7..0000000000 --- a/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.inf +++ /dev/null @@ -1,84 +0,0 @@ -## @file -# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification. -# -# This library is helpful to port Framework/Tinao code that has conflicts with UEFI 2.0. -# It hides the old conflicts with library functions and supporting implementations of -# the old (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. -# -# Copyright (c) 2006 - 2018, 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 -# 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 = FrameworkUefiLib - MODULE_UNI_FILE = FrameworkUefiLib.uni - FILE_GUID = B2F0D71A-A39F-4094-854B-0C6BA6910CCE - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = UefiLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER - -# -# VALID_ARCHITECTURES = IA32 X64 EBC -# - -[Sources] - UefiLibPrint.c - UefiNotTiano.c - UefiDriverModel.c - Console.c - UefiLib.c - UefiLibInternal.h - Acpi.c - -[Packages] - MdePkg/MdePkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec - -[LibraryClasses] - PrintLib - PcdLib - MemoryAllocationLib - DebugLib - BaseMemoryLib - BaseLib - UefiBootServicesTableLib - DevicePathLib - -[Guids] - gEfiEventReadyToBootGuid ## SOMETIMES_CONSUMES ## Event - gEfiEventLegacyBootGuid ## SOMETIMES_CONSUMES ## Event - -[Protocols] - gEfiDriverBindingProtocolGuid ## SOMETIMES_PRODUCES - gEfiSimpleTextOutProtocolGuid ## SOMETIMES_CONSUMES - gEfiGraphicsOutputProtocolGuid ## SOMETIMES_CONSUMES - gEfiHiiFontProtocolGuid ## SOMETIMES_CONSUMES - gEfiSimpleFileSystemProtocolGuid ## SOMETIMES_CONSUMES - gEfiComponentNameProtocolGuid ## SOMETIMES_PRODUCES - gEfiComponentName2ProtocolGuid ## SOMETIMES_PRODUCES - gEfiDriverConfigurationProtocolGuid ## SOMETIMES_PRODUCES - gEfiDriverConfiguration2ProtocolGuid ## SOMETIMES_PRODUCES - gEfiDriverDiagnosticsProtocolGuid ## SOMETIMES_PRODUCES - gEfiDriverDiagnostics2ProtocolGuid ## SOMETIMES_PRODUCES - gEfiUgaDrawProtocolGuid ## SOMETIMES_CONSUMES - - -[Pcd] - gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize ## SOMETIMES_CONSUMES - -[FeaturePcd] - gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable ## CONSUMES - gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable ## CONSUMES - gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable ## CONSUMES - gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable ## CONSUMES - gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport ## CONSUMES - diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.uni b/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.uni deleted file mode 100644 index 8643521eff..0000000000 --- a/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.uni +++ /dev/null @@ -1,23 +0,0 @@ -// /** @file -// Library to abstract Framework extensions that conflict with UEFI 2.0 Specification. -// -// This library is helpful to port Framework/Tinao code that has conflicts with UEFI 2.0. -// It hides the old conflicts with library functions and supporting implementations of -// the old (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. -// -// Copyright (c) 2006 - 2014, 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 -// 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 "Library to abstract Framework extensions that conflict with the UEFI 2.0 Specification" - -#string STR_MODULE_DESCRIPTION #language en-US "This library is helpful to port Framework/Tiano code that has conflicts with UEFI 2.0. It hides the old conflicts with library functions and supporting implementations of the old (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) methods." - diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiDriverModel.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiDriverModel.c deleted file mode 100644 index 83482dad1c..0000000000 --- a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiDriverModel.c +++ /dev/null @@ -1,1056 +0,0 @@ -/** @file - Library functions that abstract driver model protocols - installation. - - Copyright (c) 2006 - 2018, 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 - 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 "UefiLibInternal.h" - -/** - Installs and completes the initialization of a Driver Binding Protocol instance. - - Installs the Driver Binding Protocol specified by DriverBinding onto the handle - specified by DriverBindingHandle. If DriverBindingHandle is NULL, then DriverBinding - is installed onto a newly created handle. DriverBindingHandle is typically the same - as the driver's ImageHandle, but it can be different if the driver produces multiple - Driver Binding Protocols. - If DriverBinding is NULL, then ASSERT(). - If DriverBinding can not be installed onto a handle, then ASSERT(). - - @param ImageHandle The image handle of the driver. - @param SystemTable The EFI System Table that was passed to the driver's entry point. - @param DriverBinding A Driver Binding Protocol instance that this driver is producing. - @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this - parameter is NULL, then a new handle is created. - - @retval EFI_SUCCESS The protocol installation is completed successfully. - @retval EFI_OUT_OF_RESOURCES There was not enough system resources to install the protocol. - @retval Others Status from gBS->InstallMultipleProtocolInterfaces(). - -**/ -EFI_STATUS -EFIAPI -EfiLibInstallDriverBinding ( - IN CONST EFI_HANDLE ImageHandle, - IN CONST EFI_SYSTEM_TABLE *SystemTable, - IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, - IN EFI_HANDLE DriverBindingHandle - ) -{ - EFI_STATUS Status; - - ASSERT (DriverBinding != NULL); - - // - // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol - // - DriverBinding->ImageHandle = ImageHandle; - DriverBinding->DriverBindingHandle = DriverBindingHandle; - - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - NULL - ); - // - // ASSERT if the call to InstallMultipleProtocolInterfaces() failed - // - ASSERT_EFI_ERROR (Status); - - return Status; -} - - -/** - Installs and completes the initialization of a Driver Binding Protocol instance and - optionally installs the Component Name, Driver Configuration and Driver Diagnostics Protocols. - - Initializes a driver by installing the Driver Binding Protocol together with the - optional Component Name, optional Driver Configure and optional Driver Diagnostic - Protocols onto the driver's DriverBindingHandle. If DriverBindingHandle is NULL, - then the protocols are installed onto a newly created handle. DriverBindingHandle - is typically the same as the driver's ImageHandle, but it can be different if the - driver produces multiple Driver Binding Protocols. - If DriverBinding is NULL, then ASSERT(). - If the installation fails, then ASSERT(). - - @param ImageHandle The image handle of the driver. - @param SystemTable The EFI System Table that was passed to the driver's entry point. - @param DriverBinding A Driver Binding Protocol instance that this driver is producing. - @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this - parameter is NULL, then a new handle is created. - @param ComponentName A Component Name Protocol instance that this driver is producing. - @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing. - @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing. - - @retval EFI_SUCCESS The protocol installation is completed successfully. - @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols. - -**/ -EFI_STATUS -EFIAPI -EfiLibInstallAllDriverProtocols ( - IN CONST EFI_HANDLE ImageHandle, - IN CONST EFI_SYSTEM_TABLE *SystemTable, - IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, - IN EFI_HANDLE DriverBindingHandle, - IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL - IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL - IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL - ) -{ - EFI_STATUS Status; - - ASSERT (DriverBinding != NULL); - - // - // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol - // - DriverBinding->ImageHandle = ImageHandle; - DriverBinding->DriverBindingHandle = DriverBindingHandle; - - if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) { - if (DriverConfiguration == NULL) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - NULL - ); - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } - } - } else { - if (DriverConfiguration == NULL) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } - } - - // - // ASSERT if the call to InstallMultipleProtocolInterfaces() failed - // - ASSERT_EFI_ERROR (Status); - - return Status; -} - - - -/** - Installs Driver Binding Protocol with optional Component Name and Component Name 2 Protocols. - - Initializes a driver by installing the Driver Binding Protocol together with the - optional Component Name and optional Component Name 2 protocols onto the driver's - DriverBindingHandle. If DriverBindingHandle is NULL, then the protocols are installed - onto a newly created handle. DriverBindingHandle is typically the same as the driver's - ImageHandle, but it can be different if the driver produces multiple Driver Binding Protocols. - If DriverBinding is NULL, then ASSERT(). - If the installation fails, then ASSERT(). - - @param ImageHandle The image handle of the driver. - @param SystemTable The EFI System Table that was passed to the driver's entry point. - @param DriverBinding A Driver Binding Protocol instance that this driver is producing. - @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this - parameter is NULL, then a new handle is created. - @param ComponentName A Component Name Protocol instance that this driver is producing. - @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing. - - @retval EFI_SUCCESS The protocol installation is completed successfully. - @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols. - -**/ -EFI_STATUS -EFIAPI -EfiLibInstallDriverBindingComponentName2 ( - IN CONST EFI_HANDLE ImageHandle, - IN CONST EFI_SYSTEM_TABLE *SystemTable, - IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, - IN EFI_HANDLE DriverBindingHandle, - IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL - IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL - ) -{ - EFI_STATUS Status; - - ASSERT (DriverBinding != NULL); - - // - // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol - // - DriverBinding->ImageHandle = ImageHandle; - DriverBinding->DriverBindingHandle = DriverBindingHandle; - - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - NULL - ); - } - } - - // - // ASSERT if the call to InstallMultipleProtocolInterfaces() failed - // - ASSERT_EFI_ERROR (Status); - - return Status; -} - - - -/** - Installs Driver Binding Protocol with optional Component Name, Component Name 2, Driver - Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols. - - Initializes a driver by installing the Driver Binding Protocol together with the optional - Component Name, optional Component Name 2, optional Driver Configuration, optional Driver Configuration 2, - optional Driver Diagnostic, and optional Driver Diagnostic 2 Protocols onto the driver's DriverBindingHandle. - DriverBindingHandle is typically the same as the driver's ImageHandle, but it can be different if the driver - produces multiple Driver Binding Protocols. - If DriverBinding is NULL, then ASSERT(). - If the installation fails, then ASSERT(). - - - @param ImageHandle The image handle of the driver. - @param SystemTable The EFI System Table that was passed to the driver's entry point. - @param DriverBinding A Driver Binding Protocol instance that this driver is producing. - @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this - parameter is NULL, then a new handle is created. - @param ComponentName A Component Name Protocol instance that this driver is producing. - @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing. - @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing. - @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver is producing. - @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing. - @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing. - - @retval EFI_SUCCESS The protocol installation is completed successfully. - @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols. - -**/ -EFI_STATUS -EFIAPI -EfiLibInstallAllDriverProtocols2 ( - IN CONST EFI_HANDLE ImageHandle, - IN CONST EFI_SYSTEM_TABLE *SystemTable, - IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, - IN EFI_HANDLE DriverBindingHandle, - IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL - IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2, OPTIONAL - IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL - IN CONST EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2, OPTIONAL - IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics, OPTIONAL - IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL - ) -{ - EFI_STATUS Status; - - ASSERT (DriverBinding != NULL); - - // - // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol - // - DriverBinding->ImageHandle = ImageHandle; - DriverBinding->DriverBindingHandle = DriverBindingHandle; - - if (DriverConfiguration2 == NULL) { - if (DriverConfiguration == NULL) { - if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } else { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } - } else { - if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } else { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } - } - } else { - if (DriverConfiguration == NULL) { - if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } else { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } - } else { - if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } else { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBinding->DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } - } - } - - // - // ASSERT if the call to InstallMultipleProtocolInterfaces() failed - // - ASSERT_EFI_ERROR (Status); - - return Status; -} diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c deleted file mode 100644 index 45bf4b17c5..0000000000 --- a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c +++ /dev/null @@ -1,1892 +0,0 @@ -/** @file - The UEFI Library provides functions and macros that simplify the development of - UEFI Drivers and UEFI Applications. These functions and macros help manage EFI - events, build simple locks utilizing EFI Task Priority Levels (TPLs), install - EFI Driver Model related protocols, manage Unicode string tables for UEFI Drivers, - and print messages on the console output and standard error devices. - - Copyright (c) 2006 - 2018, 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 - 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 "UefiLibInternal.h" - -/** - Compare whether two names of languages are identical. - - @param Language1 Name of language 1. - @param Language2 Name of language 2. - - @retval TRUE Language 1 and language 2 are the same. - @retval FALSE Language 1 and language 2 are not the same. - -**/ -BOOLEAN -CompareIso639LanguageCode ( - IN CONST CHAR8 *Language1, - IN CONST CHAR8 *Language2 - ) -{ - UINT32 Name1; - UINT32 Name2; - - Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1); - Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2); - - return (BOOLEAN) (Name1 == Name2); -} - -/** - Retrieves a pointer to the system configuration table from the EFI System Table - based on a specified GUID. - - This function searches the list of configuration tables stored in the EFI System Table - for a table with a GUID that matches TableGuid. If a match is found, then a pointer to - the configuration table is returned in Table., and EFI_SUCCESS is returned. If a matching GUID - is not found, then EFI_NOT_FOUND is returned. - If TableGuid is NULL, then ASSERT(). - If Table is NULL, then ASSERT(). - - @param TableGuid Pointer to table's GUID type.. - @param Table Pointer to the table associated with TableGuid in the EFI System Table. - - @retval EFI_SUCCESS A configuration table matching TableGuid was found. - @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found. - -**/ -EFI_STATUS -EFIAPI -EfiGetSystemConfigurationTable ( - IN EFI_GUID *TableGuid, - OUT VOID **Table - ) -{ - EFI_SYSTEM_TABLE *SystemTable; - UINTN Index; - - ASSERT (TableGuid != NULL); - ASSERT (Table != NULL); - - SystemTable = gST; - *Table = NULL; - for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) { - if (CompareGuid (TableGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) { - *Table = SystemTable->ConfigurationTable[Index].VendorTable; - return EFI_SUCCESS; - } - } - - return EFI_NOT_FOUND; -} - -/** - Creates and returns a notification event and registers that event with all the protocol - instances specified by ProtocolGuid. - - This function causes the notification function to be executed for every protocol of type - ProtocolGuid instance that exists in the system when this function is invoked. If there are - no instances of ProtocolGuid in the handle database at the time this function is invoked, - then the notification function is still executed one time. In addition, every time a protocol - of type ProtocolGuid instance is installed or reinstalled, the notification function is also - executed. This function returns the notification event that was created. - If ProtocolGuid is NULL, then ASSERT(). - If NotifyTpl is not a legal TPL value, then ASSERT(). - If NotifyFunction is NULL, then ASSERT(). - If Registration is NULL, then ASSERT(). - - - @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired. - @param NotifyTpl Supplies the task priority level of the event notifications. - @param NotifyFunction Supplies the function to notify when the event is signaled. - @param NotifyContext The context parameter to pass to NotifyFunction. - @param Registration A pointer to a memory location to receive the registration value. - This value is passed to LocateHandle() to obtain new handles that - have been added that support the ProtocolGuid-specified protocol. - - @return The notification event that was created. - -**/ -EFI_EVENT -EFIAPI -EfiCreateProtocolNotifyEvent( - IN EFI_GUID *ProtocolGuid, - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, - IN VOID *NotifyContext, OPTIONAL - OUT VOID **Registration - ) -{ - EFI_STATUS Status; - EFI_EVENT Event; - - ASSERT (ProtocolGuid != NULL); - ASSERT (NotifyFunction != NULL); - ASSERT (Registration != NULL); - - // - // Create the event - // - - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL, - NotifyTpl, - NotifyFunction, - NotifyContext, - &Event - ); - ASSERT_EFI_ERROR (Status); - - // - // Register for protocol notifications on this event - // - - Status = gBS->RegisterProtocolNotify ( - ProtocolGuid, - Event, - Registration - ); - - ASSERT_EFI_ERROR (Status); - - // - // Kick the event so we will perform an initial pass of - // current installed drivers - // - - gBS->SignalEvent (Event); - return Event; -} - -/** - Creates a named event that can be signaled with EfiNamedEventSignal(). - - This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext. - This event is signaled with EfiNamedEventSignal(). This provides the ability for one or more - listeners on the same event named by the GUID specified by Name. - If Name is NULL, then ASSERT(). - If NotifyTpl is not a legal TPL value, then ASSERT(). - If NotifyFunction is NULL, then ASSERT(). - - @param Name Supplies GUID name of the event. - @param NotifyTpl Supplies the task priority level of the event notifications. - @param NotifyFunction Supplies the function to notify when the event is signaled. - @param NotifyContext The context parameter to pass to NotifyFunction. - @param Registration A pointer to a memory location to receive the registration value. - - @retval EFI_SUCCESS A named event was created. - @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event. - -**/ -EFI_STATUS -EFIAPI -EfiNamedEventListen ( - IN CONST EFI_GUID *Name, - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, - IN CONST VOID *NotifyContext, OPTIONAL - OUT VOID *Registration OPTIONAL - ) -{ - EFI_STATUS Status; - EFI_EVENT Event; - VOID *RegistrationLocal; - - ASSERT (Name != NULL); - ASSERT (NotifyFunction != NULL); - ASSERT (NotifyTpl <= TPL_HIGH_LEVEL); - - // - // Create event - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL, - NotifyTpl, - NotifyFunction, - (VOID *) NotifyContext, - &Event - ); - ASSERT_EFI_ERROR (Status); - - // - // The Registration is not optional to RegisterProtocolNotify(). - // To make it optional to EfiNamedEventListen(), may need to substitute with a local. - // - if (Registration != NULL) { - RegistrationLocal = Registration; - } else { - RegistrationLocal = &RegistrationLocal; - } - - // - // Register for an installation of protocol interface - // - - Status = gBS->RegisterProtocolNotify ( - (EFI_GUID *) Name, - Event, - RegistrationLocal - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} - -/** - Signals a named event created with EfiNamedEventListen(). - - This function signals the named event specified by Name. The named event must have been - created with EfiNamedEventListen(). - If Name is NULL, then ASSERT(). - - @param Name Supplies GUID name of the event. - - @retval EFI_SUCCESS A named event was signaled. - @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event. - -**/ -EFI_STATUS -EFIAPI -EfiNamedEventSignal ( - IN CONST EFI_GUID *Name - ) -{ - EFI_STATUS Status; - EFI_HANDLE Handle; - - ASSERT(Name != NULL); - - Handle = NULL; - Status = gBS->InstallProtocolInterface ( - &Handle, - (EFI_GUID *) Name, - EFI_NATIVE_INTERFACE, - NULL - ); - ASSERT_EFI_ERROR (Status); - - Status = gBS->UninstallProtocolInterface ( - Handle, - (EFI_GUID *) Name, - NULL - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} - -/** - Signals an event group by placing a new event in the group temporarily and - signaling it. - - @param[in] EventGroup Supplies the unique identifier of the event - group to signal. - - @retval EFI_SUCCESS The event group was signaled successfully. - @retval EFI_INVALID_PARAMETER EventGroup is NULL. - @return Error codes that report problems about event - creation or signaling. -**/ -EFI_STATUS -EFIAPI -EfiEventGroupSignal ( - IN CONST EFI_GUID *EventGroup - ) -{ - EFI_STATUS Status; - EFI_EVENT Event; - - if (EventGroup == NULL) { - return EFI_INVALID_PARAMETER; - } - - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - EfiEventEmptyFunction, - NULL, - EventGroup, - &Event - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = gBS->SignalEvent (Event); - gBS->CloseEvent (Event); - - return Status; -} - -/** - An empty function that can be used as NotifyFunction parameter of - CreateEvent() or CreateEventEx(). - - @param Event Event whose notification function is being invoked. - @param Context The pointer to the notification function's context, - which is implementation-dependent. - -**/ -VOID -EFIAPI -EfiEventEmptyFunction ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ -} - -/** - Returns the current TPL. - - This function returns the current TPL. There is no EFI service to directly - retrieve the current TPL. Instead, the RaiseTPL() function is used to raise - the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level - can then immediately be restored back to the current TPL level with a call - to RestoreTPL(). - - @return The current TPL. - -**/ -EFI_TPL -EFIAPI -EfiGetCurrentTpl ( - VOID - ) -{ - EFI_TPL Tpl; - - Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); - gBS->RestoreTPL (Tpl); - - return Tpl; -} - - -/** - Initializes a basic mutual exclusion lock. - - This function initializes a basic mutual exclusion lock to the released state - and returns the lock. Each lock provides mutual exclusion access at its task - priority level. Since there is no preemption or multiprocessor support in EFI, - acquiring the lock only consists of raising to the locks TPL. - If Lock is NULL, then ASSERT(). - If Priority is not a valid TPL value, then ASSERT(). - - @param Lock A pointer to the lock data structure to initialize. - @param Priority EFI TPL associated with the lock. - - @return The lock. - -**/ -EFI_LOCK * -EFIAPI -EfiInitializeLock ( - IN OUT EFI_LOCK *Lock, - IN EFI_TPL Priority - ) -{ - ASSERT (Lock != NULL); - ASSERT (Priority <= TPL_HIGH_LEVEL); - - Lock->Tpl = Priority; - Lock->OwnerTpl = TPL_APPLICATION; - Lock->Lock = EfiLockReleased ; - return Lock; -} - -/** - Acquires ownership of a lock. - - This function raises the system's current task priority level to the task - priority level of the mutual exclusion lock. Then, it places the lock in the - acquired state. - If Lock is NULL, then ASSERT(). - If Lock is not initialized, then ASSERT(). - If Lock is already in the acquired state, then ASSERT(). - - @param Lock A pointer to the lock to acquire. - -**/ -VOID -EFIAPI -EfiAcquireLock ( - IN EFI_LOCK *Lock - ) -{ - ASSERT (Lock != NULL); - ASSERT (Lock->Lock == EfiLockReleased); - - Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); - Lock->Lock = EfiLockAcquired; -} - -/** - Acquires ownership of a lock. - - This function raises the system's current task priority level to the task priority - level of the mutual exclusion lock. Then, it attempts to place the lock in the acquired state. - If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned. - Otherwise, EFI_SUCCESS is returned. - If Lock is NULL, then ASSERT(). - If Lock is not initialized, then ASSERT(). - - @param Lock A pointer to the lock to acquire. - - @retval EFI_SUCCESS The lock was acquired. - @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned. - -**/ -EFI_STATUS -EFIAPI -EfiAcquireLockOrFail ( - IN EFI_LOCK *Lock - ) -{ - - ASSERT (Lock != NULL); - ASSERT (Lock->Lock != EfiLockUninitialized); - - if (Lock->Lock == EfiLockAcquired) { - // - // Lock is already owned, so bail out - // - return EFI_ACCESS_DENIED; - } - - Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); - - Lock->Lock = EfiLockAcquired; - - return EFI_SUCCESS; -} - -/** - Releases ownership of a lock. - - This function transitions a mutual exclusion lock from the acquired state to - the released state, and restores the system's task priority level to its - previous level. - If Lock is NULL, then ASSERT(). - If Lock is not initialized, then ASSERT(). - If Lock is already in the released state, then ASSERT(). - - @param Lock A pointer to the lock to release. - -**/ -VOID -EFIAPI -EfiReleaseLock ( - IN EFI_LOCK *Lock - ) -{ - EFI_TPL Tpl; - - ASSERT (Lock != NULL); - ASSERT (Lock->Lock == EfiLockAcquired); - - Tpl = Lock->OwnerTpl; - - Lock->Lock = EfiLockReleased; - - gBS->RestoreTPL (Tpl); -} - -/** - Tests whether a controller handle is being managed by a specific driver. - - This function tests whether the driver specified by DriverBindingHandle is - currently managing the controller specified by ControllerHandle. This test - is performed by evaluating if the the protocol specified by ProtocolGuid is - present on ControllerHandle and is was opened by DriverBindingHandle with an - attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. - If ProtocolGuid is NULL, then ASSERT(). - - @param ControllerHandle A handle for a controller to test. - @param DriverBindingHandle Specifies the driver binding handle for the - driver. - @param ProtocolGuid Specifies the protocol that the driver specified - by DriverBindingHandle opens in its Start() - function. - - @retval EFI_SUCCESS ControllerHandle is managed by the driver - specified by DriverBindingHandle. - @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver - specified by DriverBindingHandle. - -**/ -EFI_STATUS -EFIAPI -EfiTestManagedDevice ( - IN CONST EFI_HANDLE ControllerHandle, - IN CONST EFI_HANDLE DriverBindingHandle, - IN CONST EFI_GUID *ProtocolGuid - ) -{ - EFI_STATUS Status; - VOID *ManagedInterface; - - ASSERT (ProtocolGuid != NULL); - - Status = gBS->OpenProtocol ( - ControllerHandle, - (EFI_GUID *) ProtocolGuid, - &ManagedInterface, - DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (!EFI_ERROR (Status)) { - gBS->CloseProtocol ( - ControllerHandle, - (EFI_GUID *) ProtocolGuid, - DriverBindingHandle, - ControllerHandle - ); - return EFI_UNSUPPORTED; - } - - if (Status != EFI_ALREADY_STARTED) { - return EFI_UNSUPPORTED; - } - - return EFI_SUCCESS; -} - -/** - Tests whether a child handle is a child device of the controller. - - This function tests whether ChildHandle is one of the children of - ControllerHandle. This test is performed by checking to see if the protocol - specified by ProtocolGuid is present on ControllerHandle and opened by - ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. - If ProtocolGuid is NULL, then ASSERT(). - - @param ControllerHandle A handle for a (parent) controller to test. - @param ChildHandle A child handle to test. - @param ProtocolGuid Supplies the protocol that the child controller - opens on its parent controller. - - @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle. - @retval EFI_UNSUPPORTED ChildHandle is not a child of the - ControllerHandle. - -**/ -EFI_STATUS -EFIAPI -EfiTestChildHandle ( - IN CONST EFI_HANDLE ControllerHandle, - IN CONST EFI_HANDLE ChildHandle, - IN CONST EFI_GUID *ProtocolGuid - ) -{ - EFI_STATUS Status; - EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer; - UINTN EntryCount; - UINTN Index; - - ASSERT (ProtocolGuid != NULL); - - // - // Retrieve the list of agents that are consuming the specific protocol - // on ControllerHandle. - // - Status = gBS->OpenProtocolInformation ( - ControllerHandle, - (EFI_GUID *) ProtocolGuid, - &OpenInfoBuffer, - &EntryCount - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - // - // Inspect if ChildHandle is one of the agents. - // - Status = EFI_UNSUPPORTED; - for (Index = 0; Index < EntryCount; Index++) { - if ((OpenInfoBuffer[Index].ControllerHandle == ChildHandle) && - (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { - Status = EFI_SUCCESS; - break; - } - } - - FreePool (OpenInfoBuffer); - return Status; -} - -/** - This function looks up a Unicode string in UnicodeStringTable. - - If Language is a member of SupportedLanguages and a Unicode string is found in - UnicodeStringTable that matches the language code specified by Language, then it - is returned in UnicodeString. - - @param Language A pointer to the ISO 639-2 language code for the - Unicode string to look up and return. - @param SupportedLanguages A pointer to the set of ISO 639-2 language codes - that the Unicode string table supports. Language - must be a member of this set. - @param UnicodeStringTable A pointer to the table of Unicode strings. - @param UnicodeString A pointer to the Unicode string from UnicodeStringTable - that matches the language specified by Language. - - @retval EFI_SUCCESS The Unicode string that matches the language - specified by Language was found - in the table of Unicode strings UnicodeStringTable, - and it was returned in UnicodeString. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER UnicodeString is NULL. - @retval EFI_UNSUPPORTED SupportedLanguages is NULL. - @retval EFI_UNSUPPORTED UnicodeStringTable is NULL. - @retval EFI_UNSUPPORTED The language specified by Language is not a - member of SupportedLanguages. - @retval EFI_UNSUPPORTED The language specified by Language is not - supported by UnicodeStringTable. - -**/ -EFI_STATUS -EFIAPI -LookupUnicodeString ( - IN CONST CHAR8 *Language, - IN CONST CHAR8 *SupportedLanguages, - IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, - OUT CHAR16 **UnicodeString - ) -{ - // - // Make sure the parameters are valid - // - if (Language == NULL || UnicodeString == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // If there are no supported languages, or the Unicode String Table is empty, then the - // Unicode String specified by Language is not supported by this Unicode String Table - // - if (SupportedLanguages == NULL || UnicodeStringTable == NULL) { - return EFI_UNSUPPORTED; - } - - // - // Make sure Language is in the set of Supported Languages - // - while (*SupportedLanguages != 0) { - if (CompareIso639LanguageCode (Language, SupportedLanguages)) { - - // - // Search the Unicode String Table for the matching Language specifier - // - while (UnicodeStringTable->Language != NULL) { - if (CompareIso639LanguageCode (Language, UnicodeStringTable->Language)) { - - // - // A matching string was found, so return it - // - *UnicodeString = UnicodeStringTable->UnicodeString; - return EFI_SUCCESS; - } - - UnicodeStringTable++; - } - - return EFI_UNSUPPORTED; - } - - SupportedLanguages += 3; - } - - return EFI_UNSUPPORTED; -} - - - -/** - This function looks up a Unicode string in UnicodeStringTable. - - If Language is a member of SupportedLanguages and a Unicode string is found in - UnicodeStringTable that matches the language code specified by Language, then - it is returned in UnicodeString. - - @param Language A pointer to an ASCII string containing the ISO 639-2 or the - RFC 4646 language code for the Unicode string to look up and - return. If Iso639Language is TRUE, then this ASCII string is - not assumed to be Null-terminated, and only the first three - characters are used. If Iso639Language is FALSE, then this ASCII - string must be Null-terminated. - @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains a - set of ISO 639-2 or RFC 4646 language codes that the Unicode - string table supports. Language must be a member of this set. - If Iso639Language is TRUE, then this string contains one or more - ISO 639-2 language codes with no separator characters. If Iso639Language - is FALSE, then is string contains one or more RFC 4646 language - codes separated by ';'. - @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE - is defined in "Related Definitions". - @param UnicodeString A pointer to the Null-terminated Unicode string from UnicodeStringTable - that matches the language specified by Language. - @param Iso639Language Specifies the supported language code format. If it is TRUE, then - Language and SupportedLanguages follow ISO 639-2 language code format. - Otherwise, they follow RFC 4646 language code format. - - - @retval EFI_SUCCESS The Unicode string that matches the language specified by Language - was found in the table of Unicode strings UnicodeStringTable, and - it was returned in UnicodeString. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER UnicodeString is NULL. - @retval EFI_UNSUPPORTED SupportedLanguages is NULL. - @retval EFI_UNSUPPORTED UnicodeStringTable is NULL. - @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages. - @retval EFI_UNSUPPORTED The language specified by Language is not supported by UnicodeStringTable. - -**/ -EFI_STATUS -EFIAPI -LookupUnicodeString2 ( - IN CONST CHAR8 *Language, - IN CONST CHAR8 *SupportedLanguages, - IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, - OUT CHAR16 **UnicodeString, - IN BOOLEAN Iso639Language - ) -{ - BOOLEAN Found; - UINTN Index; - CHAR8 *LanguageString; - - // - // Make sure the parameters are valid - // - if (Language == NULL || UnicodeString == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // If there are no supported languages, or the Unicode String Table is empty, then the - // Unicode String specified by Language is not supported by this Unicode String Table - // - if (SupportedLanguages == NULL || UnicodeStringTable == NULL) { - return EFI_UNSUPPORTED; - } - - // - // Make sure Language is in the set of Supported Languages - // - Found = FALSE; - while (*SupportedLanguages != 0) { - if (Iso639Language) { - if (CompareIso639LanguageCode (Language, SupportedLanguages)) { - Found = TRUE; - break; - } - SupportedLanguages += 3; - } else { - for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++); - if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) { - Found = TRUE; - break; - } - SupportedLanguages += Index; - for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++); - } - } - - // - // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED - // - if (!Found) { - return EFI_UNSUPPORTED; - } - - // - // Search the Unicode String Table for the matching Language specifier - // - while (UnicodeStringTable->Language != NULL) { - LanguageString = UnicodeStringTable->Language; - while (0 != *LanguageString) { - for (Index = 0 ;LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++); - if (AsciiStrnCmp(LanguageString, Language, Index) == 0) { - *UnicodeString = UnicodeStringTable->UnicodeString; - return EFI_SUCCESS; - } - LanguageString += Index; - for (Index = 0 ;LanguageString[Index] != 0 && LanguageString[Index] == ';'; Index++); - } - UnicodeStringTable++; - } - - return EFI_UNSUPPORTED; -} - - -/** - This function adds a Unicode string to UnicodeStringTable. - - If Language is a member of SupportedLanguages then UnicodeString is added to - UnicodeStringTable. New buffers are allocated for both Language and - UnicodeString. The contents of Language and UnicodeString are copied into - these new buffers. These buffers are automatically freed when - FreeUnicodeStringTable() is called. - - @param Language A pointer to the ISO 639-2 language code for the Unicode - string to add. - @param SupportedLanguages A pointer to the set of ISO 639-2 language codes - that the Unicode string table supports. - Language must be a member of this set. - @param UnicodeStringTable A pointer to the table of Unicode strings. - @param UnicodeString A pointer to the Unicode string to add. - - @retval EFI_SUCCESS The Unicode string that matches the language - specified by Language was found in the table of - Unicode strings UnicodeStringTable, and it was - returned in UnicodeString. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER UnicodeString is NULL. - @retval EFI_INVALID_PARAMETER UnicodeString is an empty string. - @retval EFI_UNSUPPORTED SupportedLanguages is NULL. - @retval EFI_ALREADY_STARTED A Unicode string with language Language is - already present in UnicodeStringTable. - @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another - Unicode string to UnicodeStringTable. - @retval EFI_UNSUPPORTED The language specified by Language is not a - member of SupportedLanguages. - -**/ -EFI_STATUS -EFIAPI -AddUnicodeString ( - IN CONST CHAR8 *Language, - IN CONST CHAR8 *SupportedLanguages, - IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, - IN CONST CHAR16 *UnicodeString - ) -{ - UINTN NumberOfEntries; - EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable; - EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable; - UINTN UnicodeStringLength; - - // - // Make sure the parameter are valid - // - if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // If there are no supported languages, then a Unicode String can not be added - // - if (SupportedLanguages == NULL) { - return EFI_UNSUPPORTED; - } - - // - // If the Unicode String is empty, then a Unicode String can not be added - // - if (UnicodeString[0] == 0) { - return EFI_INVALID_PARAMETER; - } - - // - // Make sure Language is a member of SupportedLanguages - // - while (*SupportedLanguages != 0) { - if (CompareIso639LanguageCode (Language, SupportedLanguages)) { - - // - // Determine the size of the Unicode String Table by looking for a NULL Language entry - // - NumberOfEntries = 0; - if (*UnicodeStringTable != NULL) { - OldUnicodeStringTable = *UnicodeStringTable; - while (OldUnicodeStringTable->Language != NULL) { - if (CompareIso639LanguageCode (Language, OldUnicodeStringTable->Language)) { - return EFI_ALREADY_STARTED; - } - - OldUnicodeStringTable++; - NumberOfEntries++; - } - } - - // - // Allocate space for a new Unicode String Table. It must hold the current number of - // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table - // marker - // - NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE)); - if (NewUnicodeStringTable == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // If the current Unicode String Table contains any entries, then copy them to the - // newly allocated Unicode String Table. - // - if (*UnicodeStringTable != NULL) { - CopyMem ( - NewUnicodeStringTable, - *UnicodeStringTable, - NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE) - ); - } - - // - // Allocate space for a copy of the Language specifier - // - NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (3, Language); - if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) { - gBS->FreePool (NewUnicodeStringTable); - return EFI_OUT_OF_RESOURCES; - } - - // - // Compute the length of the Unicode String - // - for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++) - ; - - // - // Allocate space for a copy of the Unicode String - // - NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool ( - (UnicodeStringLength + 1) * sizeof (CHAR16), - UnicodeString - ); - if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) { - gBS->FreePool (NewUnicodeStringTable[NumberOfEntries].Language); - gBS->FreePool (NewUnicodeStringTable); - return EFI_OUT_OF_RESOURCES; - } - - // - // Mark the end of the Unicode String Table - // - NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL; - NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL; - - // - // Free the old Unicode String Table - // - if (*UnicodeStringTable != NULL) { - gBS->FreePool (*UnicodeStringTable); - } - - // - // Point UnicodeStringTable at the newly allocated Unicode String Table - // - *UnicodeStringTable = NewUnicodeStringTable; - - return EFI_SUCCESS; - } - - SupportedLanguages += 3; - } - - return EFI_UNSUPPORTED; -} - - -/** - This function adds the Null-terminated Unicode string specified by UnicodeString - to UnicodeStringTable. - - If Language is a member of SupportedLanguages then UnicodeString is added to - UnicodeStringTable. New buffers are allocated for both Language and UnicodeString. - The contents of Language and UnicodeString are copied into these new buffers. - These buffers are automatically freed when EfiLibFreeUnicodeStringTable() is called. - - @param Language A pointer to an ASCII string containing the ISO 639-2 or - the RFC 4646 language code for the Unicode string to add. - If Iso639Language is TRUE, then this ASCII string is not - assumed to be Null-terminated, and only the first three - chacters are used. If Iso639Language is FALSE, then this - ASCII string must be Null-terminated. - @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains - a set of ISO 639-2 or RFC 4646 language codes that the Unicode - string table supports. Language must be a member of this set. - If Iso639Language is TRUE, then this string contains one or more - ISO 639-2 language codes with no separator characters. - If Iso639Language is FALSE, then is string contains one or more - RFC 4646 language codes separated by ';'. - @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE - is defined in "Related Definitions". - @param UnicodeString A pointer to the Unicode string to add. - @param Iso639Language Specifies the supported language code format. If it is TRUE, - then Language and SupportedLanguages follow ISO 639-2 language code format. - Otherwise, they follow RFC 4646 language code format. - - @retval EFI_SUCCESS The Unicode string that matches the language specified by - Language was found in the table of Unicode strings UnicodeStringTable, - and it was returned in UnicodeString. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER UnicodeString is NULL. - @retval EFI_INVALID_PARAMETER UnicodeString is an empty string. - @retval EFI_UNSUPPORTED SupportedLanguages is NULL. - @retval EFI_ALREADY_STARTED A Unicode string with language Language is already present in - UnicodeStringTable. - @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another Unicode string UnicodeStringTable. - @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages. - -**/ -EFI_STATUS -EFIAPI -AddUnicodeString2 ( - IN CONST CHAR8 *Language, - IN CONST CHAR8 *SupportedLanguages, - IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, - IN CONST CHAR16 *UnicodeString, - IN BOOLEAN Iso639Language - ) -{ - UINTN NumberOfEntries; - EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable; - EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable; - UINTN UnicodeStringLength; - BOOLEAN Found; - UINTN Index; - CHAR8 *LanguageString; - - // - // Make sure the parameter are valid - // - if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // If there are no supported languages, then a Unicode String can not be added - // - if (SupportedLanguages == NULL) { - return EFI_UNSUPPORTED; - } - - // - // If the Unicode String is empty, then a Unicode String can not be added - // - if (UnicodeString[0] == 0) { - return EFI_INVALID_PARAMETER; - } - - // - // Make sure Language is a member of SupportedLanguages - // - Found = FALSE; - while (*SupportedLanguages != 0) { - if (Iso639Language) { - if (CompareIso639LanguageCode (Language, SupportedLanguages)) { - Found = TRUE; - break; - } - SupportedLanguages += 3; - } else { - for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++); - if (AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) { - Found = TRUE; - break; - } - SupportedLanguages += Index; - for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++); - } - } - - // - // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED - // - if (!Found) { - return EFI_UNSUPPORTED; - } - - // - // Determine the size of the Unicode String Table by looking for a NULL Language entry - // - NumberOfEntries = 0; - if (*UnicodeStringTable != NULL) { - OldUnicodeStringTable = *UnicodeStringTable; - while (OldUnicodeStringTable->Language != NULL) { - LanguageString = OldUnicodeStringTable->Language; - - while (*LanguageString != 0) { - for (Index = 0; LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++); - - if (AsciiStrnCmp (Language, LanguageString, Index) == 0) { - return EFI_ALREADY_STARTED; - } - LanguageString += Index; - for (; *LanguageString != 0 && *LanguageString == ';'; LanguageString++); - } - OldUnicodeStringTable++; - NumberOfEntries++; - } - } - - // - // Allocate space for a new Unicode String Table. It must hold the current number of - // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table - // marker - // - NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE)); - if (NewUnicodeStringTable == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // If the current Unicode String Table contains any entries, then copy them to the - // newly allocated Unicode String Table. - // - if (*UnicodeStringTable != NULL) { - CopyMem ( - NewUnicodeStringTable, - *UnicodeStringTable, - NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE) - ); - } - - // - // Allocate space for a copy of the Language specifier - // - NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (AsciiStrSize(Language), Language); - if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) { - gBS->FreePool (NewUnicodeStringTable); - return EFI_OUT_OF_RESOURCES; - } - - // - // Compute the length of the Unicode String - // - for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++); - - // - // Allocate space for a copy of the Unicode String - // - NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool (StrSize (UnicodeString), UnicodeString); - if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) { - gBS->FreePool (NewUnicodeStringTable[NumberOfEntries].Language); - gBS->FreePool (NewUnicodeStringTable); - return EFI_OUT_OF_RESOURCES; - } - - // - // Mark the end of the Unicode String Table - // - NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL; - NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL; - - // - // Free the old Unicode String Table - // - if (*UnicodeStringTable != NULL) { - gBS->FreePool (*UnicodeStringTable); - } - - // - // Point UnicodeStringTable at the newly allocated Unicode String Table - // - *UnicodeStringTable = NewUnicodeStringTable; - - return EFI_SUCCESS; -} - -/** - This function frees the table of Unicode strings in UnicodeStringTable. - - If UnicodeStringTable is NULL, then EFI_SUCCESS is returned. - Otherwise, each language code, and each Unicode string in the Unicode string - table are freed, and EFI_SUCCESS is returned. - - @param UnicodeStringTable A pointer to the table of Unicode strings. - - @retval EFI_SUCCESS The Unicode string table was freed. - -**/ -EFI_STATUS -EFIAPI -FreeUnicodeStringTable ( - IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable - ) -{ - UINTN Index; - - // - // If the Unicode String Table is NULL, then it is already freed - // - if (UnicodeStringTable == NULL) { - return EFI_SUCCESS; - } - - // - // Loop through the Unicode String Table until we reach the end of table marker - // - for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) { - - // - // Free the Language string from the Unicode String Table - // - gBS->FreePool (UnicodeStringTable[Index].Language); - - // - // Free the Unicode String from the Unicode String Table - // - if (UnicodeStringTable[Index].UnicodeString != NULL) { - gBS->FreePool (UnicodeStringTable[Index].UnicodeString); - } - } - - // - // Free the Unicode String Table itself - // - gBS->FreePool (UnicodeStringTable); - - return EFI_SUCCESS; -} - -/** - Returns a pointer to an allocated buffer that contains the contents of a - variable retrieved through the UEFI Runtime Service GetVariable(). The - returned buffer is allocated using AllocatePool(). The caller is responsible - for freeing this buffer with FreePool(). - - If Name is NULL, then ASSERT(). - If Guid is NULL, then ASSERT(). - - @param[in] Name Pointer to a Null-terminated Unicode string. - @param[in] Guid Pointer to an EFI_GUID structure - - @retval NULL The variable could not be retrieved. - @retval NULL There are not enough resources available for the variable contents. - @retval Other A pointer to allocated buffer containing the variable contents. - -**/ -VOID * -EFIAPI -GetVariable ( - IN CONST CHAR16 *Name, - IN CONST EFI_GUID *Guid - ) -{ - EFI_STATUS Status; - UINTN Size; - VOID *Value; - - ASSERT (Name != NULL); - ASSERT (Guid != NULL); - - // - // Try to get the variable size. - // - Value = NULL; - Size = 0; - Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &Size, Value); - if (Status != EFI_BUFFER_TOO_SMALL) { - return NULL; - } - - // - // Allocate buffer to get the variable. - // - Value = AllocatePool (Size); - if (Value == NULL) { - return NULL; - } - - // - // Get the variable data. - // - Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &Size, Value); - if (EFI_ERROR (Status)) { - FreePool(Value); - return NULL; - } - - return Value; -} - - -/** - Returns a pointer to an allocated buffer that contains the contents of a - variable retrieved through the UEFI Runtime Service GetVariable(). This - function always uses the EFI_GLOBAL_VARIABLE GUID to retrieve variables. - The returned buffer is allocated using AllocatePool(). The caller is - responsible for freeing this buffer with FreePool(). - - If Name is NULL, then ASSERT(). - - @param[in] Name Pointer to a Null-terminated Unicode string. - - @retval NULL The variable could not be retrieved. - @retval NULL There are not enough resources available for the variable contents. - @retval Other A pointer to allocated buffer containing the variable contents. - -**/ -VOID * -EFIAPI -GetEfiGlobalVariable ( - IN CONST CHAR16 *Name - ) -{ - return GetVariable (Name, &gEfiGlobalVariableGuid); -} - -/** - Returns the status whether get the variable success. The function retrieves - variable through the UEFI Runtime Service GetVariable(). The - returned buffer is allocated using AllocatePool(). The caller is responsible - for freeing this buffer with FreePool(). - - If Name is NULL, then ASSERT(). - If Guid is NULL, then ASSERT(). - If Value is NULL, then ASSERT(). - - @param[in] Name The pointer to a Null-terminated Unicode string. - @param[in] Guid The pointer to an EFI_GUID structure - @param[out] Value The buffer point saved the variable info. - @param[out] Size The buffer size of the variable. - - @return EFI_OUT_OF_RESOURCES Allocate buffer failed. - @return EFI_SUCCESS Find the specified variable. - @return Others Errors Return errors from call to gRT->GetVariable. - -**/ -EFI_STATUS -EFIAPI -GetVariable2 ( - IN CONST CHAR16 *Name, - IN CONST EFI_GUID *Guid, - OUT VOID **Value, - OUT UINTN *Size OPTIONAL - ) -{ - EFI_STATUS Status; - UINTN BufferSize; - - ASSERT (Name != NULL && Guid != NULL && Value != NULL); - - // - // Try to get the variable size. - // - BufferSize = 0; - *Value = NULL; - if (Size != NULL) { - *Size = 0; - } - - Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &BufferSize, *Value); - if (Status != EFI_BUFFER_TOO_SMALL) { - return Status; - } - - // - // Allocate buffer to get the variable. - // - *Value = AllocatePool (BufferSize); - ASSERT (*Value != NULL); - if (*Value == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Get the variable data. - // - Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &BufferSize, *Value); - if (EFI_ERROR (Status)) { - FreePool(*Value); - *Value = NULL; - } - - if (Size != NULL) { - *Size = BufferSize; - } - - return Status; -} - -/** - Returns a pointer to an allocated buffer that contains the contents of a - variable retrieved through the UEFI Runtime Service GetVariable(). This - function always uses the EFI_GLOBAL_VARIABLE GUID to retrieve variables. - The returned buffer is allocated using AllocatePool(). The caller is - responsible for freeing this buffer with FreePool(). - - If Name is NULL, then ASSERT(). - If Value is NULL, then ASSERT(). - - @param[in] Name The pointer to a Null-terminated Unicode string. - @param[out] Value The buffer point saved the variable info. - @param[out] Size The buffer size of the variable. - - @return EFI_OUT_OF_RESOURCES Allocate buffer failed. - @return EFI_SUCCESS Find the specified variable. - @return Others Errors Return errors from call to gRT->GetVariable. - -**/ -EFI_STATUS -EFIAPI -GetEfiGlobalVariable2 ( - IN CONST CHAR16 *Name, - OUT VOID **Value, - OUT UINTN *Size OPTIONAL - ) -{ - return GetVariable2 (Name, &gEfiGlobalVariableGuid, Value, Size); -} - -/** - Returns a pointer to an allocated buffer that contains the best matching language - from a set of supported languages. - - This function supports both ISO 639-2 and RFC 4646 language codes, but language - code types may not be mixed in a single call to this function. The language - code returned is allocated using AllocatePool(). The caller is responsible for - freeing the allocated buffer using FreePool(). This function supports a variable - argument list that allows the caller to pass in a prioritized list of language - codes to test against all the language codes in SupportedLanguages. - - If SupportedLanguages is NULL, then ASSERT(). - - @param[in] SupportedLanguages A pointer to a Null-terminated ASCII string that - contains a set of language codes in the format - specified by Iso639Language. - @param[in] Iso639Language If not zero, then all language codes are assumed to be - in ISO 639-2 format. If zero, then all language - codes are assumed to be in RFC 4646 language format - @param[in] ... A variable argument list that contains pointers to - Null-terminated ASCII strings that contain one or more - language codes in the format specified by Iso639Language. - The first language code from each of these language - code lists is used to determine if it is an exact or - close match to any of the language codes in - SupportedLanguages. Close matches only apply to RFC 4646 - language codes, and the matching algorithm from RFC 4647 - is used to determine if a close match is present. If - an exact or close match is found, then the matching - language code from SupportedLanguages is returned. If - no matches are found, then the next variable argument - parameter is evaluated. The variable argument list - is terminated by a NULL. - - @retval NULL The best matching language could not be found in SupportedLanguages. - @retval NULL There are not enough resources available to return the best matching - language. - @retval Other A pointer to a Null-terminated ASCII string that is the best matching - language in SupportedLanguages. - -**/ -CHAR8 * -EFIAPI -GetBestLanguage ( - IN CONST CHAR8 *SupportedLanguages, - IN UINTN Iso639Language, - ... - ) -{ - VA_LIST Args; - CHAR8 *Language; - UINTN CompareLength; - UINTN LanguageLength; - CONST CHAR8 *Supported; - CHAR8 *BestLanguage; - - ASSERT (SupportedLanguages != NULL); - - VA_START (Args, Iso639Language); - while ((Language = VA_ARG (Args, CHAR8 *)) != NULL) { - // - // Default to ISO 639-2 mode - // - CompareLength = 3; - LanguageLength = MIN (3, AsciiStrLen (Language)); - - // - // If in RFC 4646 mode, then determine the length of the first RFC 4646 language code in Language - // - if (Iso639Language == 0) { - for (LanguageLength = 0; Language[LanguageLength] != 0 && Language[LanguageLength] != ';'; LanguageLength++); - } - - // - // Trim back the length of Language used until it is empty - // - while (LanguageLength > 0) { - // - // Loop through all language codes in SupportedLanguages - // - for (Supported = SupportedLanguages; *Supported != '\0'; Supported += CompareLength) { - // - // In RFC 4646 mode, then Loop through all language codes in SupportedLanguages - // - if (Iso639Language == 0) { - // - // Skip ';' characters in Supported - // - for (; *Supported != '\0' && *Supported == ';'; Supported++); - // - // Determine the length of the next language code in Supported - // - for (CompareLength = 0; Supported[CompareLength] != 0 && Supported[CompareLength] != ';'; CompareLength++); - // - // If Language is longer than the Supported, then skip to the next language - // - if (LanguageLength > CompareLength) { - continue; - } - } - // - // See if the first LanguageLength characters in Supported match Language - // - if (AsciiStrnCmp (Supported, Language, LanguageLength) == 0) { - VA_END (Args); - // - // Allocate, copy, and return the best matching language code from SupportedLanguages - // - BestLanguage = AllocateZeroPool (CompareLength + 1); - if (BestLanguage == NULL) { - return NULL; - } - return CopyMem (BestLanguage, Supported, CompareLength); - } - } - - if (Iso639Language != 0) { - // - // If ISO 639 mode, then each language can only be tested once - // - LanguageLength = 0; - } else { - // - // If RFC 4646 mode, then trim Language from the right to the next '-' character - // - for (LanguageLength--; LanguageLength > 0 && Language[LanguageLength] != '-'; LanguageLength--); - } - } - } - VA_END (Args); - - // - // No matches were found - // - return NULL; -} - -/** - Returns an array of protocol instance that matches the given protocol. - - @param[in] Protocol Provides the protocol to search for. - @param[out] NoProtocols The number of protocols returned in Buffer. - @param[out] Buffer A pointer to the buffer to return the requested - array of protocol instances that match Protocol. - The returned buffer is allocated using - EFI_BOOT_SERVICES.AllocatePool(). The caller is - responsible for freeing this buffer with - EFI_BOOT_SERVICES.FreePool(). - - @retval EFI_SUCCESS The array of protocols was returned in Buffer, - and the number of protocols in Buffer was - returned in NoProtocols. - @retval EFI_NOT_FOUND No protocols found. - @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the - matching results. - @retval EFI_INVALID_PARAMETER Protocol is NULL. - @retval EFI_INVALID_PARAMETER NoProtocols is NULL. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - -**/ -EFI_STATUS -EFIAPI -EfiLocateProtocolBuffer ( - IN EFI_GUID *Protocol, - OUT UINTN *NoProtocols, - OUT VOID ***Buffer - ) -{ - EFI_STATUS Status; - UINTN NoHandles; - EFI_HANDLE *HandleBuffer; - UINTN Index; - - // - // Check input parameters - // - if (Protocol == NULL || NoProtocols == NULL || Buffer == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Initialze output parameters - // - *NoProtocols = 0; - *Buffer = NULL; - - // - // Retrieve the array of handles that support Protocol - // - Status = gBS->LocateHandleBuffer ( - ByProtocol, - Protocol, - NULL, - &NoHandles, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Allocate array of protocol instances - // - Status = gBS->AllocatePool ( - EfiBootServicesData, - NoHandles * sizeof (VOID *), - (VOID **)Buffer - ); - if (EFI_ERROR (Status)) { - // - // Free the handle buffer - // - gBS->FreePool (HandleBuffer); - return EFI_OUT_OF_RESOURCES; - } - ZeroMem (*Buffer, NoHandles * sizeof (VOID *)); - - // - // Lookup Protocol on each handle in HandleBuffer to fill in the array of - // protocol instances. Handle case where protocol instance was present when - // LocateHandleBuffer() was called, but is not present when HandleProtocol() - // is called. - // - for (Index = 0, *NoProtocols = 0; Index < NoHandles; Index++) { - Status = gBS->HandleProtocol ( - HandleBuffer[Index], - Protocol, - &((*Buffer)[*NoProtocols]) - ); - if (!EFI_ERROR (Status)) { - (*NoProtocols)++; - } - } - - // - // Free the handle buffer - // - gBS->FreePool (HandleBuffer); - - // - // Make sure at least one protocol instance was found - // - if (*NoProtocols == 0) { - gBS->FreePool (*Buffer); - *Buffer = NULL; - return EFI_NOT_FOUND; - } - - return EFI_SUCCESS; -} - -/** - Open or create a file or directory, possibly creating the chain of - directories leading up to the directory. - - EfiOpenFileByDevicePath() first locates EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on - FilePath, and opens the root directory of that filesystem with - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume(). - - On the remaining device path, the longest initial sequence of - FILEPATH_DEVICE_PATH nodes is node-wise traversed with - EFI_FILE_PROTOCOL.Open(). - - (As a consequence, if OpenMode includes EFI_FILE_MODE_CREATE, and Attributes - includes EFI_FILE_DIRECTORY, and each FILEPATH_DEVICE_PATH specifies a single - pathname component, then EfiOpenFileByDevicePath() ensures that the specified - series of subdirectories exist on return.) - - The EFI_FILE_PROTOCOL identified by the last FILEPATH_DEVICE_PATH node is - output to the caller; intermediate EFI_FILE_PROTOCOL instances are closed. If - there are no FILEPATH_DEVICE_PATH nodes past the node that identifies the - filesystem, then the EFI_FILE_PROTOCOL of the root directory of the - filesystem is output to the caller. If a device path node that is different - from FILEPATH_DEVICE_PATH is encountered relative to the filesystem, the - traversal is stopped with an error, and a NULL EFI_FILE_PROTOCOL is output. - - @param[in,out] FilePath On input, the device path to the file or directory - to open or create. The caller is responsible for - ensuring that the device path pointed-to by FilePath - is well-formed. On output, FilePath points one past - the last node in the original device path that has - been successfully processed. FilePath is set on - output even if EfiOpenFileByDevicePath() returns an - error. - - @param[out] File On error, File is set to NULL. On success, File is - set to the EFI_FILE_PROTOCOL of the root directory - of the filesystem, if there are no - FILEPATH_DEVICE_PATH nodes in FilePath; otherwise, - File is set to the EFI_FILE_PROTOCOL identified by - the last node in FilePath. - - @param[in] OpenMode The OpenMode parameter to pass to - EFI_FILE_PROTOCOL.Open(). - - @param[in] Attributes The Attributes parameter to pass to - EFI_FILE_PROTOCOL.Open(). - - @retval EFI_SUCCESS The file or directory has been opened or - created. - - @retval EFI_INVALID_PARAMETER FilePath is NULL; or File is NULL; or FilePath - contains a device path node, past the node - that identifies - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, that is not a - FILEPATH_DEVICE_PATH node. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. - - @return Error codes propagated from the - LocateDevicePath() and OpenProtocol() boot - services, and from the - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume() - and EFI_FILE_PROTOCOL.Open() member functions. -**/ -EFI_STATUS -EFIAPI -EfiOpenFileByDevicePath ( - IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath, - OUT EFI_FILE_PROTOCOL **File, - IN UINT64 OpenMode, - IN UINT64 Attributes - ) -{ - EFI_STATUS Status; - EFI_HANDLE FileSystemHandle; - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem; - EFI_FILE_PROTOCOL *LastFile; - FILEPATH_DEVICE_PATH *FilePathNode; - CHAR16 *AlignedPathName; - CHAR16 *PathName; - EFI_FILE_PROTOCOL *NextFile; - - if (File == NULL) { - return EFI_INVALID_PARAMETER; - } - *File = NULL; - - if (FilePath == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Look up the filesystem. - // - Status = gBS->LocateDevicePath ( - &gEfiSimpleFileSystemProtocolGuid, - FilePath, - &FileSystemHandle - ); - if (EFI_ERROR (Status)) { - return Status; - } - Status = gBS->OpenProtocol ( - FileSystemHandle, - &gEfiSimpleFileSystemProtocolGuid, - (VOID **)&FileSystem, - gImageHandle, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Open the root directory of the filesystem. After this operation succeeds, - // we have to release LastFile on error. - // - Status = FileSystem->OpenVolume (FileSystem, &LastFile); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Traverse the device path nodes relative to the filesystem. - // - while (!IsDevicePathEnd (*FilePath)) { - if (DevicePathType (*FilePath) != MEDIA_DEVICE_PATH || - DevicePathSubType (*FilePath) != MEDIA_FILEPATH_DP) { - Status = EFI_INVALID_PARAMETER; - goto CloseLastFile; - } - FilePathNode = (FILEPATH_DEVICE_PATH *)*FilePath; - - // - // FilePathNode->PathName may be unaligned, and the UEFI specification - // requires pointers that are passed to protocol member functions to be - // aligned. Create an aligned copy of the pathname if necessary. - // - if ((UINTN)FilePathNode->PathName % sizeof *FilePathNode->PathName == 0) { - AlignedPathName = NULL; - PathName = FilePathNode->PathName; - } else { - AlignedPathName = AllocateCopyPool ( - (DevicePathNodeLength (FilePathNode) - - SIZE_OF_FILEPATH_DEVICE_PATH), - FilePathNode->PathName - ); - if (AlignedPathName == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto CloseLastFile; - } - PathName = AlignedPathName; - } - - // - // Open or create the file corresponding to the next pathname fragment. - // - Status = LastFile->Open ( - LastFile, - &NextFile, - PathName, - OpenMode, - Attributes - ); - - // - // Release any AlignedPathName on both error and success paths; PathName is - // no longer needed. - // - if (AlignedPathName != NULL) { - FreePool (AlignedPathName); - } - if (EFI_ERROR (Status)) { - goto CloseLastFile; - } - - // - // Advance to the next device path node. - // - LastFile->Close (LastFile); - LastFile = NextFile; - *FilePath = NextDevicePathNode (FilePathNode); - } - - *File = LastFile; - return EFI_SUCCESS; - -CloseLastFile: - LastFile->Close (LastFile); - - // - // We are on the error path; we must have set an error Status for returning - // to the caller. - // - ASSERT (EFI_ERROR (Status)); - return Status; -} diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h deleted file mode 100644 index 51f58176de..0000000000 --- a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h +++ /dev/null @@ -1,44 +0,0 @@ -/** @file - Internal include file for UefiLib. - - Copyright (c) 2007 - 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 - 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 __UEFI_LIB_INTERNAL_H_ -#define __UEFI_LIB_INTERNAL_H_ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibPrint.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibPrint.c deleted file mode 100644 index 28b0817557..0000000000 --- a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibPrint.c +++ /dev/null @@ -1,822 +0,0 @@ -/** @file - Mde UEFI library API implementation. - Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE - - Copyright (c) 2007 - 2018, 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 - 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 "UefiLibInternal.h" - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = { - { 0x00, 0x00, 0x00, 0x00 }, - { 0x98, 0x00, 0x00, 0x00 }, - { 0x00, 0x98, 0x00, 0x00 }, - { 0x98, 0x98, 0x00, 0x00 }, - { 0x00, 0x00, 0x98, 0x00 }, - { 0x98, 0x00, 0x98, 0x00 }, - { 0x00, 0x98, 0x98, 0x00 }, - { 0x98, 0x98, 0x98, 0x00 }, - { 0x10, 0x10, 0x10, 0x00 }, - { 0xff, 0x10, 0x10, 0x00 }, - { 0x10, 0xff, 0x10, 0x00 }, - { 0xff, 0xff, 0x10, 0x00 }, - { 0x10, 0x10, 0xff, 0x00 }, - { 0xf0, 0x10, 0xff, 0x00 }, - { 0x10, 0xff, 0xff, 0x00 }, - { 0xff, 0xff, 0xff, 0x00 } -}; - -/** - Internal function which prints a formatted Unicode string to the console output device - specified by Console - - This function prints a formatted Unicode string to the console output device - specified by Console and returns the number of Unicode characters that printed - to it. If the length of the formatted Unicode string is greater than PcdUefiLibMaxPrintBufferSize, - then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console. - If Format is NULL, then ASSERT(). - If Format is not aligned on a 16-bit boundary, then ASSERT(). - - @param Format Null-terminated Unicode format string. - @param Console The output console. - @param Marker VA_LIST marker for the variable argument list. - - @return The number of Unicode characters in the produced - output buffer not including the Null-terminator. -**/ -UINTN -InternalPrint ( - IN CONST CHAR16 *Format, - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console, - IN VA_LIST Marker - ) -{ - EFI_STATUS Status; - UINTN Return; - CHAR16 *Buffer; - UINTN BufferSize; - - ASSERT (Format != NULL); - ASSERT (((UINTN) Format & BIT0) == 0); - ASSERT (Console != NULL); - - BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16); - - Buffer = (CHAR16 *) AllocatePool(BufferSize); - ASSERT (Buffer != NULL); - - Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker); - - if (Console != NULL && Return > 0) { - // - // To be extra safe make sure Console has been initialized - // - Status = Console->OutputString (Console, Buffer); - if (EFI_ERROR (Status)) { - Return = 0; - } - } - - FreePool (Buffer); - - return Return; -} - -/** - Prints a formatted Unicode string to the console output device specified by - ConOut defined in the EFI_SYSTEM_TABLE. - - This function prints a formatted Unicode string to the console output device - specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode - characters that printed to ConOut. If the length of the formatted Unicode - string is greater than PcdUefiLibMaxPrintBufferSize, then only the first - PcdUefiLibMaxPrintBufferSize characters are sent to ConOut. - If Format is NULL, then ASSERT(). - If Format is not aligned on a 16-bit boundary, then ASSERT(). - If gST->ConOut is NULL, then ASSERT(). - - @param Format Null-terminated Unicode format string. - @param ... Variable argument list whose contents are accessed based - on the format string specified by Format. - - @return Number of Unicode characters printed to ConOut. - -**/ -UINTN -EFIAPI -Print ( - IN CONST CHAR16 *Format, - ... - ) -{ - VA_LIST Marker; - UINTN Return; - - VA_START (Marker, Format); - - Return = InternalPrint (Format, gST->ConOut, Marker); - - VA_END (Marker); - - return Return; -} - -/** - Prints a formatted Unicode string to the console output device specified by - StdErr defined in the EFI_SYSTEM_TABLE. - - This function prints a formatted Unicode string to the console output device - specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode - characters that printed to StdErr. If the length of the formatted Unicode - string is greater than PcdUefiLibMaxPrintBufferSize, then only the first - PcdUefiLibMaxPrintBufferSize characters are sent to StdErr. - If Format is NULL, then ASSERT(). - If Format is not aligned on a 16-bit boundary, then ASSERT(). - If gST->StdErr is NULL, then ASSERT(). - - @param Format Null-terminated Unicode format string. - @param ... Variable argument list whose contents are accessed based - on the format string specified by Format. - - @return Number of Unicode characters printed to StdErr. - -**/ -UINTN -EFIAPI -ErrorPrint ( - IN CONST CHAR16 *Format, - ... - ) -{ - VA_LIST Marker; - UINTN Return; - - VA_START (Marker, Format); - - Return = InternalPrint( Format, gST->StdErr, Marker); - - VA_END (Marker); - - return Return; -} - - -/** - Internal function which prints a formatted ASCII string to the console output device - specified by Console - - This function prints a formatted ASCII string to the console output device - specified by Console and returns the number of ASCII characters that printed - to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize, - then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console. - - If Format is NULL, then ASSERT(). - - @param Format Null-terminated ASCII format string. - @param Console The output console. - @param Marker VA_LIST marker for the variable argument list. - - @return The number of Unicode characters in the produced - output buffer not including the Null-terminator. - -**/ -UINTN -AsciiInternalPrint ( - IN CONST CHAR8 *Format, - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console, - IN VA_LIST Marker - ) -{ - EFI_STATUS Status; - UINTN Return; - CHAR16 *Buffer; - UINTN BufferSize; - - ASSERT (Format != NULL); - ASSERT (Console != NULL); - - BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16); - - Buffer = (CHAR16 *) AllocatePool(BufferSize); - ASSERT (Buffer != NULL); - - Return = UnicodeVSPrintAsciiFormat (Buffer, BufferSize, Format, Marker); - - if (Console != NULL) { - // - // To be extra safe make sure Console has been initialized - // - Status = Console->OutputString (Console, Buffer); - if (EFI_ERROR (Status)) { - Return = 0; - } - } - - FreePool (Buffer); - - return Return; -} - -/** - Prints a formatted ASCII string to the console output device specified by - ConOut defined in the EFI_SYSTEM_TABLE. - - This function prints a formatted ASCII string to the console output device - specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII - characters that printed to ConOut. If the length of the formatted ASCII - string is greater than PcdUefiLibMaxPrintBufferSize, then only the first - PcdUefiLibMaxPrintBufferSize characters are sent to ConOut. - If Format is NULL, then ASSERT(). - If gST->ConOut is NULL, then ASSERT(). - - @param Format Null-terminated ASCII format string. - @param ... Variable argument list whose contents are accessed based - on the format string specified by Format. - - @return Number of ASCII characters printed to ConOut. - -**/ -UINTN -EFIAPI -AsciiPrint ( - IN CONST CHAR8 *Format, - ... - ) -{ - VA_LIST Marker; - UINTN Return; - ASSERT (Format != NULL); - - VA_START (Marker, Format); - - Return = AsciiInternalPrint( Format, gST->ConOut, Marker); - - VA_END (Marker); - - return Return; -} - -/** - Prints a formatted ASCII string to the console output device specified by - StdErr defined in the EFI_SYSTEM_TABLE. - - This function prints a formatted ASCII string to the console output device - specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII - characters that printed to StdErr. If the length of the formatted ASCII - string is greater than PcdUefiLibMaxPrintBufferSize, then only the first - PcdUefiLibMaxPrintBufferSize characters are sent to StdErr. - If Format is NULL, then ASSERT(). - If gST->StdErr is NULL, then ASSERT(). - - @param Format Null-terminated ASCII format string. - @param ... Variable argument list whose contents are accessed based - on the format string specified by Format. - - @return Number of ASCII characters printed to ConErr. - -**/ -UINTN -EFIAPI -AsciiErrorPrint ( - IN CONST CHAR8 *Format, - ... - ) -{ - VA_LIST Marker; - UINTN Return; - - ASSERT (Format != NULL); - - VA_START (Marker, Format); - - Return = AsciiInternalPrint( Format, gST->StdErr, Marker); - - VA_END (Marker); - - return Return; -} - -/** - Internal function to print a formatted Unicode string to a graphics console device specified by - ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates. - - This function prints a formatted Unicode string to the graphics console device - specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of - Unicode characters printed. The EFI_HII_FONT_PROTOCOL is used to convert the - string to a bitmap using the glyphs registered with the - HII database. No wrapping is performed, so any portions of the string the fall - outside the active display region will not be displayed. - - If a graphics console device is not associated with the ConsoleOutputHandle - defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned. - If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no - string is printed, and 0 is returned. - - @param PointX X coordinate to print the string. - @param PointY Y coordinate to print the string. - @param Foreground The foreground color of the string being printed. This is - an optional parameter that may be NULL. If it is NULL, - then the foreground color of the current ConOut device - in the EFI_SYSTEM_TABLE is used. - @param Background The background color of the string being printed. This is - an optional parameter that may be NULL. If it is NULL, - then the background color of the current ConOut device - in the EFI_SYSTEM_TABLE is used. - @param Buffer Null-terminated Unicode formatted string. - @param PrintNum The number of Unicode formatted string to be printed. - - @return Number of Unicode Characters printed. Zero means no any character - displayed successfully. - -**/ -UINTN -InternalPrintGraphic ( - IN UINTN PointX, - IN UINTN PointY, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background, - IN CHAR16 *Buffer, - IN UINTN PrintNum - ) -{ - EFI_STATUS Status; - UINT32 HorizontalResolution; - UINT32 VerticalResolution; - UINT32 ColorDepth; - UINT32 RefreshRate; - EFI_HII_FONT_PROTOCOL *HiiFont; - EFI_IMAGE_OUTPUT *Blt; - EFI_FONT_DISPLAY_INFO FontInfo; - EFI_HII_ROW_INFO *RowInfoArray; - UINTN RowInfoArraySize; - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; - EFI_UGA_DRAW_PROTOCOL *UgaDraw; - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto; - EFI_HANDLE ConsoleHandle; - UINTN Width; - UINTN Height; - UINTN Delta; - - HorizontalResolution = 0; - VerticalResolution = 0; - Blt = NULL; - RowInfoArray = NULL; - - ConsoleHandle = gST->ConsoleOutHandle; - - ASSERT( ConsoleHandle != NULL); - - Status = gBS->HandleProtocol ( - ConsoleHandle, - &gEfiGraphicsOutputProtocolGuid, - (VOID **) &GraphicsOutput - ); - - UgaDraw = NULL; - if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) { - // - // If no GOP available, try to open UGA Draw protocol if supported. - // - GraphicsOutput = NULL; - - Status = gBS->HandleProtocol ( - ConsoleHandle, - &gEfiUgaDrawProtocolGuid, - (VOID **) &UgaDraw - ); - } - if (EFI_ERROR (Status)) { - goto Error; - } - - Status = gBS->HandleProtocol ( - ConsoleHandle, - &gEfiSimpleTextOutProtocolGuid, - (VOID **) &Sto - ); - - if (EFI_ERROR (Status)) { - goto Error; - } - - if (GraphicsOutput != NULL) { - HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution; - VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution; - } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) { - UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate); - } else { - goto Error; - } - - ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0)); - - Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont); - if (EFI_ERROR (Status)) { - goto Error; - } - - Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT)); - ASSERT (Blt != NULL); - - Blt->Width = (UINT16) (HorizontalResolution); - Blt->Height = (UINT16) (VerticalResolution); - - ZeroMem (&FontInfo, sizeof (EFI_FONT_DISPLAY_INFO)); - - if (Foreground != NULL) { - CopyMem (&FontInfo.ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - } else { - CopyMem ( - &FontInfo.ForegroundColor, - &mEfiColors[Sto->Mode->Attribute & 0x0f], - sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) - ); - } - if (Background != NULL) { - CopyMem (&FontInfo.BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - } else { - CopyMem ( - &FontInfo.BackgroundColor, - &mEfiColors[Sto->Mode->Attribute >> 4], - sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) - ); - } - - if (GraphicsOutput != NULL) { - Blt->Image.Screen = GraphicsOutput; - - Status = HiiFont->StringToImage ( - HiiFont, - EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_OUT_FLAG_CLIP | - EFI_HII_OUT_FLAG_CLIP_CLEAN_X | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y | - EFI_HII_IGNORE_LINE_BREAK | EFI_HII_DIRECT_TO_SCREEN, - Buffer, - &FontInfo, - &Blt, - PointX, - PointY, - &RowInfoArray, - &RowInfoArraySize, - NULL - ); - if (EFI_ERROR (Status)) { - goto Error; - } - - } else if (FeaturePcdGet (PcdUgaConsumeSupport)) { - ASSERT (UgaDraw!= NULL); - - // - // Ensure Width * Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow. - // - if (Blt->Width > DivU64x32 (MAX_UINTN, Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) { - goto Error; - } - - Blt->Image.Bitmap = AllocateZeroPool ((UINT32) Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - ASSERT (Blt->Image.Bitmap != NULL); - - // - // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform, - // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw. - // - Status = HiiFont->StringToImage ( - HiiFont, - EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_OUT_FLAG_CLIP | - EFI_HII_OUT_FLAG_CLIP_CLEAN_X | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y | - EFI_HII_IGNORE_LINE_BREAK, - Buffer, - &FontInfo, - &Blt, - PointX, - PointY, - &RowInfoArray, - &RowInfoArraySize, - NULL - ); - - if (!EFI_ERROR (Status)) { - ASSERT (RowInfoArray != NULL); - // - // Explicit Line break characters are ignored, so the updated parameter RowInfoArraySize by StringToImage will - // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure. - // - ASSERT (RowInfoArraySize <= 1); - - if (RowInfoArraySize != 0) { - Width = RowInfoArray[0].LineWidth; - Height = RowInfoArray[0].LineHeight; - Delta = Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); - } else { - Width = 0; - Height = 0; - Delta = 0; - } - Status = UgaDraw->Blt ( - UgaDraw, - (EFI_UGA_PIXEL *) Blt->Image.Bitmap, - EfiUgaBltBufferToVideo, - PointX, - PointY, - PointX, - PointY, - Width, - Height, - Delta - ); - } else { - goto Error; - } - FreePool (Blt->Image.Bitmap); - } else { - goto Error; - } - // - // Calculate the number of actual printed characters - // - if (RowInfoArraySize != 0) { - PrintNum = RowInfoArray[0].EndIndex - RowInfoArray[0].StartIndex + 1; - } else { - PrintNum = 0; - } - - FreePool (RowInfoArray); - FreePool (Blt); - return PrintNum; - -Error: - if (Blt != NULL) { - FreePool (Blt); - } - return 0; -} - -/** - Prints a formatted Unicode string to a graphics console device specified by - ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates. - - This function prints a formatted Unicode string to the graphics console device - specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of - Unicode characters displayed, not including partial characters that may be clipped - by the right edge of the display. If the length of the formatted Unicode string is - greater than PcdUefiLibMaxPrintBufferSize, then at most the first - PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL - StringToImage() service is used to convert the string to a bitmap using the glyphs - registered with the HII database. No wrapping is performed, so any portions of the - string the fall outside the active display region will not be displayed. Please see - Section 27.2.6 of the UEFI Specification for a description of the supported string - format including the set of control codes supported by the StringToImage() service. - - If a graphics console device is not associated with the ConsoleOutputHandle - defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned. - If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no - string is printed, and 0 is returned. - If Format is NULL, then ASSERT(). - If Format is not aligned on a 16-bit boundary, then ASSERT(). - If gST->ConsoleOutputHandle is NULL, then ASSERT(). - - @param PointX X coordinate to print the string. - @param PointY Y coordinate to print the string. - @param ForeGround The foreground color of the string being printed. This is - an optional parameter that may be NULL. If it is NULL, - then the foreground color of the current ConOut device - in the EFI_SYSTEM_TABLE is used. - @param BackGround The background color of the string being printed. This is - an optional parameter that may be NULL. If it is NULL, - then the background color of the current ConOut device - in the EFI_SYSTEM_TABLE is used. - @param Format Null-terminated Unicode format string. See Print Library - for the supported format string syntax. - @param ... Variable argument list whose contents are accessed based on - the format string specified by Format. - - @return The number of Unicode characters printed. - -**/ -UINTN -EFIAPI -PrintXY ( - IN UINTN PointX, - IN UINTN PointY, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL - IN CONST CHAR16 *Format, - ... - ) -{ - VA_LIST Marker; - CHAR16 *Buffer; - UINTN BufferSize; - UINTN PrintNum; - UINTN ReturnNum; - - ASSERT (Format != NULL); - ASSERT (((UINTN) Format & BIT0) == 0); - - VA_START (Marker, Format); - - BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16); - - Buffer = (CHAR16 *) AllocatePool (BufferSize); - ASSERT (Buffer != NULL); - - PrintNum = UnicodeVSPrint (Buffer, BufferSize, Format, Marker); - - VA_END (Marker); - - ReturnNum = InternalPrintGraphic (PointX, PointY, ForeGround, BackGround, Buffer, PrintNum); - - FreePool (Buffer); - - return ReturnNum; -} - -/** - Prints a formatted ASCII string to a graphics console device specified by - ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates. - - This function prints a formatted ASCII string to the graphics console device - specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of - ASCII characters displayed, not including partial characters that may be clipped - by the right edge of the display. If the length of the formatted ASCII string is - greater than PcdUefiLibMaxPrintBufferSize, then at most the first - PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL - StringToImage() service is used to convert the string to a bitmap using the glyphs - registered with the HII database. No wrapping is performed, so any portions of the - string the fall outside the active display region will not be displayed. Please see - Section 27.2.6 of the UEFI Specification for a description of the supported string - format including the set of control codes supported by the StringToImage() service. - - If a graphics console device is not associated with the ConsoleOutputHandle - defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned. - If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no - string is printed, and 0 is returned. - If Format is NULL, then ASSERT(). - If gST->ConsoleOutputHandle is NULL, then ASSERT(). - - @param PointX X coordinate to print the string. - @param PointY Y coordinate to print the string. - @param ForeGround The foreground color of the string being printed. This is - an optional parameter that may be NULL. If it is NULL, - then the foreground color of the current ConOut device - in the EFI_SYSTEM_TABLE is used. - @param BackGround The background color of the string being printed. This is - an optional parameter that may be NULL. If it is NULL, - then the background color of the current ConOut device - in the EFI_SYSTEM_TABLE is used. - @param Format Null-terminated ASCII format string. See Print Library - for the supported format string syntax. - @param ... Variable argument list whose contents are accessed based on - the format string specified by Format. - - @return The number of ASCII characters printed. - -**/ -UINTN -EFIAPI -AsciiPrintXY ( - IN UINTN PointX, - IN UINTN PointY, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL - IN CONST CHAR8 *Format, - ... - ) -{ - VA_LIST Marker; - CHAR16 *Buffer; - UINTN BufferSize; - UINTN PrintNum; - UINTN ReturnNum; - - ASSERT (Format != NULL); - - VA_START (Marker, Format); - - BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16); - - Buffer = (CHAR16 *) AllocatePool (BufferSize); - ASSERT (Buffer != NULL); - - PrintNum = UnicodeSPrintAsciiFormat (Buffer, BufferSize, Format, Marker); - - VA_END (Marker); - - ReturnNum = InternalPrintGraphic (PointX, PointY, ForeGround, BackGround, Buffer, PrintNum); - - FreePool (Buffer); - - return ReturnNum; -} - -/** - Appends a formatted Unicode string to a Null-terminated Unicode string - - This function appends a formatted Unicode string to the Null-terminated - Unicode string specified by String. String is optional and may be NULL. - Storage for the formatted Unicode string returned is allocated using - AllocatePool(). The pointer to the appended string is returned. The caller - is responsible for freeing the returned string. - - If String is not NULL and not aligned on a 16-bit boundary, then ASSERT(). - If FormatString is NULL, then ASSERT(). - If FormatString is not aligned on a 16-bit boundary, then ASSERT(). - - @param[in] String A Null-terminated Unicode string. - @param[in] FormatString A Null-terminated Unicode format string. - @param[in] Marker VA_LIST marker for the variable argument list. - - @retval NULL There was not enough available memory. - @return Null-terminated Unicode string is that is the formatted - string appended to String. -**/ -CHAR16* -EFIAPI -CatVSPrint ( - IN CHAR16 *String, OPTIONAL - IN CONST CHAR16 *FormatString, - IN VA_LIST Marker - ) -{ - UINTN CharactersRequired; - UINTN SizeRequired; - CHAR16 *BufferToReturn; - VA_LIST ExtraMarker; - - VA_COPY (ExtraMarker, Marker); - CharactersRequired = SPrintLength(FormatString, ExtraMarker); - VA_END (ExtraMarker); - - if (String != NULL) { - SizeRequired = StrSize(String) + (CharactersRequired * sizeof(CHAR16)); - } else { - SizeRequired = sizeof(CHAR16) + (CharactersRequired * sizeof(CHAR16)); - } - - BufferToReturn = AllocatePool(SizeRequired); - - if (BufferToReturn == NULL) { - return NULL; - } else { - BufferToReturn[0] = L'\0'; - } - - if (String != NULL) { - StrCpyS(BufferToReturn, SizeRequired / sizeof(CHAR16), String); - } - - UnicodeVSPrint(BufferToReturn + StrLen(BufferToReturn), (CharactersRequired+1) * sizeof(CHAR16), FormatString, Marker); - - ASSERT(StrSize(BufferToReturn)==SizeRequired); - - return (BufferToReturn); -} - -/** - Appends a formatted Unicode string to a Null-terminated Unicode string - - This function appends a formatted Unicode string to the Null-terminated - Unicode string specified by String. String is optional and may be NULL. - Storage for the formatted Unicode string returned is allocated using - AllocatePool(). The pointer to the appended string is returned. The caller - is responsible for freeing the returned string. - - If String is not NULL and not aligned on a 16-bit boundary, then ASSERT(). - If FormatString is NULL, then ASSERT(). - If FormatString is not aligned on a 16-bit boundary, then ASSERT(). - - @param[in] String A Null-terminated Unicode string. - @param[in] FormatString A Null-terminated Unicode format string. - @param[in] ... The variable argument list whose contents are - accessed based on the format string specified by - FormatString. - - @retval NULL There was not enough available memory. - @return Null-terminated Unicode string is that is the formatted - string appended to String. -**/ -CHAR16 * -EFIAPI -CatSPrint ( - IN CHAR16 *String, OPTIONAL - IN CONST CHAR16 *FormatString, - ... - ) -{ - VA_LIST Marker; - CHAR16 *NewString; - - VA_START (Marker, FormatString); - NewString = CatVSPrint(String, FormatString, Marker); - VA_END (Marker); - return NewString; -} - diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c deleted file mode 100644 index b4937bab1f..0000000000 --- a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c +++ /dev/null @@ -1,327 +0,0 @@ -/** @file - Library functions that abstract areas of conflict between framework and UEFI 2.0. - - Help Port Framework code that has conflicts with UEFI 2.0 by hiding the - old conflicts with library functions and supporting implementations of the old - (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. This module is a DXE driver as - it contains DXE enum extensions for EFI event services. - -Copyright (c) 2006 - 2018, 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 -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 "UefiLibInternal.h" - -/** - Create a Legacy Boot Event. - - Tiano extended the CreateEvent Type enum to add a legacy boot event type. - This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was - added and now it's possible to not voilate the UEFI specification by - declaring a GUID for the legacy boot event class. This library supports - the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to - work both ways. - - @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). - - @retval EFI_SUCCESS Event was created. - @retval Other Event was not created. - -**/ -EFI_STATUS -EFIAPI -EfiCreateEventLegacyBoot ( - OUT EFI_EVENT *LegacyBootEvent - ) -{ - return EfiCreateEventLegacyBootEx ( - TPL_CALLBACK, - EfiEventEmptyFunction, - NULL, - LegacyBootEvent - ); -} - -/** - Create an EFI event in the Legacy Boot Event Group and allows - the caller to specify a notification function. - - This function abstracts the creation of the Legacy Boot Event. - The Framework moved from a proprietary to UEFI 2.0 based mechanism. - This library abstracts the caller from how this event is created to prevent - to code form having to change with the version of the specification supported. - If LegacyBootEvent is NULL, then ASSERT(). - - @param NotifyTpl The task priority level of the event. - @param NotifyFunction The notification function to call when the event is signaled. - @param NotifyContext The content to pass to NotifyFunction when the event is signaled. - @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). - - @retval EFI_SUCCESS Event was created. - @retval Other Event was not created. - -**/ -EFI_STATUS -EFIAPI -EfiCreateEventLegacyBootEx ( - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL - IN VOID *NotifyContext, OPTIONAL - OUT EFI_EVENT *LegacyBootEvent - ) -{ - EFI_STATUS Status; - - ASSERT (LegacyBootEvent != NULL); - - if (gST->Hdr.Revision < 0x00020000) { - // - // prior to UEFI 2.0 use Tiano extension to EFI - // - Status = gBS->CreateEvent ( - EFI_EVENT_SIGNAL_LEGACY_BOOT | EVT_NOTIFY_SIGNAL, - NotifyTpl, - NotifyFunction, - NotifyContext, - LegacyBootEvent - ); - } else { - // - // For UEFI 2.0 and the future use an Event Group - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - NotifyTpl, - NotifyFunction, - NotifyContext, - &gEfiEventLegacyBootGuid, - LegacyBootEvent - ); - } - - return Status; -} - -/** - Create a Read to Boot Event. - - Tiano extended the CreateEvent Type enum to add a ready to boot event type. - This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was - added and now it's possible to not voilate the UEFI specification and use - the ready to boot event class defined in UEFI 2.0. This library supports - the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to - work both ways. - - @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). - - @retval EFI_SUCCESS Event was created. - @retval Other Event was not created. - -**/ -EFI_STATUS -EFIAPI -EfiCreateEventReadyToBoot ( - OUT EFI_EVENT *ReadyToBootEvent - ) -{ - return EfiCreateEventReadyToBootEx ( - TPL_CALLBACK, - EfiEventEmptyFunction, - NULL, - ReadyToBootEvent - ); -} - -/** - Create an EFI event in the Ready To Boot Event Group and allows - the caller to specify a notification function. - - This function abstracts the creation of the Ready to Boot Event. - The Framework moved from a proprietary to UEFI 2.0 based mechanism. - This library abstracts the caller from how this event is created to prevent - to code form having to change with the version of the specification supported. - If ReadyToBootEvent is NULL, then ASSERT(). - - @param NotifyTpl The task priority level of the event. - @param NotifyFunction The notification function to call when the event is signaled. - @param NotifyContext The content to pass to NotifyFunction when the event is signaled. - @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). - - @retval EFI_SUCCESS Event was created. - @retval Other Event was not created. - -**/ -EFI_STATUS -EFIAPI -EfiCreateEventReadyToBootEx ( - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL - IN VOID *NotifyContext, OPTIONAL - OUT EFI_EVENT *ReadyToBootEvent - ) -{ - EFI_STATUS Status; - - ASSERT (ReadyToBootEvent != NULL); - - if (gST->Hdr.Revision < 0x00020000) { - // - // prior to UEFI 2.0 use Tiano extension to EFI - // - Status = gBS->CreateEvent ( - EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL, - NotifyTpl, - NotifyFunction, - NotifyContext, - ReadyToBootEvent - ); - } else { - // - // For UEFI 2.0 and the future use an Event Group - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - NotifyTpl, - NotifyFunction, - NotifyContext, - &gEfiEventReadyToBootGuid, - ReadyToBootEvent - ); - } - - return Status; -} - - -/** - Signal a Ready to Boot Event. - - Create a Ready to Boot Event. Signal it and close it. This causes other - events of the same event group to be signaled in other modules. - -**/ -VOID -EFIAPI -EfiSignalEventReadyToBoot ( - VOID - ) -{ - EFI_STATUS Status; - EFI_EVENT ReadyToBootEvent; - - Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent); - if (!EFI_ERROR (Status)) { - gBS->SignalEvent (ReadyToBootEvent); - gBS->CloseEvent (ReadyToBootEvent); - } -} - -/** - Signal a Legacy Boot Event. - - Create a legacy Boot Event. Signal it and close it. This causes other - events of the same event group to be signaled in other modules. - -**/ -VOID -EFIAPI -EfiSignalEventLegacyBoot ( - VOID - ) -{ - EFI_STATUS Status; - EFI_EVENT LegacyBootEvent; - - Status = EfiCreateEventLegacyBoot (&LegacyBootEvent); - if (!EFI_ERROR (Status)) { - gBS->SignalEvent (LegacyBootEvent); - gBS->CloseEvent (LegacyBootEvent); - } -} - - -/** - Check to see if the Firmware Volume (FV) Media Device Path is valid - - Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum - so as we move to UEFI 2.0 support we must use a mechanism that conforms with - the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed - device path is defined for Tiano extensions of device path. If the code - is compiled to conform with the UEFI 2.0 specification use the new device path - else use the old form for backwards compatability. The return value to this - function points to a location in FvDevicePathNode and it does not allocate - new memory for the GUID pointer that is returned. - - @param FvDevicePathNode Pointer to FV device path to check. - - @retval NULL FvDevicePathNode is not valid. - @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned. - -**/ -EFI_GUID * -EFIAPI -EfiGetNameGuidFromFwVolDevicePathNode ( - IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode - ) -{ - ASSERT (FvDevicePathNode != NULL); - - // - // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10. - // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with - // EFI 1.10 and UEFI 2.10. - // - if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH && - DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_PIWG_FW_FILE_DP) { - return (EFI_GUID *) &FvDevicePathNode->FvFileName; - } - - return NULL; -} - - -/** - Initialize a Firmware Volume (FV) Media Device Path node. - - Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum - so as we move to UEFI 2.0 support we must use a mechanism that conforms with - the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed - device path is defined for Tiano extensions of device path. If the code - is compiled to conform with the UEFI 2.0 specification use the new device path - else use the old form for backwards compatability. - - @param FvDevicePathNode Pointer to a FV device path node to initialize - @param NameGuid FV file name to use in FvDevicePathNode - -**/ -VOID -EFIAPI -EfiInitializeFwVolDevicepathNode ( - IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, - IN CONST EFI_GUID *NameGuid - ) -{ - ASSERT (FvDevicePathNode != NULL); - ASSERT (NameGuid != NULL); - - // - // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10. - // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with - // EFI 1.10 and UEFI 2.10. - // - FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH; - FvDevicePathNode->Header.SubType = MEDIA_PIWG_FW_FILE_DP; - SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); - - CopyGuid (&FvDevicePathNode->FvFileName, NameGuid); -} - -- 2.18.0.windows.1