]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Sync UefiLib instance in IntelFrameworkPkg with the one in MdePkg.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 1 Dec 2008 14:42:26 +0000 (14:42 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 1 Dec 2008 14:42:26 +0000 (14:42 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6797 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkPkg/Library/FrameworkUefiLib/Console.c
IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.h [deleted file]
IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.inf
IntelFrameworkPkg/Library/FrameworkUefiLib/UefiDriverModel.c
IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c
IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h [new file with mode: 0644]
IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibPrint.c
IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c

index 67598b0b4fa10449daeb9d8269e627354c01f945..fd223f42f33e2594c6c79b8bfef3c48714d8dcd0 100644 (file)
@@ -1,31 +1,34 @@
 /** @file\r
-  The module provide methods to compute the displayed unicode width.\r
+  This module provide help function for displaying unicode string.\r
 \r
-  Copyright (c) 2007, Intel Corporation<BR>\r
-  All rights reserved. This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
+  Copyright (c) 2006, Intel Corporation<BR>\r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
 \r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
 **/\r
 \r
-#include "FrameworkUefiLib.h"\r
-  \r
+\r
+\r
+\r
+#include "UefiLibInternal.h"\r
+\r
 typedef struct {\r
   CHAR16  WChar;\r
   UINT32  Width;\r
 } UNICODE_WIDTH_ENTRY;\r
 \r
-UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {\r
   //\r
   // General script area\r
   //\r
   {(CHAR16)0x1FFF,  1},\r
   /*\r
-   * Merge the blocks and replace them with the above entry as they fall to\r
+   * Merge the blocks and replace them with the above entry as they fall to \r
    * the same category and they are all narrow glyph. This will reduce search\r
    * time and table size. The merge will omit the reserved code.\r
    *\r
@@ -72,7 +75,7 @@ UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {
   //\r
   {(CHAR16)0x2FFF,  1},\r
   /*\r
-   * Merge the blocks and replace them with the above entry as they fall to\r
+   * Merge the blocks and replace them with the above entry as they fall to \r
    * the same category and they are all narrow glyph. This will reduce search\r
    * time and table size. The merge will omit the reserved code.\r
    *\r
@@ -104,7 +107,7 @@ UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {
   //\r
   {(CHAR16)0x33FF,  2},\r
   /*\r
-   * Merge the blocks and replace them with the above entry as they fall to\r
+   * Merge the blocks and replace them with the above entry as they fall to \r
    * the same category and they are all wide glyph. This will reduce search\r
    * time and table size. The merge will omit the reserved code.\r
    *\r
@@ -127,13 +130,13 @@ UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {
   //\r
   {(CHAR16)0x9FFF,  2},\r
   /*\r
-   * Merge the blocks and replace them with the above entry as they fall to\r
+   * Merge the blocks and replace them with the above entry as they fall to \r
    * the same category and they are all wide glyph. This will reduce search\r
    * time and table size. The merge will omit the reserved code.\r
    *\r
    * Remove the above item if below is un-commented.\r
    *\r
-  {(CHAR16)0x4DFF,  0},       // Reserved. 0x3400-0x4DBF as CJK unified ideographs\r
+  {(CHAR16)0x4DFF,  0},       // Reserved. 0x3400-0x4DBF as CJK unified ideographs \r
                       // extension A in ver3.0. 0x3400-0x4DFF\r
   {(CHAR16)0x9FFF,  2},       // CJK unified ideographs. 0x4E00-0x9FFF\r
   *\r
@@ -149,7 +152,7 @@ UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {
   //\r
   {(CHAR16)0xD7FF,  2},\r
   /*\r
-   * Merge the blocks and replace them with the above entry as they fall to\r
+   * Merge the blocks and replace them with the above entry as they fall to \r
    * the same category and they are all wide glyph. This will reduce search\r
    * time and table size. The merge will omit the reserved code.\r
    *\r
@@ -186,8 +189,10 @@ UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {
 };\r
 \r
 /**\r
-  This function computes and returns the width of the Unicode character\r
-  specified by UnicodeChar.\r
+  Retrieves the width of a Unicode character.\r
+\r
+  This function computes and returns the width of the Unicode character specified\r
+  by UnicodeChar.\r
 \r
   @param  UnicodeChar   A Unicode character.\r
 \r
@@ -202,10 +207,10 @@ GetGlyphWidth (
   IN CHAR16  UnicodeChar\r
   )\r
 {\r
-  UINTN               Index;\r
-  UINTN               Low;\r
-  UINTN               High;\r
-  UNICODE_WIDTH_ENTRY *Item;\r
+  UINTN                     Index;\r
+  UINTN                     Low;\r
+  UINTN                     High;\r
+  CONST UNICODE_WIDTH_ENTRY *Item;\r
 \r
   Item  = NULL;\r
   Low   = 0;\r
@@ -241,16 +246,20 @@ GetGlyphWidth (
 }\r
 \r
 /**\r
-  This function computes and returns the display length of\r
-  the Null-terminated Unicode string specified by String.\r
-  If String is NULL, then 0 is returned.\r
-  If any of the widths of the Unicode characters in String\r
-  can not be determined, then 0 is returned.\r
+  Computes the display length of a Null-terminated Unicode String.\r
+\r
+  This function computes and returns the display length of the Null-terminated Unicode\r
+  string specified by String.  If String is NULL then 0 is returned. If any of the widths\r
+  of the Unicode characters in String can not be determined, then 0 is returned. The display\r
+  width of String can be computed by summing the display widths of each Unicode character\r
+  in String.  Unicode characters that are narrow glyphs have a width of 1, and Unicode\r
+  characters that are width glyphs have a width of 2. \r
+  If String is not aligned on a 16-bit boundary, then ASSERT().\r
 \r
   @param  String      A pointer to a Null-terminated Unicode string.\r
 \r
   @return The display length of the Null-terminated Unicode string specified by String.\r
-\r
+  \r
 **/\r
 UINTN\r
 EFIAPI\r
diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.h b/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.h
deleted file mode 100644 (file)
index 0d8365a..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/** @file\r
-  Header file to include header files common to all source files in\r
-  FrameworkUefiLib.\r
-\r
-  Copyright (c) 2007, Intel Corporation<BR>\r
-  All rights reserved. This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _UEFI_LIB_FRAMEWORK_H_\r
-#define _UEFI_LIB_FRAMEWORK_H_\r
-\r
-\r
-#include <FrameworkDxe.h>\r
-\r
-#include <Protocol/DriverBinding.h>\r
-#include <Protocol/ComponentName.h>\r
-#include <Protocol/ComponentName2.h>\r
-#include <Protocol/DriverConfiguration.h>\r
-#include <Protocol/DriverDiagnostics.h>\r
-#include <Protocol/DriverDiagnostics2.h>\r
-\r
-#include <Guid/EventGroup.h>\r
-#include <Guid/EventLegacyBios.h>\r
-#include <Guid/FrameworkDevicePath.h>\r
-\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-#endif\r
index 058fa05ede77c824a6da97eb599081f9b4336931..91285620f44bc660da4c5d439c09dc7e9beb506b 100644 (file)
   INF_VERSION                    = 0x00010005\r
   BASE_NAME                      = FrameworkUefiLib\r
   FILE_GUID                      = B2F0D71A-A39F-4094-854B-0C6BA6910CCE\r
-  MODULE_TYPE                    = DXE_DRIVER\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
   VERSION_STRING                 = 1.0\r
   LIBRARY_CLASS                  = UefiLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
-  EDK_RELEASE_VERSION            = 0x00020000\r
-  EFI_SPECIFICATION_VERSION      = 0x00020000\r
 \r
 \r
-#\r
-# The following information is for reference only and not required by the build tools.\r
 #\r
 #  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
 #\r
 [Sources.common]\r
   UefiLibPrint.c\r
   UefiNotTiano.c\r
+  UefiDriverModel.c\r
   Console.c\r
   UefiLib.c\r
-  UefiDriverModel.c\r
-  FrameworkUefiLib.h\r
-  \r
+  UefiLibInternal.h\r
+\r
+\r
 [Packages]\r
   MdePkg/MdePkg.dec\r
   IntelFrameworkPkg/IntelFrameworkPkg.dec\r
   UefiBootServicesTableLib\r
   DevicePathLib\r
   \r
+[Guids]\r
+  gEfiFrameworkDevicePathGuid                   # ALWAYS_CONSUMED\r
+  gEfiEventReadyToBootGuid                      # ALWAYS_CONSUMED\r
+  gEfiEventLegacyBootGuid                       # ALWAYS_CONSUMED\r
+\r
+\r
 [Protocols]\r
   gEfiDriverBindingProtocolGuid                 # ALWAYS_CONSUMED\r
+  gEfiSimpleTextOutProtocolGuid                 # ALWAYS_CONSUMED\r
+  gEfiGraphicsOutputProtocolGuid                # ALWAYS_CONSUMED\r
+  gEfiHiiFontProtocolGuid                       # ALWAYS_CONSUMED\r
   gEfiComponentNameProtocolGuid                 # SOMETIMES_CONSUMED\r
   gEfiComponentName2ProtocolGuid                # SOMETIMES_CONSUMED\r
   gEfiDriverConfigurationProtocolGuid           # SOMETIMES_CONSUMED\r
   gEfiDriverConfiguration2ProtocolGuid          # SOMETIMES_CONSUMED\r
   gEfiDriverDiagnosticsProtocolGuid             # SOMETIMES_CONSUMED\r
   gEfiDriverDiagnostics2ProtocolGuid            # SOMETIMES_CONSUMED\r
-  gEfiFirmwareVolume2ProtocolGuid               # ALWAYS_CONSUMED\r
-\r
-[Guids]\r
-  gEfiFrameworkDevicePathGuid                   # ALWAYS_CONSUMED\r
-  gEfiEventReadyToBootGuid                      # ALWAYS_CONSUMED\r
-  gEfiEventLegacyBootGuid                       # ALWAYS_CONSUMED\r
+  gEfiUgaDrawProtocolGuid                       # SOMETIMES_CONSUMED\r
 \r
 \r
 [Pcd.common]\r
@@ -81,3 +82,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable\r
   gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable\r
   gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable\r
+  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport\r
+\r
+\r
+\r
index 19af4965c20830fa674ce5cb4bab4a4197a5d191..28037b605873ed1251b01b4e41e2b2210a33732d 100644 (file)
 \r
 **/ \r
 \r
-#include "FrameworkUefiLib.h"\r
+\r
+#include "UefiLibInternal.h"\r
 \r
 /**\r
-  Intialize a driver by installing the Driver Binding Protocol onto the driver's\r
-  DriverBindingHandle.  This is typically the same as the driver's ImageHandle, but\r
-  it can be different if the driver produces multiple DriverBinding Protocols. \r
-  If the Drvier Binding Protocol interface is NULL, then ASSERT (). \r
-  If the installation fails, then ASSERT ().\r
+  Installs and completes the initialization of a Driver Binding Protocol instance.\r
+  \r
+  Installs the Driver Binding Protocol specified by DriverBinding onto the handle\r
+  specified by DriverBindingHandle. If DriverBindingHandle is NULL, then DriverBinding\r
+  is installed onto a newly created handle. DriverBindingHandle is typically the same\r
+  as the driver's ImageHandle, but it can be different if the driver produces multiple\r
+  Driver Binding Protocols. \r
+  If DriverBinding is NULL, then ASSERT(). \r
+  If DriverBinding can not be installed onto a handle, then ASSERT().\r
 \r
-  @param  ImageHandle                 The image handle of the driver.\r
-  @param  SystemTable                 The EFI System Table that was passed to the driver's entry point.\r
-  @param  DriverBinding               A Driver Binding Protocol instance that this driver is producing.\r
-  @param  DriverBindingHandle         The handle that DriverBinding is to be installe onto.  If this\r
-                                      parameter is NULL, then a new handle is created.\r
+  @param  ImageHandle          The image handle of the driver.\r
+  @param  SystemTable          The EFI System Table that was passed to the driver's entry point.\r
+  @param  DriverBinding        A Driver Binding Protocol instance that this driver is producing.\r
+  @param  DriverBindingHandle  The handle that DriverBinding is to be installed onto.  If this\r
+                               parameter is NULL, then a new handle is created.\r
 \r
-  @retval EFI_SUCCESS                 The protocol installation is completed successfully.\r
-  @retval Others                      Status from gBS->InstallMultipleProtocolInterfaces().\r
+  @retval EFI_SUCCESS           The protocol installation is completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  There was not enough system resources to install the protocol.\r
+  @retval Others                Status from gBS->InstallMultipleProtocolInterfaces().\r
 \r
 **/\r
 EFI_STATUS\r
@@ -66,24 +72,29 @@ EfiLibInstallDriverBinding (
 \r
 \r
 /**\r
-  Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name,\r
-  Driver Configure and Driver Diagnostic Protocols onto the driver's DriverBindingHandle.  This is\r
-  typically the same as the driver's ImageHandle, but it can be different if the driver produces multiple\r
-  DriverBinding Protocols. \r
-  If the Drvier Binding Protocol interface is NULL, then ASSERT (). \r
-  If the installation fails, then ASSERT ().\r
+  Installs and completes the initialization of a Driver Binding Protocol instance and\r
+  optionally installs the Component Name, Driver Configuration and Driver Diagnostics Protocols.\r
 \r
-  @param  ImageHandle                 The image handle of the driver.\r
-  @param  SystemTable                 The EFI System Table that was passed to the driver's entry point.\r
-  @param  DriverBinding               A Driver Binding Protocol instance that this driver is producing.\r
-  @param  DriverBindingHandle         The handle that DriverBinding is to be installe onto.  If this\r
-                                      parameter is NULL, then a new handle is created.\r
-  @param  ComponentName               A Component Name Protocol instance that this driver is producing.\r
-  @param  DriverConfiguration         A Driver Configuration Protocol instance that this driver is producing.\r
-  @param  DriverDiagnostics           A Driver Diagnostics Protocol instance that this driver is producing.\r
+  Initializes a driver by installing the Driver Binding Protocol together with the\r
+  optional Component Name, optional Driver Configure and optional Driver Diagnostic\r
+  Protocols onto the driver's DriverBindingHandle. If DriverBindingHandle is NULL,\r
+  then the protocols are  installed onto a newly created handle. DriverBindingHandle\r
+  is typically the same as the driver's ImageHandle, but it can be different if the\r
+  driver produces multiple Driver Binding Protocols. \r
+  If DriverBinding is NULL, then ASSERT(). \r
+  If the installation fails, then ASSERT().\r
+  \r
+  @param  ImageHandle          The image handle of the driver.\r
+  @param  SystemTable          The EFI System Table that was passed to the driver's entry point.\r
+  @param  DriverBinding        A Driver Binding Protocol instance that this driver is producing.\r
+  @param  DriverBindingHandle  The handle that DriverBinding is to be installed onto.  If this\r
+                               parameter is NULL, then a new handle is created.\r
+  @param  ComponentName        A Component Name Protocol instance that this driver is producing.\r
+  @param  DriverConfiguration  A Driver Configuration Protocol instance that this driver is producing.\r
+  @param  DriverDiagnostics    A Driver Diagnostics Protocol instance that this driver is producing.\r
 \r
-  @retval EFI_SUCCESS                 The protocol installation is completed successfully.\r
-  @retval Others                      Status from gBS->InstallMultipleProtocolInterfaces().\r
+  @retval EFI_SUCCESS           The protocol installation is completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  There was not enough memory in pool to install all the protocols.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -193,22 +204,26 @@ EfiLibInstallAllDriverProtocols (
 \r
 \r
 /**\r
-  Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name,\r
-  Component Name 2 onto the driver's DriverBindingHandle.  This is typically the same as the driver's\r
-  ImageHandle, but it can be different if the driver produces multiple DriverBinding Protocols. \r
-  If the Drvier Binding Protocol interface is NULL, then ASSERT (). \r
-  If the installation fails, then ASSERT ().\r
+  Installs Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.\r
 \r
-  @param  ImageHandle                 The image handle of the driver.\r
-  @param  SystemTable                 The EFI System Table that was passed to the driver's entry point.\r
-  @param  DriverBinding               A Driver Binding Protocol instance that this driver is producing.\r
-  @param  DriverBindingHandle         The handle that DriverBinding is to be installe onto.  If this\r
-                                      parameter is NULL, then a new handle is created.\r
-  @param  ComponentName               A Component Name Protocol instance that this driver is producing.\r
-  @param  ComponentName2              A Component Name 2 Protocol instance that this driver is producing.\r
+  Initializes a driver by installing the Driver Binding Protocol together with the\r
+  optional Component Name and optional Component Name 2 protocols onto the driver's\r
+  DriverBindingHandle.  If DriverBindingHandle is NULL, then the protocols are installed\r
+  onto a newly created handle.  DriverBindingHandle is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple Driver Binding Protocols. \r
+  If DriverBinding is NULL, then ASSERT(). \r
+  If the installation fails, then ASSERT().\r
 \r
-  @retval EFI_SUCCESS                 The protocol installation is completed successfully.\r
-  @retval Others                      Status from gBS->InstallMultipleProtocolInterfaces().\r
+  @param  ImageHandle          The image handle of the driver.\r
+  @param  SystemTable          The EFI System Table that was passed to the driver's entry point.\r
+  @param  DriverBinding        A Driver Binding Protocol instance that this driver is producing.\r
+  @param  DriverBindingHandle  The handle that DriverBinding is to be installed onto.  If this\r
+                               parameter is NULL, then a new handle is created.\r
+  @param  ComponentName        A Component Name Protocol instance that this driver is producing.\r
+  @param  ComponentName2       A Component Name 2 Protocol instance that this driver is producing.\r
+\r
+  @retval EFI_SUCCESS           The protocol installation is completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  There was not enough memory in pool to install all the protocols.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -276,27 +291,31 @@ EfiLibInstallDriverBindingComponentName2 (
 \r
 \r
 /**\r
-  Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name,\r
-  Component Name 2, Driver Configure, Driver Diagnostic and Driver Diagnostic 2 Protocols onto the driver's\r
-  DriverBindingHandle.  This is typically the same as the driver's ImageHandle, but it can be different if\r
-  the driver produces multiple DriverBinding Protocols. \r
-  If the Drvier Binding Protocol interface is NULL, then ASSERT (). \r
-  If the installation fails, then ASSERT ().\r
+  Installs Driver Binding Protocol with optional Component Name, Component Name 2, Driver\r
+  Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.\r
+\r
+  Initializes a driver by installing the Driver Binding Protocol together with the optional\r
+  Component Name, optional Component Name 2, optional Driver Configuration, optional Driver\r
+  Configuration 2, optional Driver Diagnostic, and optional Driver Diagnostic 2 Protocols\r
+  onto the driver's DriverBindingHandle. DriverBindingHandle is typically the same as the\r
+  driver's ImageHandle, but it can be different if the driver produces multiple Driver Binding Protocols. \r
+  If DriverBinding is NULL, then ASSERT(). \r
+  If the installation fails, then ASSERT().  \r
 \r
-  @param  ImageHandle                 The image handle of the driver.\r
-  @param  SystemTable                 The EFI System Table that was passed to the driver's entry point.\r
-  @param  DriverBinding               A Driver Binding Protocol instance that this driver is producing.\r
-  @param  DriverBindingHandle         The handle that DriverBinding is to be installe onto.  If this\r
-                                      parameter is NULL, then a new handle is created.\r
-  @param  ComponentName               A Component Name Protocol instance that this driver is producing.\r
-  @param  ComponentName2              A Component Name 2 Protocol instance that this driver is producing.\r
-  @param  DriverConfiguration         A Driver Configuration Protocol instance that this driver is producing.\r
-  @param  DriverConfiguration2        A Driver Configuration Protocol 2 instance that this driver is producing.\r
-  @param  DriverDiagnostics           A Driver Diagnostics Protocol instance that this driver is producing.\r
-  @param  DriverDiagnostics2          A Driver Diagnostics Protocol 2 instance that this driver is producing.\r
+  @param  ImageHandle           The image handle of the driver.\r
+  @param  SystemTable           The EFI System Table that was passed to the driver's entry point.\r
+  @param  DriverBinding         A Driver Binding Protocol instance that this driver is producing.\r
+  @param  DriverBindingHandle   The handle that DriverBinding is to be installe onto.  If this\r
+                                parameter is NULL, then a new handle is created.\r
+  @param  ComponentName         A Component Name Protocol instance that this driver is producing.\r
+  @param  ComponentName2        A Component Name 2 Protocol instance that this driver is producing.\r
+  @param  DriverConfiguration   A Driver Configuration Protocol instance that this driver is producing.\r
+  @param  DriverConfiguration2  A Driver Configuration Protocol 2 instance that this driver is producing.\r
+  @param  DriverDiagnostics     A Driver Diagnostics Protocol instance that this driver is producing.\r
+  @param  DriverDiagnostics2    A Driver Diagnostics Protocol 2 instance that this driver is producing.\r
 \r
-  @retval EFI_SUCCESS                 The protocol installation is completed successfully.\r
-  @retval Others                      Status from gBS->InstallMultipleProtocolInterfaces().\r
+  @retval EFI_SUCCESS           The protocol installation is completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  There was not enough memory in pool to install all the protocols.\r
 \r
 **/\r
 EFI_STATUS\r
index 91b37d2ab3b38a1d0d293659ee3bd43b523f602b..e263a06f89b223095c13da3ec4ee2af536251161 100644 (file)
@@ -1,5 +1,9 @@
 /** @file\r
-  Implementation of UefiLib \r
+  The UEFI Library provides functions and macros that simplify the development of \r
+  UEFI Drivers and UEFI Applications.  These functions and macros help manage EFI \r
+  events, build simple locks utilizing EFI Task Priority Levels (TPLs), install \r
+  EFI Driver Model related protocols, manage Unicode string tables for UEFI Drivers, \r
+  and print messages on the console output and standard error devices.\r
 \r
   Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
   All rights reserved. This program and the accompanying materials\r
@@ -12,7 +16,8 @@
 \r
 **/\r
 \r
-#include "FrameworkUefiLib.h"\r
+\r
+#include "UefiLibInternal.h"\r
 \r
 /**\r
   Compare whether two names of languages are identical.\r
@@ -40,10 +45,15 @@ CompareIso639LanguageCode (
 }\r
 \r
 /**\r
-  This function searches the list of configuration tables stored in the EFI System\r
-  Table for a table with a GUID that matches TableGuid.  If a match is found,\r
-  then a pointer to the configuration table is returned in Table, and EFI_SUCCESS\r
-  is returned.  If a matching GUID is not found, then EFI_NOT_FOUND is returned.\r
+  Retrieves a pointer to the system configuration table from the EFI System Table\r
+  based on a specified GUID.\r
+  \r
+  This function searches the list of configuration tables stored in the EFI System Table\r
+  for a table with a GUID that matches TableGuid.  If a match is found, then a pointer to\r
+  the configuration table is returned in Table., and EFI_SUCCESS is returned. If a matching GUID\r
+  is not found, then EFI_NOT_FOUND is returned.\r
+  If TableGuid is NULL, then ASSERT().\r
+  If Table is NULL, then ASSERT().\r
 \r
   @param  TableGuid       Pointer to table's GUID type..\r
   @param  Table           Pointer to the table associated with TableGuid in the EFI System Table.\r
@@ -78,16 +88,26 @@ EfiGetSystemConfigurationTable (
 }\r
 \r
 /**\r
-  This function causes the notification function to be executed for every protocol\r
-  of type ProtocolGuid instance that exists in the system when this function is\r
-  invoked.  In addition, every time a protocol of type ProtocolGuid instance is\r
-  installed or reinstalled, the notification function is also executed.\r
+  Creates and returns a notification event and registers that event with all the protocol\r
+  instances specified by ProtocolGuid.\r
+\r
+  This function causes the notification function to be executed for every protocol of type\r
+  ProtocolGuid instance that exists in the system when this function is invoked.\r
+  In addition, every time a protocol of type ProtocolGuid instance is installed or reinstalled,\r
+  the notification function is also executed.  This function returns the notification event\r
+  that was created. \r
+  If ProtocolGuid is NULL, then ASSERT().\r
+  If NotifyTpl is not a legal TPL value, then ASSERT().\r
+  If NotifyFunction is NULL, then ASSERT().\r
+  If Registration is NULL, then ASSERT().\r
 \r
   @param  ProtocolGuid    Supplies GUID of the protocol upon whose installation the event is fired.\r
   @param  NotifyTpl       Supplies the task priority level of the event notifications.\r
   @param  NotifyFunction  Supplies the function to notify when the event is signaled.\r
   @param  NotifyContext   The context parameter to pass to NotifyFunction.\r
   @param  Registration    A pointer to a memory location to receive the registration value.\r
+                          This value is passed to LocateHandle() to obtain new handles that\r
+                          have been added that support the ProtocolGuid-specified protocol. \r
 \r
   @return The notification event that was created.\r
 \r
@@ -105,6 +125,10 @@ EfiCreateProtocolNotifyEvent(
   EFI_STATUS  Status;\r
   EFI_EVENT   Event;\r
 \r
+  ASSERT (ProtocolGuid != NULL);\r
+  ASSERT (NotifyFunction != NULL);\r
+  ASSERT (Registration != NULL);\r
+\r
   //\r
   // Create the event\r
   //\r
@@ -140,14 +164,19 @@ EfiCreateProtocolNotifyEvent(
 }\r
 \r
 /**\r
+  Creates a named event that can be signaled with EfiNamedEventSignal().\r
+\r
   This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.\r
-  This event is signaled with EfiNamedEventSignal().  This provide the ability for\r
-  one or more listeners on the same event named by the GUID specified by Name.\r
+  This event is signaled with EfiNamedEventSignal(). This provides the ability for one or more\r
+  listeners on the same event named by the GUID specified by Name. \r
+  If Name is NULL, then ASSERT().\r
+  If NotifyTpl is not a legal TPL value, then ASSERT().\r
+  If NotifyFunction is NULL, then ASSERT().\r
 \r
   @param  Name                  Supplies GUID name of the event.\r
   @param  NotifyTpl             Supplies the task priority level of the event notifications.\r
   @param  NotifyFunction        Supplies the function to notify when the event is signaled.\r
-  @param  NotifyContext         The context parameter to pass to NotifyFunction.\r
+  @param  NotifyContext         The context parameter to pass to NotifyFunction. \r
   @param  Registration          A pointer to a memory location to receive the registration value.\r
 \r
   @retval EFI_SUCCESS           A named event was created.\r
@@ -168,6 +197,10 @@ EfiNamedEventListen (
   EFI_EVENT   Event;\r
   VOID        *RegistrationLocal;\r
 \r
+  ASSERT (Name != NULL);\r
+  ASSERT (NotifyFunction != NULL);\r
+  ASSERT (NotifyTpl <= TPL_HIGH_LEVEL);\r
+  \r
   //\r
   // Create event\r
   //\r
@@ -201,12 +234,15 @@ EfiNamedEventListen (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r
 \r
 /**\r
-  This function signals the named event specified by Name.  The named event must\r
-  have been created with EfiNamedEventListen().\r
+  Signals a named event created with EfiNamedEventListen().\r
+\r
+  This function signals the named event specified by Name. The named event must have been\r
+  created with EfiNamedEventListen().\r
+  If Name is NULL, then ASSERT().\r
 \r
   @param  Name                  Supplies GUID name of the event.\r
 \r
@@ -223,6 +259,8 @@ EfiNamedEventSignal (
   EFI_STATUS  Status;\r
   EFI_HANDLE  Handle;\r
 \r
+  ASSERT(Name != NULL);\r
+\r
   Handle = NULL;\r
   Status = gBS->InstallProtocolInterface (\r
                   &Handle,\r
@@ -239,16 +277,16 @@ EfiNamedEventSignal (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r
 \r
-/**\r
+/** \r
   Returns the current TPL.\r
 \r
-  This function returns the current TPL.  There is no EFI service to directly\r
-  retrieve the current TPL. Instead, the RaiseTPL() function is used to raise\r
-  the TPL to TPL_HIGH_LEVEL.  This will return the current TPL.  The TPL level\r
-  can then immediately be restored back to the current TPL level with a call\r
+  This function returns the current TPL.  There is no EFI service to directly \r
+  retrieve the current TPL. Instead, the RaiseTPL() function is used to raise \r
+  the TPL to TPL_HIGH_LEVEL.  This will return the current TPL.  The TPL level \r
+  can then immediately be restored back to the current TPL level with a call \r
   to RestoreTPL().\r
 \r
   @return The current TPL.\r
@@ -270,10 +308,14 @@ EfiGetCurrentTpl (
 \r
 \r
 /**\r
-  This function initializes a basic mutual exclusion lock to the released state\r
-  and returns the lock.  Each lock provides mutual exclusion access at its task\r
+  Initializes a basic mutual exclusion lock.\r
+\r
+  This function initializes a basic mutual exclusion lock to the released state \r
+  and returns the lock.  Each lock provides mutual exclusion access at its task \r
   priority level.  Since there is no preemption or multiprocessor support in EFI,\r
   acquiring the lock only consists of raising to the locks TPL.\r
+  If Lock is NULL, then ASSERT().\r
+  If Priority is not a valid TPL value, then ASSERT().\r
 \r
   @param  Lock       A pointer to the lock data structure to initialize.\r
   @param  Priority   EFI TPL associated with the lock.\r
@@ -298,11 +340,16 @@ EfiInitializeLock (
 }\r
 \r
 /**\r
-  This function raises the system's current task priority level to the task\r
-  priority level of the mutual exclusion lock.  Then, it places the lock in the\r
+  Acquires ownership of a lock.\r
+\r
+  This function raises the system's current task priority level to the task \r
+  priority level of the mutual exclusion lock.  Then, it places the lock in the \r
   acquired state.\r
+  If Lock is NULL, then ASSERT().\r
+  If Lock is not initialized, then ASSERT().\r
+  If Lock is already in the acquired state, then ASSERT().\r
 \r
-  @param  Lock  Point to EFI_LOCK instance\r
+  @param  Lock              A pointer to the lock to acquire.\r
 \r
 **/\r
 VOID\r
@@ -319,9 +366,14 @@ EfiAcquireLock (
 }\r
 \r
 /**\r
-  This function raises the system's current task priority level to the task\r
-  priority level of the mutual exclusion lock.  Then, it attempts to place the\r
-  lock in the acquired state.\r
+  Acquires ownership of a lock.\r
+\r
+  This function raises the system's current task priority level to the task priority\r
+  level of the mutual exclusion lock.  Then, it attempts to place the lock in the acquired state.\r
+  If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.\r
+  Otherwise, EFI_SUCCESS is returned.\r
+  If Lock is NULL, then ASSERT().\r
+  If Lock is not initialized, then ASSERT().\r
 \r
   @param  Lock              A pointer to the lock to acquire.\r
 \r
@@ -354,9 +406,14 @@ EfiAcquireLockOrFail (
 }\r
 \r
 /**\r
-  This function transitions a mutual exclusion lock from the acquired state to\r
-  the released state, and restores the system's task priority level to its\r
+  Releases ownership of a lock.\r
+\r
+  This function transitions a mutual exclusion lock from the acquired state to \r
+  the released state, and restores the system's task priority level to its \r
   previous level.\r
+  If Lock is NULL, then ASSERT().\r
+  If Lock is not initialized, then ASSERT().\r
+  If Lock is already in the released state, then ASSERT().\r
 \r
   @param  Lock  A pointer to the lock to release.\r
 \r
@@ -386,7 +443,7 @@ EfiReleaseLock (
   currently managing the controller specified by ControllerHandle.  This test\r
   is performed by evaluating if the the protocol specified by ProtocolGuid is\r
   present on ControllerHandle and is was opened by DriverBindingHandle with an\r
-  attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.\r
+  attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. \r
   If ProtocolGuid is NULL, then ASSERT().\r
 \r
   @param  ControllerHandle     A handle for a controller to test.\r
@@ -449,10 +506,10 @@ EfiTestManagedDevice (
   ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
   If ProtocolGuid is NULL, then ASSERT().\r
 \r
-  @param  ControllerHandle     A handle for a (parent) controller to test.\r
+  @param  ControllerHandle     A handle for a (parent) controller to test. \r
   @param  ChildHandle          A child handle to test.\r
   @param  ProtocolGuid         Supplies the protocol that the child controller\r
-                               opens on its parent controller.\r
+                               opens on its parent controller. \r
 \r
   @retval EFI_SUCCESS          ChildHandle is a child of the ControllerHandle.\r
   @retval EFI_UNSUPPORTED      ChildHandle is not a child of the\r
@@ -505,31 +562,32 @@ EfiTestChildHandle (
 }\r
 \r
 /**\r
-  This function looks up a Unicode string in UnicodeStringTable.  If Language is\r
-  a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable\r
-  that matches the language code specified by Language, then it is returned in\r
-  UnicodeString.\r
+  This function looks up a Unicode string in UnicodeStringTable.\r
 \r
-  @param  Language                A pointer to the ISO 639-2 language code for the\r
+  If Language is a member of SupportedLanguages and a Unicode string is found in\r
+  UnicodeStringTable that matches the language code specified by Language, then it\r
+  is returned in UnicodeString.\r
+\r
+  @param  Language                A pointer to the ISO 639-2 language code for the \r
                                   Unicode string to look up and return.\r
-  @param  SupportedLanguages      A pointer to the set of ISO 639-2 language codes\r
-                                  that the Unicode string table supports.  Language\r
+  @param  SupportedLanguages      A pointer to the set of ISO 639-2 language codes \r
+                                  that the Unicode string table supports.  Language \r
                                   must be a member of this set.\r
   @param  UnicodeStringTable      A pointer to the table of Unicode strings.\r
   @param  UnicodeString           A pointer to the Unicode string from UnicodeStringTable\r
                                   that matches the language specified by Language.\r
 \r
-  @retval  EFI_SUCCESS            The Unicode string that matches the language\r
+  @retval EFI_SUCCESS             The Unicode string that matches the language \r
                                   specified by Language was found\r
-                                  in the table of Unicoide strings UnicodeStringTable,\r
+                                  in the table of Unicoide strings UnicodeStringTable, \r
                                   and it was returned in UnicodeString.\r
-  @retval  EFI_INVALID_PARAMETER  Language is NULL.\r
-  @retval  EFI_INVALID_PARAMETER  UnicodeString is NULL.\r
-  @retval  EFI_UNSUPPORTED        SupportedLanguages is NULL.\r
-  @retval  EFI_UNSUPPORTED        UnicodeStringTable is NULL.\r
-  @retval  EFI_UNSUPPORTED        The language specified by Language is not a\r
+  @retval EFI_INVALID_PARAMETER   Language is NULL.\r
+  @retval EFI_INVALID_PARAMETER   UnicodeString is NULL.\r
+  @retval EFI_UNSUPPORTED         SupportedLanguages is NULL.\r
+  @retval EFI_UNSUPPORTED         UnicodeStringTable is NULL.\r
+  @retval EFI_UNSUPPORTED         The language specified by Language is not a \r
                                   member of SupportedLanguages.\r
-  @retval  EFI_UNSUPPORTED        The language specified by Language is not\r
+  @retval EFI_UNSUPPORTED         The language specified by Language is not \r
                                   supported by UnicodeStringTable.\r
 \r
 **/\r
@@ -588,15 +646,138 @@ LookupUnicodeString (
   return EFI_UNSUPPORTED;\r
 }\r
 \r
+\r
+\r
+/**\r
+  This function looks up a Unicode string in UnicodeStringTable.\r
+\r
+  If Language is a member of SupportedLanguages and a Unicode string is found in\r
+  UnicodeStringTable that matches the language code specified by Language, then\r
+  it is returned in UnicodeString.\r
+\r
+  @param  Language             A pointer to an ASCII string containing the ISO 639-2 or the\r
+                               RFC 4646 language code for the Unicode string to look up and\r
+                               return. If Iso639Language is TRUE, then this ASCII string is\r
+                               not assumed to be Null-terminated, and only the first three\r
+                               chacters are used. If Iso639Language is FALSE, then this ASCII\r
+                               string must be Null-terminated. \r
+  @param  SupportedLanguages   A pointer to a Null-terminated ASCII string that contains a\r
+                               set of ISO 639-2 or RFC 4646 language codes that the Unicode\r
+                               string table supports.  Language must be a member of this set.\r
+                               If Iso639Language is TRUE, then this string contains one or more\r
+                               ISO 639-2 language codes with no separator characters. If Iso639Language\r
+                               is FALSE, then is string contains one or more RFC 4646 language\r
+                               codes separated by ';'.\r
+  @param  UnicodeStringTable   A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE\r
+                               is defined in "Related Definitions".\r
+  @param  UnicodeString        A pointer to the Null-terminated Unicode string from UnicodeStringTable\r
+                               that matches the language specified by Language.\r
+  @param  Iso639Language       Specifies the supported language code format. If it is TRUE, then\r
+                               Language and SupportedLanguages follow ISO 639-2 language code format.\r
+                               Otherwise, they follow RFC 4646 language code format.\r
+\r
+\r
+  @retval  EFI_SUCCESS            The Unicode string that matches the language specified by Language\r
+                                  was found in the table of Unicode strings UnicodeStringTable, and\r
+                                  it was returned in UnicodeString.\r
+  @retval  EFI_INVALID_PARAMETER  Language is NULL.  \r
+  @retval  EFI_INVALID_PARAMETER  UnicodeString is NULL.  \r
+  @retval  EFI_UNSUPPORTED        SupportedLanguages is NULL.  \r
+  @retval  EFI_UNSUPPORTED        UnicodeStringTable is NULL.  \r
+  @retval  EFI_UNSUPPORTED        The language specified by Language is not a member of SupportedLanguages.  \r
+  @retval  EFI_UNSUPPORTED        The language specified by Language is not supported by UnicodeStringTable.\r
+\r
+**/\r
+EFI_STATUS\r
+\r
+EFIAPI\r
+LookupUnicodeString2 (\r
+  IN CONST CHAR8                     *Language,\r
+  IN CONST CHAR8                     *SupportedLanguages,\r
+  IN CONST EFI_UNICODE_STRING_TABLE  *UnicodeStringTable,\r
+  OUT CHAR16                         **UnicodeString,\r
+  IN BOOLEAN                         Iso639Language\r
+  )\r
+{\r
+  BOOLEAN   Found;\r
+  UINTN     Index;\r
+  CHAR8     *LanguageString;\r
+\r
+  //\r
+  // Make sure the parameters are valid\r
+  //\r
+  if (Language == NULL || UnicodeString == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // If there are no supported languages, or the Unicode String Table is empty, then the\r
+  // Unicode String specified by Language is not supported by this Unicode String Table\r
+  //\r
+  if (SupportedLanguages == NULL || UnicodeStringTable == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Make sure Language is in the set of Supported Languages\r
+  //\r
+  Found = FALSE;\r
+  while (*SupportedLanguages != 0) {\r
+    if (Iso639Language) {\r
+      if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
+        Found = TRUE;\r
+        break;\r
+      }\r
+      SupportedLanguages += 3;\r
+    } else {\r
+      for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);\r
+      if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {\r
+        Found = TRUE;\r
+        break;\r
+      }\r
+      SupportedLanguages += Index;\r
+      for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);\r
+    }\r
+  }\r
+\r
+  //\r
+  // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED\r
+  //\r
+  if (!Found) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Search the Unicode String Table for the matching Language specifier\r
+  //\r
+  while (UnicodeStringTable->Language != NULL) {\r
+    LanguageString = UnicodeStringTable->Language;\r
+    while (0 != *LanguageString) {\r
+      for (Index = 0 ;LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++);\r
+      if (AsciiStrnCmp(LanguageString, Language, Index) == 0) {\r
+        *UnicodeString = UnicodeStringTable->UnicodeString;\r
+        return EFI_SUCCESS;\r
+      }\r
+      LanguageString += Index;\r
+      for (Index = 0 ;LanguageString[Index] != 0 && LanguageString[Index] == ';'; Index++);\r
+    }\r
+    UnicodeStringTable++;\r
+  }\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
 /**\r
   This function adds a Unicode string to UnicodeStringTable.\r
-  If Language is a member of SupportedLanguages then UnicodeString is added to\r
-  UnicodeStringTable.  New buffers are allocated for both Language and\r
-  UnicodeString.  The contents of Language and UnicodeString are copied into\r
-  these new buffers.  These buffers are automatically freed when\r
+\r
+  If Language is a member of SupportedLanguages then UnicodeString is added to \r
+  UnicodeStringTable.  New buffers are allocated for both Language and \r
+  UnicodeString.  The contents of Language and UnicodeString are copied into \r
+  these new buffers.  These buffers are automatically freed when \r
   FreeUnicodeStringTable() is called.\r
 \r
-  @param  Language                A pointer to the ISO 639-2 language code for the Unicode\r
+  @param  Language                A pointer to the ISO 639-2 language code for the Unicode \r
                                   string to add.\r
   @param  SupportedLanguages      A pointer to the set of ISO 639-2 language codes\r
                                   that the Unicode string table supports.\r
@@ -604,19 +785,19 @@ LookupUnicodeString (
   @param  UnicodeStringTable      A pointer to the table of Unicode strings.\r
   @param  UnicodeString           A pointer to the Unicode string to add.\r
 \r
-  @retval EFI_SUCCESS             The Unicode string that matches the language\r
-                                  specified by Language was found in the table of\r
-                                  Unicode strings UnicodeStringTable, and it was\r
+  @retval EFI_SUCCESS             The Unicode string that matches the language \r
+                                  specified by Language was found in the table of \r
+                                  Unicode strings UnicodeStringTable, and it was \r
                                   returned in UnicodeString.\r
   @retval EFI_INVALID_PARAMETER   Language is NULL.\r
   @retval EFI_INVALID_PARAMETER   UnicodeString is NULL.\r
   @retval EFI_INVALID_PARAMETER   UnicodeString is an empty string.\r
   @retval EFI_UNSUPPORTED         SupportedLanguages is NULL.\r
-  @retval EFI_ALREADY_STARTED     A Unicode string with language Language is\r
+  @retval EFI_ALREADY_STARTED     A Unicode string with language Language is \r
                                   already present in UnicodeStringTable.\r
-  @retval EFI_OUT_OF_RESOURCES    There is not enough memory to add another\r
+  @retval EFI_OUT_OF_RESOURCES    There is not enough memory to add another \r
                                   Unicode string to UnicodeStringTable.\r
-  @retval EFI_UNSUPPORTED         The language specified by Language is not a\r
+  @retval EFI_UNSUPPORTED         The language specified by Language is not a \r
                                   member of SupportedLanguages.\r
 \r
 **/\r
@@ -754,10 +935,212 @@ AddUnicodeString (
   return EFI_UNSUPPORTED;\r
 }\r
 \r
+\r
+/**\r
+  This function adds the Null-terminated Unicode string specified by UnicodeString\r
+  to UnicodeStringTable.\r
+\r
+  If Language is a member of SupportedLanguages then UnicodeString is added to\r
+  UnicodeStringTable.  New buffers are allocated for both Language and UnicodeString.\r
+  The contents of Language and UnicodeString are copied into these new buffers.\r
+  These buffers are automatically freed when EfiLibFreeUnicodeStringTable() is called.\r
+\r
+  @param  Language            A pointer to an ASCII string containing the ISO 639-2 or\r
+                              the RFC 4646 language code for the Unicode string to add.\r
+                              If Iso639Language is TRUE, then this ASCII string is not\r
+                              assumed to be Null-terminated, and only the first three\r
+                              chacters are used. If Iso639Language is FALSE, then this\r
+                              ASCII string must be Null-terminated.\r
+  @param  SupportedLanguages  A pointer to a Null-terminated ASCII string that contains\r
+                              a set of ISO 639-2 or RFC 4646 language codes that the Unicode\r
+                              string table supports.  Language must be a member of this set.\r
+                              If Iso639Language is TRUE, then this string contains one or more\r
+                              ISO 639-2 language codes with no separator characters.\r
+                              If Iso639Language is FALSE, then is string contains one or more\r
+                              RFC 4646 language codes separated by ';'.\r
+  @param  UnicodeStringTable  A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE\r
+                              is defined in "Related Definitions".\r
+  @param  UnicodeString       A pointer to the Unicode string to add.  \r
+  @param  Iso639Language      Specifies the supported language code format. If it is TRUE,\r
+                              then Language and SupportedLanguages follow ISO 639-2 language code format.\r
+                              Otherwise, they follow RFC 4646 language code format.\r
+\r
+  @retval EFI_SUCCESS            The Unicode string that matches the language specified by\r
+                                 Language was found in the table of Unicode strings UnicodeStringTable,\r
+                                 and it was returned in UnicodeString.  \r
+  @retval EFI_INVALID_PARAMETER  Language is NULL.  \r
+  @retval EFI_INVALID_PARAMETER  UnicodeString is NULL.  \r
+  @retval EFI_INVALID_PARAMETER  UnicodeString is an empty string.  \r
+  @retval EFI_UNSUPPORTED        SupportedLanguages is NULL.  \r
+  @retval EFI_ALREADY_STARTED    A Unicode string with language Language is already present in\r
+                                 UnicodeStringTable.  \r
+  @retval EFI_OUT_OF_RESOURCES   There is not enough memory to add another Unicode string UnicodeStringTable.  \r
+  @retval EFI_UNSUPPORTED        The language specified by Language is not a member of SupportedLanguages.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AddUnicodeString2 (\r
+  IN CONST CHAR8               *Language,\r
+  IN CONST CHAR8               *SupportedLanguages,\r
+  IN EFI_UNICODE_STRING_TABLE  **UnicodeStringTable,\r
+  IN CONST CHAR16              *UnicodeString,\r
+  IN BOOLEAN                   Iso639Language\r
+  )\r
+{\r
+  UINTN                     NumberOfEntries;\r
+  EFI_UNICODE_STRING_TABLE  *OldUnicodeStringTable;\r
+  EFI_UNICODE_STRING_TABLE  *NewUnicodeStringTable;\r
+  UINTN                     UnicodeStringLength;\r
+  BOOLEAN                   Found;\r
+  UINTN                     Index;\r
+  CHAR8                     *LanguageString;\r
+\r
+  //\r
+  // Make sure the parameter are valid\r
+  //\r
+  if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // If there are no supported languages, then a Unicode String can not be added\r
+  //\r
+  if (SupportedLanguages == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // If the Unicode String is empty, then a Unicode String can not be added\r
+  //\r
+  if (UnicodeString[0] == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Make sure Language is a member of SupportedLanguages\r
+  //\r
+  Found = FALSE;\r
+  while (*SupportedLanguages != 0) {\r
+    if (Iso639Language) {\r
+      if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
+        Found = TRUE;\r
+        break;\r
+      }\r
+      SupportedLanguages += 3;\r
+    } else {\r
+      for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);\r
+      if (AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) {\r
+        Found = TRUE;\r
+        break;\r
+      }\r
+      SupportedLanguages += Index;\r
+      for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);\r
+    }\r
+  }\r
+\r
+  //\r
+  // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED\r
+  //\r
+  if (!Found) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Determine the size of the Unicode String Table by looking for a NULL Language entry\r
+  //\r
+  NumberOfEntries = 0;\r
+  if (*UnicodeStringTable != NULL) {\r
+    OldUnicodeStringTable = *UnicodeStringTable;\r
+    while (OldUnicodeStringTable->Language != NULL) {\r
+      LanguageString = OldUnicodeStringTable->Language;\r
+\r
+      while (*LanguageString != 0) {\r
+        for (Index = 0; LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++);\r
+\r
+        if (AsciiStrnCmp (Language, LanguageString, Index) == 0) { \r
+          return EFI_ALREADY_STARTED;\r
+        }\r
+        LanguageString += Index;\r
+        for (; *LanguageString != 0 && *LanguageString == ';'; LanguageString++);\r
+      }\r
+      OldUnicodeStringTable++;\r
+      NumberOfEntries++;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Allocate space for a new Unicode String Table.  It must hold the current number of\r
+  // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table\r
+  // marker\r
+  //\r
+  NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE));\r
+  if (NewUnicodeStringTable == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // If the current Unicode String Table contains any entries, then copy them to the\r
+  // newly allocated Unicode String Table.\r
+  //\r
+  if (*UnicodeStringTable != NULL) {\r
+    CopyMem (\r
+      NewUnicodeStringTable,\r
+      *UnicodeStringTable,\r
+      NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE)\r
+      );\r
+  }\r
+\r
+  //\r
+  // Allocate space for a copy of the Language specifier\r
+  //\r
+  NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (AsciiStrSize(Language), Language);\r
+  if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {\r
+    gBS->FreePool (NewUnicodeStringTable);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // Compute the length of the Unicode String\r
+  //\r
+  for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++);\r
+\r
+  //\r
+  // Allocate space for a copy of the Unicode String\r
+  //\r
+  NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool (StrSize (UnicodeString), UnicodeString);\r
+  if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) {\r
+    gBS->FreePool (NewUnicodeStringTable[NumberOfEntries].Language);\r
+    gBS->FreePool (NewUnicodeStringTable);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // Mark the end of the Unicode String Table\r
+  //\r
+  NewUnicodeStringTable[NumberOfEntries + 1].Language       = NULL;\r
+  NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString  = NULL;\r
+\r
+  //\r
+  // Free the old Unicode String Table\r
+  //\r
+  if (*UnicodeStringTable != NULL) {\r
+    gBS->FreePool (*UnicodeStringTable);\r
+  }\r
+\r
+  //\r
+  // Point UnicodeStringTable at the newly allocated Unicode String Table\r
+  //\r
+  *UnicodeStringTable = NewUnicodeStringTable;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   This function frees the table of Unicode strings in UnicodeStringTable.\r
+\r
   If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.\r
-  Otherwise, each language code, and each Unicode string in the Unicode string\r
+  Otherwise, each language code, and each Unicode string in the Unicode string \r
   table are freed, and EFI_SUCCESS is returned.\r
 \r
   @param  UnicodeStringTable  A pointer to the table of Unicode strings.\r
@@ -805,4 +1188,3 @@ FreeUnicodeStringTable (
 \r
   return EFI_SUCCESS;\r
 }\r
-\r
diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h
new file mode 100644 (file)
index 0000000..e8aed5b
--- /dev/null
@@ -0,0 +1,44 @@
+/** @file\r
+  Internal include file for UefiLib.\r
+\r
+  Copyright (c) 2007 - 2008, Intel Corporation.<BR>\r
+  All rights reserved. This program and the accompanying materials\r
+   are licensed and made available under the terms and conditions of the BSD License\r
+   which accompanies this distribution. The full text of the license may be found at\r
+   http://opensource.org/licenses/bsd-license.php\r
+   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __UEFI_LIB_INTERNAL_H_\r
+#define __UEFI_LIB_INTERNAL_H_\r
+\r
+\r
+#include <Uefi.h>\r
+#include <FrameworkDxe.h>\r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/ComponentName2.h>\r
+#include <Protocol/DriverConfiguration.h>\r
+#include <Protocol/DriverConfiguration2.h>\r
+#include <Protocol/DriverDiagnostics.h>\r
+#include <Protocol/DriverDiagnostics2.h>\r
+#include <Protocol/LoadedImage.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Protocol/UgaDraw.h>\r
+#include <Protocol/HiiFont.h>\r
+\r
+#include <Guid/EventGroup.h>\r
+#include <Guid/EventLegacyBios.h>\r
+#include <Guid/FrameworkDevicePath.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+#endif\r
index 39718517d12128aa181258a202d9a01f7757cf7b..247838023270ecf767be93f456cb4ea382ce1d1f 100644 (file)
 \r
 **/\r
 \r
-#include "FrameworkUefiLib.h"\r
+#include "UefiLibInternal.h"\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {\r
+  { 0x00, 0x00, 0x00, 0x00 },\r
+  { 0x98, 0x00, 0x00, 0x00 },\r
+  { 0x00, 0x98, 0x00, 0x00 },\r
+  { 0x98, 0x98, 0x00, 0x00 },\r
+  { 0x00, 0x00, 0x98, 0x00 },\r
+  { 0x98, 0x00, 0x98, 0x00 },\r
+  { 0x00, 0x98, 0x98, 0x00 },\r
+  { 0x98, 0x98, 0x98, 0x00 },\r
+  { 0x10, 0x10, 0x10, 0x00 },\r
+  { 0xff, 0x10, 0x10, 0x00 },\r
+  { 0x10, 0xff, 0x10, 0x00 },\r
+  { 0xff, 0xff, 0x10, 0x00 },\r
+  { 0x10, 0x10, 0xff, 0x00 },\r
+  { 0xf0, 0x10, 0xff, 0x00 },\r
+  { 0x10, 0xff, 0xff, 0x00 },\r
+  { 0xff, 0xff, 0xff, 0x00 }\r
+};\r
 \r
 /**\r
   Internal function which prints a formatted Unicode string to the console output device\r
   specified by Console and returns the number of Unicode characters that printed\r
   to it.  If the length of the formatted Unicode string is greater than PcdUefiLibMaxPrintBufferSize,\r
   then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
 \r
   @param Format   Null-terminated Unicode format string.\r
   @param Console  The output console.\r
   @param Marker   VA_LIST marker for the variable argument list.\r
-\r
-  If Format is NULL, then ASSERT().\r
-  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
-\r
+  \r
+  @return The number of Unicode characters in the produced\r
+          output buffer not including the Null-terminator.\r
 **/\r
-\r
 UINTN\r
 InternalPrint (\r
   IN  CONST CHAR16                     *Format,\r
@@ -45,7 +64,7 @@ InternalPrint (
   UINTN   BufferSize;\r
 \r
   ASSERT (Format != NULL);\r
-  ASSERT (((UINTN) Format & 0x01) == 0);\r
+  ASSERT (((UINTN) Format & BIT0) == 0);\r
 \r
   BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
 \r
@@ -54,7 +73,7 @@ InternalPrint (
 \r
   Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
 \r
-  if (Console != NULL) {\r
+  if (Console != NULL && Return > 0) {\r
     //\r
     // To be extra safe make sure Console has been initialized\r
     //\r
@@ -66,21 +85,23 @@ InternalPrint (
   return Return;\r
 }\r
 \r
-/**\r
-  Prints a formatted Unicode string to the console output device specified by\r
+/** \r
+  Prints a formatted Unicode string to the console output device specified by \r
   ConOut defined in the EFI_SYSTEM_TABLE.\r
 \r
-  This function prints a formatted Unicode string to the console output device\r
-  specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode\r
-  characters that printed to ConOut.  If the length of the formatted Unicode\r
-  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
+  This function prints a formatted Unicode string to the console output device \r
+  specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode \r
+  characters that printed to ConOut.  If the length of the formatted Unicode \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
   PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
 \r
   @param Format   Null-terminated Unicode format string.\r
   @param ...      Variable argument list whose contents are accessed based \r
                   on the format string specified by Format.\r
-  If Format is NULL, then ASSERT().\r
-  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+  \r
+  @return Number of Unicode characters printed to ConOut.\r
 \r
 **/\r
 UINTN\r
@@ -102,24 +123,25 @@ Print (
   return Return;\r
 }\r
 \r
-/**\r
-  Prints a formatted Unicode string to the console output device specified by\r
+/** \r
+  Prints a formatted Unicode string to the console output device specified by \r
   StdErr defined in the EFI_SYSTEM_TABLE.\r
 \r
-  This function prints a formatted Unicode string to the console output device\r
-  specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode\r
-  characters that printed to StdErr.  If the length of the formatted Unicode\r
-  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
+  This function prints a formatted Unicode string to the console output device \r
+  specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode \r
+  characters that printed to StdErr.  If the length of the formatted Unicode \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
   PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
 \r
   @param Format   Null-terminated Unicode format string.\r
   @param ...      Variable argument list whose contents are accessed based \r
                   on the format string specified by Format.\r
-  If Format is NULL, then ASSERT().\r
-  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+  \r
+  @return Number of Unicode characters printed to StdErr.\r
 \r
 **/\r
-\r
 UINTN\r
 EFIAPI\r
 ErrorPrint (\r
@@ -149,14 +171,16 @@ ErrorPrint (
   to it.  If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize,\r
   then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r
 \r
+  If Format is NULL, then ASSERT().\r
+\r
   @param Format   Null-terminated ASCII format string.\r
   @param Console  The output console.\r
   @param Marker   VA_LIST marker for the variable argument list.\r
 \r
-  If Format is NULL, then ASSERT().\r
+  @return The number of Unicode characters in the produced\r
+          output buffer not including the Null-terminator.\r
 \r
 **/\r
-\r
 UINTN\r
 AsciiInternalPrint (\r
   IN  CONST CHAR8                      *Format,\r
@@ -189,21 +213,22 @@ AsciiInternalPrint (
   return Return;\r
 }\r
 \r
-/**\r
-  Prints a formatted ASCII string to the console output device specified by\r
+/** \r
+  Prints a formatted ASCII string to the console output device specified by \r
   ConOut defined in the EFI_SYSTEM_TABLE.\r
 \r
-  This function prints a formatted ASCII string to the console output device\r
-  specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII\r
-  characters that printed to ConOut.  If the length of the formatted ASCII\r
-  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
+  This function prints a formatted ASCII string to the console output device \r
+  specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII \r
+  characters that printed to ConOut.  If the length of the formatted ASCII \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
   PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
+  If Format is NULL, then ASSERT().\r
 \r
   @param Format   Null-terminated ASCII format string.\r
   @param ...      Variable argument list whose contents are accessed based \r
                   on the format string specified by Format.\r
-  If Format is NULL, then ASSERT().\r
-  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+  \r
+  @return Number of ASCII characters printed to ConOut.\r
 \r
 **/\r
 UINTN\r
@@ -215,7 +240,8 @@ AsciiPrint (
 {\r
   VA_LIST Marker;\r
   UINTN   Return;\r
-\r
+  ASSERT (Format != NULL);\r
+  \r
   VA_START (Marker, Format);\r
 \r
   Return = AsciiInternalPrint( Format, gST->ConOut, Marker);\r
@@ -225,21 +251,22 @@ AsciiPrint (
   return Return;\r
 }\r
 \r
-/**\r
-  Prints a formatted ASCII string to the console output device specified by\r
+/** \r
+  Prints a formatted ASCII string to the console output device specified by \r
   StdErr defined in the EFI_SYSTEM_TABLE.\r
 \r
-  This function prints a formatted ASCII string to the console output device\r
-  specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII\r
-  characters that printed to StdErr.  If the length of the formatted ASCII\r
-  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
+  This function prints a formatted ASCII string to the console output device \r
+  specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII \r
+  characters that printed to StdErr.  If the length of the formatted ASCII \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
   PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
+  If Format is NULL, then ASSERT().\r
 \r
   @param Format   Null-terminated ASCII format string.\r
   @param ...      Variable argument list whose contents are accessed based \r
                   on the format string specified by Format.\r
-  If Format is NULL, then ASSERT().\r
-  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+  \r
+  @return Number of ASCII characters printed to ConErr.\r
 \r
 **/\r
 UINTN\r
@@ -252,6 +279,8 @@ AsciiErrorPrint (
   VA_LIST Marker;\r
   UINTN   Return;\r
 \r
+  ASSERT (Format != NULL);\r
+  \r
   VA_START (Marker, Format);\r
 \r
   Return = AsciiInternalPrint( Format, gST->StdErr, Marker);\r
@@ -261,3 +290,388 @@ AsciiErrorPrint (
   return Return;\r
 }\r
 \r
+/**\r
+  Internal function to print a formatted Unicode string to a graphics console device specified by \r
+  ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.\r
+\r
+  This function prints a formatted Unicode string to the graphics console device \r
+  specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of \r
+  Unicode characters printed. The EFI_HII_FONT_PROTOCOL is used to convert the \r
+  string to a bitmap using the glyphs registered with the \r
+  HII database.  No wrapping is performed, so any portions of the string the fall\r
+  outside the active display region will not be displayed.\r
+\r
+  If a graphics console device is not associated with the ConsoleOutputHandle \r
+  defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.\r
+  If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no \r
+  string is printed, and 0 is returned.\r
+\r
+  @param  X            X coordinate to print the string.\r
+  @param  Y            Y coordinate to print the string.\r
+  @param  ForeGround   The forground color of the string being printed.  This is\r
+                       an optional parameter that may be NULL.  If it is NULL,\r
+                       then the foreground color of the current ConOut device\r
+                       in the EFI_SYSTEM_TABLE is used.\r
+  @param  BackGround   The background color of the string being printed.  This is\r
+                       an optional parameter that may be NULL.  If it is NULL, \r
+                       then the background color of the current ConOut device\r
+                       in the EFI_SYSTEM_TABLE is used.\r
+  @param  Buffer       Null-terminated Unicode formatted string.\r
+  @param  PrintNum     The number of Unicode formatted string to be printed.\r
+\r
+  @return  Number of Unicode Characters printed. Zero means no any character \r
+           displayed successfully.\r
+\r
+**/\r
+UINTN\r
+InternalPrintGraphic (\r
+  IN UINTN                            X,\r
+  IN UINTN                            Y,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Foreground,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Background,\r
+  IN CHAR16                           *Buffer,\r
+  IN UINTN                            PrintNum\r
+  )\r
+{\r
+  EFI_STATUS                          Status;\r
+  UINTN                               Index;\r
+  CHAR16                              *UnicodeWeight;\r
+  UINT32                              HorizontalResolution;\r
+  UINT32                              VerticalResolution;\r
+  UINT32                              ColorDepth;\r
+  UINT32                              RefreshRate;\r
+  UINTN                               LineBufferLen;\r
+  EFI_HII_FONT_PROTOCOL               *HiiFont;\r
+  EFI_IMAGE_OUTPUT                    *Blt;\r
+  EFI_FONT_DISPLAY_INFO               FontInfo;\r
+  EFI_HII_ROW_INFO                    *RowInfoArray;\r
+  UINTN                               RowInfoArraySize;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL        *GraphicsOutput;\r
+  EFI_UGA_DRAW_PROTOCOL               *UgaDraw;\r
+  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL     *Sto;\r
+  EFI_HANDLE                          ConsoleHandle;\r
+\r
+  HorizontalResolution  = 0;\r
+  VerticalResolution    = 0;\r
+  Blt                   = NULL;\r
+\r
+  ConsoleHandle = gST->ConsoleOutHandle;\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  ConsoleHandle,\r
+                  &gEfiGraphicsOutputProtocolGuid,\r
+                  (VOID **) &GraphicsOutput\r
+                  );\r
+\r
+  UgaDraw = NULL;\r
+  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+    //\r
+    // If no GOP available, try to open UGA Draw protocol if supported.\r
+    //\r
+    GraphicsOutput = NULL;\r
+\r
+    Status = gBS->HandleProtocol (\r
+                    ConsoleHandle,\r
+                    &gEfiUgaDrawProtocolGuid,\r
+                    (VOID **) &UgaDraw\r
+                    );\r
+  }\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  ConsoleHandle,\r
+                  &gEfiSimpleTextOutProtocolGuid,\r
+                  (VOID **) &Sto\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  if (GraphicsOutput != NULL) {\r
+    HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
+    VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
+  } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+    UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
+  } else {\r
+    Status = EFI_UNSUPPORTED;\r
+    goto Error;\r
+  }\r
+\r
+  ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));\r
+\r
+  Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Error;\r
+  }\r
+\r
+  UnicodeWeight = Buffer;\r
+\r
+  for (Index = 0; UnicodeWeight[Index] != 0; Index++) {\r
+    if (UnicodeWeight[Index] == CHAR_BACKSPACE ||\r
+        UnicodeWeight[Index] == CHAR_LINEFEED  ||\r
+        UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {\r
+      UnicodeWeight[Index] = 0;\r
+    }\r
+  }\r
+\r
+  LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT;\r
+  if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * PrintNum > LineBufferLen) {\r
+     Status = EFI_INVALID_PARAMETER;\r
+     goto Error;\r
+  }\r
+\r
+  Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));\r
+  ASSERT (Blt != NULL);\r
+\r
+  Blt->Width        = (UINT16) (HorizontalResolution);\r
+  Blt->Height       = (UINT16) (VerticalResolution);\r
+\r
+  ZeroMem (&FontInfo, sizeof (EFI_FONT_DISPLAY_INFO));\r
+\r
+  if (Foreground != NULL) {\r
+    CopyMem (&FontInfo.ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+  } else {\r
+    CopyMem (\r
+      &FontInfo.ForegroundColor,\r
+      &mEfiColors[Sto->Mode->Attribute & 0x0f],\r
+      sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+      );\r
+  }\r
+  if (Background != NULL) {\r
+    CopyMem (&FontInfo.BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+  } else {\r
+    CopyMem (\r
+      &FontInfo.BackgroundColor,\r
+      &mEfiColors[Sto->Mode->Attribute >> 4],\r
+      sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+      );\r
+  }\r
+\r
+  if (GraphicsOutput != NULL) {\r
+    Blt->Image.Screen = GraphicsOutput;\r
+    \r
+    Status = HiiFont->StringToImage (\r
+                         HiiFont,\r
+                         EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,\r
+                         Buffer,\r
+                         &FontInfo,\r
+                         &Blt,\r
+                         X,\r
+                         Y,\r
+                         NULL,\r
+                         NULL,\r
+                         NULL\r
+                         );\r
+\r
+  } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+    ASSERT (UgaDraw!= NULL);\r
+\r
+    Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+    ASSERT (Blt->Image.Bitmap != NULL);\r
+\r
+    RowInfoArray = NULL;\r
+    //\r
+    //  StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,\r
+    //  we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.\r
+    //\r
+    Status = HiiFont->StringToImage (\r
+                         HiiFont,\r
+                         EFI_HII_IGNORE_IF_NO_GLYPH,\r
+                         Buffer,\r
+                         &FontInfo,\r
+                         &Blt,\r
+                         X,\r
+                         Y,\r
+                         &RowInfoArray,\r
+                         &RowInfoArraySize,\r
+                         NULL\r
+                         );\r
+\r
+    if (!EFI_ERROR (Status)) {\r
+      ASSERT (RowInfoArray != NULL);\r
+      //\r
+      // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will\r
+      // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.\r
+      //\r
+      ASSERT (RowInfoArraySize <= 1);\r
+\r
+      Status = UgaDraw->Blt (\r
+                          UgaDraw,\r
+                          (EFI_UGA_PIXEL *) Blt->Image.Bitmap,\r
+                          EfiUgaBltBufferToVideo,\r
+                          X,\r
+                          Y,\r
+                          X,\r
+                          Y,\r
+                          RowInfoArray[0].LineWidth,\r
+                          RowInfoArray[0].LineHeight,\r
+                          Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+                          );\r
+    }\r
+\r
+    FreePool (RowInfoArray);\r
+    FreePool (Blt->Image.Bitmap);\r
+\r
+  } else {\r
+    Status = EFI_UNSUPPORTED;\r
+  }\r
+\r
+  FreePool (Blt);\r
+\r
+Error:\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  } else {\r
+    return PrintNum;\r
+  }\r
+}\r
+\r
+/**\r
+  Prints a formatted Unicode string to a graphics console device specified by \r
+  ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.\r
+\r
+  This function prints a formatted Unicode string to the graphics console device \r
+  specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of \r
+  Unicode characters printed.  If the length of the formatted Unicode string is\r
+  greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+  PcdUefiLibMaxPrintBufferSize characters are printed.  The EFI_HII_FONT_PROTOCOL\r
+  is used to convert the string to a bitmap using the glyphs registered with the \r
+  HII database.  No wrapping is performed, so any portions of the string the fall\r
+  outside the active display region will not be displayed.\r
+\r
+  If a graphics console device is not associated with the ConsoleOutputHandle \r
+  defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.\r
+  If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no \r
+  string is printed, and 0 is returned.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  X            X coordinate to print the string.\r
+  @param  Y            Y coordinate to print the string.\r
+  @param  ForeGround   The forground color of the string being printed.  This is\r
+                       an optional parameter that may be NULL.  If it is NULL,\r
+                       then the foreground color of the current ConOut device\r
+                       in the EFI_SYSTEM_TABLE is used.\r
+  @param  BackGround   The background color of the string being printed.  This is\r
+                       an optional parameter that may be NULL.  If it is NULL, \r
+                       then the background color of the current ConOut device\r
+                       in the EFI_SYSTEM_TABLE is used.\r
+  @param  Format       Null-terminated Unicode format string.  See Print Library \r
+                       for the supported format string syntax.\r
+  @param  ...          Variable argument list whose contents are accessed based on \r
+                       the format string specified by Format.         \r
+\r
+  @return  The number of Unicode characters printed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PrintXY (\r
+  IN UINTN                            X,\r
+  IN UINTN                            Y,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *ForeGround, OPTIONAL\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *BackGround, OPTIONAL\r
+  IN CONST CHAR16                     *Format,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST                             Marker;\r
+  CHAR16                              *Buffer;\r
+  UINTN                               BufferSize;\r
+  UINTN                               PrintNum;\r
+  UINTN                               ReturnNum;\r
+\r
+  ASSERT (Format != NULL);\r
+  ASSERT (((UINTN) Format & BIT0) == 0);\r
+\r
+  VA_START (Marker, Format);\r
+\r
+  BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
+\r
+  Buffer = (CHAR16 *) AllocatePool (BufferSize);\r
+  ASSERT (Buffer != NULL);\r
+    \r
+  PrintNum = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
+\r
+  ReturnNum = InternalPrintGraphic (X, Y, ForeGround, BackGround, Buffer, PrintNum);\r
+\r
+  FreePool (Buffer);\r
+\r
+  return ReturnNum;\r
+}\r
+\r
+/**\r
+  Prints a formatted ASCII string to a graphics console device specified by \r
+  ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.\r
+\r
+  This function prints a formatted ASCII string to the graphics console device \r
+  specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of \r
+  ASCII characters printed.  If the length of the formatted ASCII string is\r
+  greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+  PcdUefiLibMaxPrintBufferSize characters are printed.  The EFI_HII_FONT_PROTOCOL\r
+  is used to convert the string to a bitmap using the glyphs registered with the \r
+  HII database.  No wrapping is performed, so any portions of the string the fall\r
+  outside the active display region will not be displayed.\r
+\r
+  If a graphics console device is not associated with the ConsoleOutputHandle \r
+  defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.\r
+  If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no \r
+  string is printed, and 0 is returned.\r
+  If Format is NULL, then ASSERT().\r
+\r
+  @param  X            X coordinate to print the string.\r
+  @param  Y            Y coordinate to print the string.\r
+  @param  ForeGround   The forground color of the string being printed.  This is\r
+                       an optional parameter that may be NULL.  If it is NULL,\r
+                       then the foreground color of the current ConOut device\r
+                       in the EFI_SYSTEM_TABLE is used.\r
+  @param  BackGround   The background color of the string being printed.  This is\r
+                       an optional parameter that may be NULL.  If it is NULL, \r
+                       then the background color of the current ConOut device\r
+                       in the EFI_SYSTEM_TABLE is used.\r
+  @param  Format       Null-terminated ASCII format string.  See Print Library \r
+                       for the supported format string syntax.\r
+  @param  ...          Variable argument list whose contents are accessed based on \r
+                       the format string specified by Format.         \r
+\r
+  @return  The number of ASCII characters printed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiPrintXY (\r
+  IN UINTN                            X,\r
+  IN UINTN                            Y,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *ForeGround, OPTIONAL\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *BackGround, OPTIONAL\r
+  IN CONST CHAR8                      *Format,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST                             Marker;\r
+  CHAR16                              *Buffer;\r
+  UINTN                               BufferSize;\r
+  UINTN                               PrintNum;\r
+  UINTN                               ReturnNum;\r
+\r
+  ASSERT (Format != NULL);\r
+\r
+  VA_START (Marker, Format);\r
+\r
+  BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
+\r
+  Buffer = (CHAR16 *) AllocatePool (BufferSize);\r
+  ASSERT (Buffer != NULL);\r
+    \r
+  PrintNum = UnicodeSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);\r
+\r
+  ReturnNum = InternalPrintGraphic (X, Y, ForeGround, BackGround, Buffer, PrintNum);\r
+\r
+  FreePool (Buffer);\r
\r
+  return ReturnNum;\r
+}\r
+\r
index 0a83631753c8ebeabbb8316d373554158fb48e08..cb6d2adfa54c6c70f669e8ed6dd4160037e144dd 100644 (file)
@@ -1,12 +1,12 @@
 /** @file\r
-  Library functions that abstract areas of conflict between Tiano an UEFI 2.1.\r
+  Library functions that abstract areas of conflict between framework and UEFI 2.0.\r
 \r
-  Help Port Framework/Tiano code that has conflicts with UEFI 2.1 by hiding the\r
-  oldconflicts with library functions and supporting implementations of the old\r
-  (EDK/EFI 1.10) and new (EDK II/UEFI 2.1) way. This module is a DXE driver as\r
+  Help Port Framework code that has conflicts with UEFI 2.0 by hiding the\r
+  old conflicts with library functions and supporting implementations of the old\r
+  (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. This module is a DXE driver as\r
   it contains DXE enum extensions for EFI event services.\r
 \r
-Copyright (c) 2007, Intel Corporation<BR>\r
+Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -17,13 +17,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include "FrameworkUefiLib.h"\r
+\r
+\r
+#include "UefiLibInternal.h"\r
 \r
 /**\r
   An empty function to pass error checking of CreateEventEx ().\r
 \r
-  This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error\r
+  This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error\r
   checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.\r
\r
+  @param  Event                 Event whose notification function is being invoked.\r
+  @param  Context               Pointer to the notification function's context,\r
+                                which is implementation-dependent.\r
 \r
 **/\r
 VOID\r