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 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
8 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
9 |
|
---|
10 | **/
|
---|
11 |
|
---|
12 | #include <Uefi.h>
|
---|
13 |
|
---|
14 | #include <Library/UefiHiiServicesLib.h>
|
---|
15 | #include <Library/UefiBootServicesTableLib.h>
|
---|
16 | #include <Library/DebugLib.h>
|
---|
17 |
|
---|
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>
|
---|
23 |
|
---|
24 | ///
|
---|
25 | /// Pointer to the UEFI HII Font Protocol
|
---|
26 | ///
|
---|
27 | EFI_HII_FONT_PROTOCOL *gHiiFont = NULL;
|
---|
28 |
|
---|
29 | ///
|
---|
30 | /// Pointer to the UEFI HII String Protocol
|
---|
31 | ///
|
---|
32 | EFI_HII_STRING_PROTOCOL *gHiiString = NULL;
|
---|
33 |
|
---|
34 | ///
|
---|
35 | /// Pointer to the UEFI HII Image Protocol
|
---|
36 | ///
|
---|
37 | EFI_HII_IMAGE_PROTOCOL *gHiiImage = NULL;
|
---|
38 |
|
---|
39 | ///
|
---|
40 | /// Pointer to the UEFI HII Database Protocol
|
---|
41 | ///
|
---|
42 | EFI_HII_DATABASE_PROTOCOL *gHiiDatabase = NULL;
|
---|
43 |
|
---|
44 | ///
|
---|
45 | /// Pointer to the UEFI HII Config Rounting Protocol
|
---|
46 | ///
|
---|
47 | EFI_HII_CONFIG_ROUTING_PROTOCOL *gHiiConfigRouting = NULL;
|
---|
48 |
|
---|
49 | /**
|
---|
50 | The constructor function retrieves pointers to the UEFI HII protocol instances
|
---|
51 |
|
---|
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.
|
---|
62 |
|
---|
63 | @param ImageHandle The firmware allocated handle for the EFI image.
|
---|
64 | @param SystemTable A pointer to the EFI System Table.
|
---|
65 |
|
---|
66 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
---|
67 |
|
---|
68 | **/
|
---|
69 | EFI_STATUS
|
---|
70 | EFIAPI
|
---|
71 | UefiHiiServicesLibConstructor (
|
---|
72 | IN EFI_HANDLE ImageHandle,
|
---|
73 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
74 | )
|
---|
75 | {
|
---|
76 | EFI_STATUS Status;
|
---|
77 |
|
---|
78 | //
|
---|
79 | // Retrieve the pointer to the UEFI HII String Protocol
|
---|
80 | //
|
---|
81 | Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &gHiiString);
|
---|
82 | ASSERT_EFI_ERROR (Status);
|
---|
83 |
|
---|
84 | //
|
---|
85 | // Retrieve the pointer to the UEFI HII Database Protocol
|
---|
86 | //
|
---|
87 | Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &gHiiDatabase);
|
---|
88 | ASSERT_EFI_ERROR (Status);
|
---|
89 |
|
---|
90 | //
|
---|
91 | // Retrieve the pointer to the UEFI HII Config Routing Protocol
|
---|
92 | //
|
---|
93 | Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &gHiiConfigRouting);
|
---|
94 | ASSERT_EFI_ERROR (Status);
|
---|
95 |
|
---|
96 | //
|
---|
97 | // Retrieve the pointer to the optional UEFI HII Font Protocol
|
---|
98 | //
|
---|
99 | gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &gHiiFont);
|
---|
100 |
|
---|
101 | //
|
---|
102 | // Retrieve the pointer to the optional UEFI HII Image Protocol
|
---|
103 | //
|
---|
104 | gBS->LocateProtocol (&gEfiHiiImageProtocolGuid, NULL, (VOID **) &gHiiImage);
|
---|
105 |
|
---|
106 | return EFI_SUCCESS;
|
---|
107 | }
|
---|