2 Implementation of EFI_COMPONENT_NAME_PROTOCOL and EFI_COMPONENT_NAME2_PROTOCOL protocol.
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "HttpBootDxe.h"
12 /// Component Name Protocol instance
14 GLOBAL_REMOVE_IF_UNREFERENCED
15 EFI_COMPONENT_NAME_PROTOCOL gHttpBootDxeComponentName
= {
16 (EFI_COMPONENT_NAME_GET_DRIVER_NAME
) HttpBootDxeComponentNameGetDriverName
,
17 (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME
)HttpBootDxeComponentNameGetControllerName
,
22 /// Component Name 2 Protocol instance
24 GLOBAL_REMOVE_IF_UNREFERENCED
25 EFI_COMPONENT_NAME2_PROTOCOL gHttpBootDxeComponentName2
= {
26 HttpBootDxeComponentNameGetDriverName
,
27 HttpBootDxeComponentNameGetControllerName
,
32 /// Table of driver names
34 GLOBAL_REMOVE_IF_UNREFERENCED
35 EFI_UNICODE_STRING_TABLE mHttpBootDxeDriverNameTable
[] = {
36 { "eng;en", (CHAR16
*)L
"UEFI HTTP Boot Driver" },
41 /// Table of controller names
43 GLOBAL_REMOVE_IF_UNREFERENCED
44 EFI_UNICODE_STRING_TABLE mHttpBootDxeControllerNameTable
[] = {
45 { "eng;en", (CHAR16
*)L
"UEFI Http Boot Controller" },
50 Retrieves a Unicode string that is the user-readable name of the EFI Driver.
52 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
53 @param Language A pointer to a three-character ISO 639-2 language identifier.
54 This is the language of the driver name that that the caller
55 is requesting, and it must match one of the languages specified
56 in SupportedLanguages. The number of languages supported by a
57 driver is up to the driver writer.
58 @param DriverName A pointer to the Unicode string to return. This Unicode string
59 is the name of the driver specified by This in the language
60 specified by Language.
62 @retval EFI_SUCCESS The Unicode string for the Driver specified by This
63 and the language specified by Language was returned
65 @retval EFI_INVALID_PARAMETER Language is NULL.
66 @retval EFI_INVALID_PARAMETER DriverName is NULL.
67 @retval EFI_UNSUPPORTED The driver specified by This does not support the
68 language specified by Language.
73 HttpBootDxeComponentNameGetDriverName (
74 IN EFI_COMPONENT_NAME2_PROTOCOL
*This
,
76 OUT CHAR16
**DriverName
79 return LookupUnicodeString2 (
81 This
->SupportedLanguages
,
82 mHttpBootDxeDriverNameTable
,
84 (BOOLEAN
) (This
!= &gHttpBootDxeComponentName2
)
89 Retrieves a Unicode string that is the user readable name of the controller
90 that is being managed by an EFI Driver.
92 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
93 @param ControllerHandle The handle of a controller that the driver specified by
94 This is managing. This handle specifies the controller
95 whose name is to be returned.
96 @param ChildHandle The handle of the child controller to retrieve the name
97 of. This is an optional parameter that may be NULL. It
98 will be NULL for device drivers. It will also be NULL
99 for a bus drivers that wish to retrieve the name of the
100 bus controller. It will not be NULL for a bus driver
101 that wishes to retrieve the name of a child controller.
102 @param Language A pointer to a three character ISO 639-2 language
103 identifier. This is the language of the controller name
104 that the caller is requesting, and it must match one
105 of the languages specified in SupportedLanguages. The
106 number of languages supported by a driver is up to the
108 @param ControllerName A pointer to the Unicode string to return. This Unicode
109 string is the name of the controller specified by
110 ControllerHandle and ChildHandle in the language specified
111 by Language, from the point of view of the driver specified
114 @retval EFI_SUCCESS The Unicode string for the user-readable name in the
115 language specified by Language for the driver
116 specified by This was returned in DriverName.
117 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
118 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
119 @retval EFI_INVALID_PARAMETER Language is NULL.
120 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
121 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing
122 the controller specified by ControllerHandle and
124 @retval EFI_UNSUPPORTED The driver specified by This does not support the
125 language specified by Language.
130 HttpBootDxeComponentNameGetControllerName (
131 IN EFI_COMPONENT_NAME2_PROTOCOL
*This
,
132 IN EFI_HANDLE ControllerHandle
,
133 IN EFI_HANDLE ChildHandle OPTIONAL
,
135 OUT CHAR16
**ControllerName
139 EFI_HANDLE NicHandle
;
142 if (ControllerHandle
== NULL
|| ChildHandle
!= NULL
) {
143 return EFI_UNSUPPORTED
;
146 NicHandle
= HttpBootGetNicByIp4Children (ControllerHandle
);
147 if (NicHandle
== NULL
) {
148 NicHandle
= HttpBootGetNicByIp6Children(ControllerHandle
);
149 if (NicHandle
== NULL
) {
150 return EFI_UNSUPPORTED
;
155 // Try to retrieve the private data by caller ID GUID.
157 Status
= gBS
->OpenProtocol (
163 EFI_OPEN_PROTOCOL_GET_PROTOCOL
165 if (EFI_ERROR (Status
)) {
169 return LookupUnicodeString2 (
171 This
->SupportedLanguages
,
172 mHttpBootDxeControllerNameTable
,
174 (BOOLEAN
)(This
!= &gHttpBootDxeComponentName2
)