2 UEFI Component Name(2) protocol implementation for Mtftp4Dxe driver.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "Mtftp4Impl.h"
12 // EFI Component Name Functions
15 Retrieves a Unicode string that is the user readable name of the driver.
17 This function retrieves the user readable name of a driver in the form of a
18 Unicode string. If the driver specified by This has a user readable name in
19 the language specified by Language, then a pointer to the driver name is
20 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
21 by This does not support the language specified by Language,
22 then EFI_UNSUPPORTED is returned.
24 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
25 EFI_COMPONENT_NAME_PROTOCOL instance.
27 @param[in] Language A pointer to a Null-terminated ASCII string
28 array indicating the language. This is the
29 language of the driver name that the caller is
30 requesting, and it must match one of the
31 languages specified in SupportedLanguages. The
32 number of languages supported by a driver is up
33 to the driver writer. Language is specified
34 in RFC 4646 or ISO 639-2 language code format.
36 @param[out] DriverName A pointer to the Unicode string to return.
37 This Unicode string is the name of the
38 driver specified by This in the language
39 specified by Language.
41 @retval EFI_SUCCESS The Unicode string for the Driver specified by
42 This and the language specified by Language was
43 returned in DriverName.
45 @retval EFI_INVALID_PARAMETER Language is NULL.
47 @retval EFI_INVALID_PARAMETER DriverName is NULL.
49 @retval EFI_UNSUPPORTED The driver specified by This does not support
50 the language specified by Language.
55 Mtftp4ComponentNameGetDriverName (
56 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
58 OUT CHAR16
**DriverName
63 Retrieves a Unicode string that is the user readable name of the controller
64 that is being managed by a driver.
66 This function retrieves the user readable name of the controller specified by
67 ControllerHandle and ChildHandle in the form of a Unicode string. If the
68 driver specified by This has a user readable name in the language specified by
69 Language, then a pointer to the controller name is returned in ControllerName,
70 and EFI_SUCCESS is returned. If the driver specified by This is not currently
71 managing the controller specified by ControllerHandle and ChildHandle,
72 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
73 support the language specified by Language, then EFI_UNSUPPORTED is returned.
75 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
76 EFI_COMPONENT_NAME_PROTOCOL instance.
78 @param[in] ControllerHandle The handle of a controller that the driver
79 specified by This is managing. This handle
80 specifies the controller whose name is to be
83 @param[in] ChildHandle The handle of the child controller to retrieve
84 the name of. This is an optional parameter that
85 may be NULL. It will be NULL for device
86 drivers. It will also be NULL for a bus drivers
87 that wish to retrieve the name of the bus
88 controller. It will not be NULL for a bus
89 driver that wishes to retrieve the name of a
92 @param[in] Language A pointer to a Null-terminated ASCII string
93 array indicating the language. This is the
94 language of the driver name that the caller is
95 requesting, and it must match one of the
96 languages specified in SupportedLanguages. The
97 number of languages supported by a driver is up
98 to the driver writer. Language is specified in
99 RFC 4646 or ISO 639-2 language code format.
101 @param[out] ControllerName A pointer to the Unicode string to return.
102 This Unicode string is the name of the
103 controller specified by ControllerHandle and
104 ChildHandle in the language specified by
105 Language from the point of view of the driver
108 @retval EFI_SUCCESS The Unicode string for the user readable name in
109 the language specified by Language for the
110 driver specified by This was returned in
113 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
115 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
118 @retval EFI_INVALID_PARAMETER Language is NULL.
120 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
122 @retval EFI_UNSUPPORTED The driver specified by This is not currently
123 managing the controller specified by
124 ControllerHandle and ChildHandle.
126 @retval EFI_UNSUPPORTED The driver specified by This does not support
127 the language specified by Language.
132 Mtftp4ComponentNameGetControllerName (
133 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
134 IN EFI_HANDLE ControllerHandle
,
135 IN EFI_HANDLE ChildHandle OPTIONAL
,
137 OUT CHAR16
**ControllerName
142 /// EFI Component Name Protocol
144 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMtftp4ComponentName
= {
145 Mtftp4ComponentNameGetDriverName
,
146 Mtftp4ComponentNameGetControllerName
,
151 /// EFI Component Name 2 Protocol
153 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMtftp4ComponentName2
= {
154 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) Mtftp4ComponentNameGetDriverName
,
155 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) Mtftp4ComponentNameGetControllerName
,
160 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp4DriverNameTable
[] = {
163 L
"MTFTP4 Network Service"
171 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gMtftp4ControllerNameTable
= NULL
;
174 Retrieves a Unicode string that is the user readable name of the driver.
176 This function retrieves the user readable name of a driver in the form of a
177 Unicode string. If the driver specified by This has a user readable name in
178 the language specified by Language, then a pointer to the driver name is
179 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
180 by This does not support the language specified by Language,
181 then EFI_UNSUPPORTED is returned.
183 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
184 EFI_COMPONENT_NAME_PROTOCOL instance.
186 @param[in] Language A pointer to a Null-terminated ASCII string
187 array indicating the language. This is the
188 language of the driver name that the caller is
189 requesting, and it must match one of the
190 languages specified in SupportedLanguages. The
191 number of languages supported by a driver is up
192 to the driver writer. Language is specified
193 in RFC 4646 or ISO 639-2 language code format.
195 @param[out] DriverName A pointer to the Unicode string to return.
196 This Unicode string is the name of the
197 driver specified by This in the language
198 specified by Language.
200 @retval EFI_SUCCESS The Unicode string for the Driver specified by
201 This and the language specified by Language was
202 returned in DriverName.
204 @retval EFI_INVALID_PARAMETER Language is NULL.
206 @retval EFI_INVALID_PARAMETER DriverName is NULL.
208 @retval EFI_UNSUPPORTED The driver specified by This does not support
209 the language specified by Language.
214 Mtftp4ComponentNameGetDriverName (
215 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
217 OUT CHAR16
**DriverName
220 return LookupUnicodeString2 (
222 This
->SupportedLanguages
,
223 mMtftp4DriverNameTable
,
225 (BOOLEAN
)(This
== &gMtftp4ComponentName
)
230 Update the component name for the Mtftp4 child handle.
232 @param Mtftp4[in] A pointer to the EFI_MTFTP4_PROTOCOL.
235 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
236 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
241 IN EFI_MTFTP4_PROTOCOL
*Mtftp4
245 CHAR16 HandleName
[80];
246 EFI_MTFTP4_MODE_DATA ModeData
;
248 if (Mtftp4
== NULL
) {
249 return EFI_INVALID_PARAMETER
;
253 // Format the child name into the string buffer as:
254 // MTFTPv4 (ServerIp=192.168.1.10, ServerPort=69)
256 Status
= Mtftp4
->GetModeData (Mtftp4
, &ModeData
);
257 if (EFI_ERROR (Status
)) {
261 UnicodeSPrint (HandleName
, sizeof (HandleName
),
262 L
"MTFTPv4 (ServerIp=%d.%d.%d.%d, ServerPort=%d)",
263 ModeData
.ConfigData
.ServerIp
.Addr
[0],
264 ModeData
.ConfigData
.ServerIp
.Addr
[1],
265 ModeData
.ConfigData
.ServerIp
.Addr
[2],
266 ModeData
.ConfigData
.ServerIp
.Addr
[3],
267 ModeData
.ConfigData
.InitialServerPort
270 if (gMtftp4ControllerNameTable
!= NULL
) {
271 FreeUnicodeStringTable (gMtftp4ControllerNameTable
);
272 gMtftp4ControllerNameTable
= NULL
;
275 Status
= AddUnicodeString2 (
277 gMtftp4ComponentName
.SupportedLanguages
,
278 &gMtftp4ControllerNameTable
,
282 if (EFI_ERROR (Status
)) {
286 return AddUnicodeString2 (
288 gMtftp4ComponentName2
.SupportedLanguages
,
289 &gMtftp4ControllerNameTable
,
296 Retrieves a Unicode string that is the user readable name of the controller
297 that is being managed by a driver.
299 This function retrieves the user readable name of the controller specified by
300 ControllerHandle and ChildHandle in the form of a Unicode string. If the
301 driver specified by This has a user readable name in the language specified by
302 Language, then a pointer to the controller name is returned in ControllerName,
303 and EFI_SUCCESS is returned. If the driver specified by This is not currently
304 managing the controller specified by ControllerHandle and ChildHandle,
305 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
306 support the language specified by Language, then EFI_UNSUPPORTED is returned.
308 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
309 EFI_COMPONENT_NAME_PROTOCOL instance.
311 @param[in] ControllerHandle The handle of a controller that the driver
312 specified by This is managing. This handle
313 specifies the controller whose name is to be
316 @param[in] ChildHandle The handle of the child controller to retrieve
317 the name of. This is an optional parameter that
318 may be NULL. It will be NULL for device
319 drivers. It will also be NULL for a bus drivers
320 that wish to retrieve the name of the bus
321 controller. It will not be NULL for a bus
322 driver that wishes to retrieve the name of a
325 @param[in] Language A pointer to a Null-terminated ASCII string
326 array indicating the language. This is the
327 language of the driver name that the caller is
328 requesting, and it must match one of the
329 languages specified in SupportedLanguages. The
330 number of languages supported by a driver is up
331 to the driver writer. Language is specified in
332 RFC 4646 or ISO 639-2 language code format.
334 @param[out] ControllerName A pointer to the Unicode string to return.
335 This Unicode string is the name of the
336 controller specified by ControllerHandle and
337 ChildHandle in the language specified by
338 Language from the point of view of the driver
341 @retval EFI_SUCCESS The Unicode string for the user readable name in
342 the language specified by Language for the
343 driver specified by This was returned in
346 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
348 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
351 @retval EFI_INVALID_PARAMETER Language is NULL.
353 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
355 @retval EFI_UNSUPPORTED The driver specified by This is not currently
356 managing the controller specified by
357 ControllerHandle and ChildHandle.
359 @retval EFI_UNSUPPORTED The driver specified by This does not support
360 the language specified by Language.
365 Mtftp4ComponentNameGetControllerName (
366 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
367 IN EFI_HANDLE ControllerHandle
,
368 IN EFI_HANDLE ChildHandle OPTIONAL
,
370 OUT CHAR16
**ControllerName
374 EFI_MTFTP4_PROTOCOL
*Mtftp4
;
377 // Only provide names for child handles.
379 if (ChildHandle
== NULL
) {
380 return EFI_UNSUPPORTED
;
384 // Make sure this driver produced ChildHandle
386 Status
= EfiTestChildHandle (
389 &gEfiUdp4ProtocolGuid
391 if (EFI_ERROR (Status
)) {
396 // Retrieve an instance of a produced protocol from ChildHandle
398 Status
= gBS
->OpenProtocol (
400 &gEfiMtftp4ProtocolGuid
,
404 EFI_OPEN_PROTOCOL_GET_PROTOCOL
406 if (EFI_ERROR (Status
)) {
411 // Update the component name for this child handle.
413 Status
= UpdateName (Mtftp4
);
414 if (EFI_ERROR (Status
)) {
418 return LookupUnicodeString2 (
420 This
->SupportedLanguages
,
421 gMtftp4ControllerNameTable
,
423 (BOOLEAN
)(This
== &gMtftp4ComponentName
)