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.
7 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Library/UefiHiiServicesLib.h>
15 #include <Library/UefiBootServicesTableLib.h>
16 #include <Library/DebugLib.h>
18 #include <Protocol/HiiFont.h>
19 #include <Protocol/HiiString.h>
20 #include <Protocol/HiiImage.h>
21 #include <Protocol/HiiDatabase.h>
22 #include <Protocol/HiiConfigRouting.h>
25 /// Pointer to the UEFI HII Font Protocol
27 EFI_HII_FONT_PROTOCOL
*gHiiFont
= NULL
;
30 /// Pointer to the UEFI HII String Protocol
32 EFI_HII_STRING_PROTOCOL
*gHiiString
= NULL
;
35 /// Pointer to the UEFI HII Image Protocol
37 EFI_HII_IMAGE_PROTOCOL
*gHiiImage
= NULL
;
40 /// Pointer to the UEFI HII Database Protocol
42 EFI_HII_DATABASE_PROTOCOL
*gHiiDatabase
= NULL
;
45 /// Pointer to the UEFI HII Config Rounting Protocol
47 EFI_HII_CONFIG_ROUTING_PROTOCOL
*gHiiConfigRouting
= NULL
;
50 The constructor function retrieves pointers to the UEFI HII protocol instances
52 The constructor function retrieves pointers to the four UEFI HII protocols from the
53 handle database. These include the UEFI HII Font Protocol, the UEFI HII String
54 Protocol, the UEFI HII Image Protocol, the UEFI HII Database Protocol, and the
55 UEFI HII Config Routing Protocol. This function always return EFI_SUCCESS.
56 All of these protocols are optional if the platform does not support configuration
57 and the UEFI HII Image Protocol and the UEFI HII Font Protocol are optional if
58 the platform does not support a graphical console. As a result, the consumers
59 of this library much check the protocol pointers againt NULL before using them,
60 or use dependency expressions to guarantee that some of them are present before
61 assuming they are not NULL.
63 @param ImageHandle The firmware allocated handle for the EFI image.
64 @param SystemTable A pointer to the EFI System Table.
66 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
71 UefiHiiServicesLibConstructor (
72 IN EFI_HANDLE ImageHandle
,
73 IN EFI_SYSTEM_TABLE
*SystemTable
79 // Retrieve the pointer to the UEFI HII String Protocol
81 Status
= gBS
->LocateProtocol (&gEfiHiiStringProtocolGuid
, NULL
, (VOID
**)&gHiiString
);
82 ASSERT_EFI_ERROR (Status
);
85 // Retrieve the pointer to the UEFI HII Database Protocol
87 Status
= gBS
->LocateProtocol (&gEfiHiiDatabaseProtocolGuid
, NULL
, (VOID
**)&gHiiDatabase
);
88 ASSERT_EFI_ERROR (Status
);
91 // Retrieve the pointer to the UEFI HII Config Routing Protocol
93 Status
= gBS
->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid
, NULL
, (VOID
**)&gHiiConfigRouting
);
94 ASSERT_EFI_ERROR (Status
);
97 // Retrieve the pointer to the optional UEFI HII Font Protocol
99 gBS
->LocateProtocol (&gEfiHiiFontProtocolGuid
, NULL
, (VOID
**)&gHiiFont
);
102 // Retrieve the pointer to the optional UEFI HII Image Protocol
104 gBS
->LocateProtocol (&gEfiHiiImageProtocolGuid
, NULL
, (VOID
**)&gHiiImage
);