2 UEFI Component Name(2) protocol implementation for Mtftp6 driver.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "Mtftp6Impl.h"
13 Retrieves a Unicode string that is the user-readable name of the driver.
15 This function retrieves the user-readable name of a driver in the form of a
16 Unicode string. If the driver specified by This has a user-readable name in
17 the language specified by Language, then a pointer to the driver name is
18 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
19 by This does not support the language specified by Language,
20 then EFI_UNSUPPORTED is returned.
22 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
23 EFI_COMPONENT_NAME_PROTOCOL instance.
25 @param[in] Language A pointer to a Null-terminated ASCII string
26 array indicating the language. This is the
27 language of the driver name that the caller is
28 requesting, and it must match one of the
29 languages specified in SupportedLanguages. The
30 number of languages supported by a driver is up
31 to the driver writer. Language is specified
32 in RFC 4646 or ISO 639-2 language code format.
34 @param[out] DriverName A pointer to the Unicode string to return.
35 This Unicode string is the name of the
36 driver specified by This in the language
37 specified by Language.
39 @retval EFI_SUCCESS The Unicode string for the Driver specified by
40 This and the language specified by Language was
41 returned in DriverName.
43 @retval EFI_INVALID_PARAMETER Language is NULL.
45 @retval EFI_INVALID_PARAMETER DriverName is NULL.
47 @retval EFI_UNSUPPORTED The driver specified by This does not support
48 the language specified by Language.
53 Mtftp6ComponentNameGetDriverName (
54 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
56 OUT CHAR16
**DriverName
60 Retrieves a Unicode string that is the user-readable name of the controller
61 that is being managed by a driver.
63 This function retrieves the user-readable name of the controller specified by
64 ControllerHandle and ChildHandle in the form of a Unicode string. If the
65 driver specified by This has a user-readable name in the language specified by
66 Language, then a pointer to the controller name is returned in ControllerName,
67 and EFI_SUCCESS is returned. If the driver specified by This is not currently
68 managing the controller specified by ControllerHandle and ChildHandle,
69 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
70 support the language specified by Language, then EFI_UNSUPPORTED is returned.
72 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
73 EFI_COMPONENT_NAME_PROTOCOL instance.
75 @param[in] ControllerHandle The handle of a controller that the driver
76 specified by This is managing. This handle
77 specifies the controller whose name is to be
80 @param[in] ChildHandle The handle of the child controller to retrieve
81 the name of. This is an optional parameter that
82 may be NULL. It will be NULL for device
83 drivers. It will also be NULL for bus drivers
84 attempting to retrieve the name of the bus
85 controller. It will not be NULL for a bus
86 driver that attempts to retrieve the name of a
89 @param[in] Language A pointer to a Null-terminated ASCII string
90 array indicating the language. This is the
91 language of the driver name that the caller is
92 requesting, and it must match one of the
93 languages specified in SupportedLanguages. The
94 number of languages supported by a driver is up
95 to the driver writer. Language is specified in
96 RFC 4646 or ISO 639-2 language code format.
98 @param[out] ControllerName A pointer to the Unicode string to return.
99 This Unicode string is the name of the
100 controller specified by ControllerHandle and
101 ChildHandle in the language specified by
102 Language from the point of view of the driver
105 @retval EFI_SUCCESS The Unicode string for the user-readable name in
106 the language specified by Language for the
107 driver specified by This was returned in
110 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
112 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
115 @retval EFI_INVALID_PARAMETER Language is NULL.
117 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
119 @retval EFI_UNSUPPORTED The driver specified by This is not currently
120 managing the controller specified by
121 ControllerHandle and ChildHandle.
123 @retval EFI_UNSUPPORTED The driver specified by This does not support
124 the language specified by Language.
129 Mtftp6ComponentNameGetControllerName (
130 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
131 IN EFI_HANDLE ControllerHandle
,
132 IN EFI_HANDLE ChildHandle OPTIONAL
,
134 OUT CHAR16
**ControllerName
138 // EFI Component Name Protocol
140 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMtftp6ComponentName
= {
141 Mtftp6ComponentNameGetDriverName
,
142 Mtftp6ComponentNameGetControllerName
,
147 // EFI Component Name 2 Protocol
149 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMtftp6ComponentName2
= {
150 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)Mtftp6ComponentNameGetDriverName
,
151 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)Mtftp6ComponentNameGetControllerName
,
155 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp6DriverNameTable
[] = {
158 L
"MTFTP6 Network Service Driver"
166 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gMtftp6ControllerNameTable
= NULL
;
169 Retrieves a Unicode string that is the user-readable name of the driver.
171 This function retrieves the user-readable name of a driver in the form of a
172 Unicode string. If the driver specified by This has a user-readable name in
173 the language specified by Language, then a pointer to the driver name is
174 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
175 by This does not support the language specified by Language,
176 then EFI_UNSUPPORTED is returned.
178 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
179 EFI_COMPONENT_NAME_PROTOCOL instance.
181 @param[in] Language A pointer to a Null-terminated ASCII string
182 array indicating the language. This is the
183 language of the driver name that the caller is
184 requesting, and it must match one of the
185 languages specified in SupportedLanguages. The
186 number of languages supported by a driver is up
187 to the driver writer. Language is specified
188 in RFC 4646 or ISO 639-2 language code format.
190 @param[out] DriverName A pointer to the Unicode string to return.
191 This Unicode string is the name of the
192 driver specified by This in the language
193 specified by Language.
195 @retval EFI_SUCCESS The Unicode string for the Driver specified by
196 This and the language specified by Language was
197 returned in DriverName.
199 @retval EFI_INVALID_PARAMETER Language is NULL.
201 @retval EFI_INVALID_PARAMETER DriverName is NULL.
203 @retval EFI_UNSUPPORTED The driver specified by This does not support
204 the language specified by Language.
209 Mtftp6ComponentNameGetDriverName (
210 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
212 OUT CHAR16
**DriverName
215 return LookupUnicodeString2 (
217 This
->SupportedLanguages
,
218 mMtftp6DriverNameTable
,
220 (BOOLEAN
)(This
== &gMtftp6ComponentName
)
225 Update the component name for the Mtftp6 child handle.
227 @param Mtftp6[in] A pointer to the EFI_MTFTP6_PROTOCOL.
230 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
231 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
236 IN EFI_MTFTP6_PROTOCOL
*Mtftp6
240 CHAR16 HandleName
[128];
241 EFI_MTFTP6_MODE_DATA Mtftp6ModeData
;
242 CHAR16 Address
[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
244 if (Mtftp6
== NULL
) {
245 return EFI_INVALID_PARAMETER
;
249 // Format the child name into the string buffer.
251 Status
= Mtftp6
->GetModeData (Mtftp6
, &Mtftp6ModeData
);
252 if (!EFI_ERROR (Status
)) {
253 Status
= NetLibIp6ToStr (&Mtftp6ModeData
.ConfigData
.ServerIp
, Address
, sizeof (Address
));
254 if (EFI_ERROR (Status
)) {
261 L
"MTFTPv6(ServerIp=%s, InitialServerPort=%d)",
263 Mtftp6ModeData
.ConfigData
.InitialServerPort
266 UnicodeSPrint (HandleName
, 0x100, L
"MTFTPv6(%r)", Status
);
269 if (gMtftp6ControllerNameTable
!= NULL
) {
270 FreeUnicodeStringTable (gMtftp6ControllerNameTable
);
271 gMtftp6ControllerNameTable
= NULL
;
274 Status
= AddUnicodeString2 (
276 gMtftp6ComponentName
.SupportedLanguages
,
277 &gMtftp6ControllerNameTable
,
281 if (EFI_ERROR (Status
)) {
285 return AddUnicodeString2 (
287 gMtftp6ComponentName2
.SupportedLanguages
,
288 &gMtftp6ControllerNameTable
,
295 Retrieves a Unicode string that is the user-readable name of the controller
296 that is being managed by a driver.
298 This function retrieves the user-readable name of the controller specified by
299 ControllerHandle and ChildHandle in the form of a Unicode string. If the
300 driver specified by This has a user-readable name in the language specified by
301 Language, then a pointer to the controller name is returned in ControllerName,
302 and EFI_SUCCESS is returned. If the driver specified by This is not currently
303 managing the controller specified by ControllerHandle and ChildHandle,
304 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
305 support the language specified by Language, then EFI_UNSUPPORTED is returned.
307 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
308 EFI_COMPONENT_NAME_PROTOCOL instance.
310 @param[in] ControllerHandle The handle of a controller that the driver
311 specified by This is managing. This handle
312 specifies the controller whose name is to be
315 @param[in] ChildHandle The handle of the child controller to retrieve
316 the name of. This is an optional parameter that
317 may be NULL. It will be NULL for device
318 drivers. It will also be NULL for a bus drivers
319 attempting to retrieve the name of the bus
320 controller. It will not be NULL for a bus
321 driver that attempts to retrieve the name of a
324 @param[in] Language A pointer to a Null-terminated ASCII string
325 array indicating the language. This is the
326 language of the driver name that the caller is
327 requesting, and it must match one of the
328 languages specified in SupportedLanguages. The
329 number of languages supported by a driver is up
330 to the driver writer. Language is specified in
331 RFC 4646 or ISO 639-2 language code format.
333 @param[out] ControllerName A pointer to the Unicode string to return.
334 This Unicode string is the name of the
335 controller specified by ControllerHandle and
336 ChildHandle in the language specified by
337 Language from the point of view of the driver
340 @retval EFI_SUCCESS The Unicode string for the user-readable name in
341 the language specified by Language for the
342 driver specified by This was returned in
345 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
347 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
350 @retval EFI_INVALID_PARAMETER Language is NULL.
352 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
354 @retval EFI_UNSUPPORTED The driver specified by This is not currently
355 managing the controller specified by
356 ControllerHandle and ChildHandle.
358 @retval EFI_UNSUPPORTED The driver specified by This does not support
359 the language specified by Language.
364 Mtftp6ComponentNameGetControllerName (
365 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
366 IN EFI_HANDLE ControllerHandle
,
367 IN EFI_HANDLE ChildHandle OPTIONAL
,
369 OUT CHAR16
**ControllerName
373 EFI_MTFTP6_PROTOCOL
*Mtftp6
;
376 // Only provide names for child handles.
378 if (ChildHandle
== NULL
) {
379 return EFI_UNSUPPORTED
;
383 // Make sure this driver produced ChildHandle
385 Status
= EfiTestChildHandle (
388 &gEfiUdp6ProtocolGuid
390 if (EFI_ERROR (Status
)) {
395 // Retrieve an instance of a produced protocol from ChildHandle
397 Status
= gBS
->OpenProtocol (
399 &gEfiMtftp6ProtocolGuid
,
403 EFI_OPEN_PROTOCOL_GET_PROTOCOL
405 if (EFI_ERROR (Status
)) {
410 // Update the component name for this child handle.
412 Status
= UpdateName (Mtftp6
);
413 if (EFI_ERROR (Status
)) {
417 return LookupUnicodeString2 (
419 This
->SupportedLanguages
,
420 gMtftp6ControllerNameTable
,
422 (BOOLEAN
)(This
== &gMtftp6ComponentName
)