Home | History | Annotate | Download | only in UefiHiiServicesLib
      1 /** @file
      2   This library retrieves pointers to the UEFI HII Protocol instances in the
      3   library's constructor.  All of the UEFI HII related protocols are optional,
      4   so the consumers of this library class must verify that the global variable
      5   pointers are not NULL before use.
      6 
      7   Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
      8   This program and the accompanying materials
      9   are licensed and made available under the terms and conditions of the BSD License
     10   which accompanies this distribution.  The full text of the license may be found at
     11   http://opensource.org/licenses/bsd-license.php
     12 
     13   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     14   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     15 
     16 **/
     17 
     18 #include <Uefi.h>
     19 
     20 #include <Library/UefiHiiServicesLib.h>
     21 #include <Library/UefiBootServicesTableLib.h>
     22 #include <Library/DebugLib.h>
     23 
     24 #include <Protocol/HiiFont.h>
     25 #include <Protocol/HiiString.h>
     26 #include <Protocol/HiiImage.h>
     27 #include <Protocol/HiiDatabase.h>
     28 #include <Protocol/HiiConfigRouting.h>
     29 
     30 ///
     31 /// Pointer to the UEFI HII Font Protocol
     32 ///
     33 EFI_HII_FONT_PROTOCOL  *gHiiFont = NULL;
     34 
     35 ///
     36 /// Pointer to the UEFI HII String Protocol
     37 ///
     38 EFI_HII_STRING_PROTOCOL  *gHiiString = NULL;
     39 
     40 ///
     41 /// Pointer to the UEFI HII Image Protocol
     42 ///
     43 EFI_HII_IMAGE_PROTOCOL  *gHiiImage = NULL;
     44 
     45 ///
     46 /// Pointer to the UEFI HII Database Protocol
     47 ///
     48 EFI_HII_DATABASE_PROTOCOL  *gHiiDatabase = NULL;
     49 
     50 ///
     51 /// Pointer to the UEFI HII Config Rounting Protocol
     52 ///
     53 EFI_HII_CONFIG_ROUTING_PROTOCOL  *gHiiConfigRouting = NULL;
     54 
     55 /**
     56   The constructor function retrieves pointers to the UEFI HII protocol instances
     57 
     58   The constructor function retrieves pointers to the four UEFI HII protocols from the
     59   handle database.  These include the UEFI HII Font Protocol, the UEFI HII String
     60   Protocol, the UEFI HII Image Protocol, the UEFI HII Database Protocol, and the
     61   UEFI HII Config Routing Protocol.  This function always return EFI_SUCCESS.
     62   All of these protocols are optional if the platform does not support configuration
     63   and the UEFI HII Image Protocol and the UEFI HII Font Protocol are optional if
     64   the platform does not support a graphical console.  As a result, the consumers
     65   of this library much check the protocol pointers againt NULL before using them,
     66   or use dependency expressions to guarantee that some of them are present before
     67   assuming they are not NULL.
     68 
     69   @param  ImageHandle   The firmware allocated handle for the EFI image.
     70   @param  SystemTable   A pointer to the EFI System Table.
     71 
     72   @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.
     73 
     74 **/
     75 EFI_STATUS
     76 EFIAPI
     77 UefiHiiServicesLibConstructor (
     78   IN EFI_HANDLE        ImageHandle,
     79   IN EFI_SYSTEM_TABLE  *SystemTable
     80   )
     81 {
     82   EFI_STATUS Status;
     83 
     84   //
     85   // Retrieve the pointer to the UEFI HII String Protocol
     86   //
     87   Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &gHiiString);
     88   ASSERT_EFI_ERROR (Status);
     89 
     90   //
     91   // Retrieve the pointer to the UEFI HII Database Protocol
     92   //
     93   Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &gHiiDatabase);
     94   ASSERT_EFI_ERROR (Status);
     95 
     96   //
     97   // Retrieve the pointer to the UEFI HII Config Routing Protocol
     98   //
     99   Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &gHiiConfigRouting);
    100   ASSERT_EFI_ERROR (Status);
    101 
    102   //
    103   // Retrieve the pointer to the optional UEFI HII Font Protocol
    104   //
    105   gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &gHiiFont);
    106 
    107   //
    108   // Retrieve the pointer to the optional UEFI HII Image Protocol
    109   //
    110   gBS->LocateProtocol (&gEfiHiiImageProtocolGuid, NULL, (VOID **) &gHiiImage);
    111 
    112   return EFI_SUCCESS;
    113 }
    114