2 UEFI Component Name(2) protocol implementation for Mtftp6 driver.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "Mtftp6Impl.h"
20 Retrieves a Unicode string that is the user-readable name of the driver.
22 This function retrieves the user-readable name of a driver in the form of a
23 Unicode string. If the driver specified by This has a user-readable name in
24 the language specified by Language, then a pointer to the driver name is
25 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
26 by This does not support the language specified by Language,
27 then EFI_UNSUPPORTED is returned.
29 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
30 EFI_COMPONENT_NAME_PROTOCOL instance.
32 @param[in] Language A pointer to a Null-terminated ASCII string
33 array indicating the language. This is the
34 language of the driver name that the caller is
35 requesting, and it must match one of the
36 languages specified in SupportedLanguages. The
37 number of languages supported by a driver is up
38 to the driver writer. Language is specified
39 in RFC 4646 or ISO 639-2 language code format.
41 @param[out] DriverName A pointer to the Unicode string to return.
42 This Unicode string is the name of the
43 driver specified by This in the language
44 specified by Language.
46 @retval EFI_SUCCESS The Unicode string for the Driver specified by
47 This and the language specified by Language was
48 returned in DriverName.
50 @retval EFI_INVALID_PARAMETER Language is NULL.
52 @retval EFI_INVALID_PARAMETER DriverName is NULL.
54 @retval EFI_UNSUPPORTED The driver specified by This does not support
55 the language specified by Language.
60 Mtftp6ComponentNameGetDriverName (
61 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
63 OUT CHAR16
**DriverName
67 Retrieves a Unicode string that is the user-readable name of the controller
68 that is being managed by a driver.
70 This function retrieves the user-readable name of the controller specified by
71 ControllerHandle and ChildHandle in the form of a Unicode string. If the
72 driver specified by This has a user-readable name in the language specified by
73 Language, then a pointer to the controller name is returned in ControllerName,
74 and EFI_SUCCESS is returned. If the driver specified by This is not currently
75 managing the controller specified by ControllerHandle and ChildHandle,
76 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
77 support the language specified by Language, then EFI_UNSUPPORTED is returned.
79 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
80 EFI_COMPONENT_NAME_PROTOCOL instance.
82 @param[in] ControllerHandle The handle of a controller that the driver
83 specified by This is managing. This handle
84 specifies the controller whose name is to be
87 @param[in] ChildHandle The handle of the child controller to retrieve
88 the name of. This is an optional parameter that
89 may be NULL. It will be NULL for device
90 drivers. It will also be NULL for bus drivers
91 attempting to retrieve the name of the bus
92 controller. It will not be NULL for a bus
93 driver that attempts to retrieve the name of a
96 @param[in] Language A pointer to a Null-terminated ASCII string
97 array indicating the language. This is the
98 language of the driver name that the caller is
99 requesting, and it must match one of the
100 languages specified in SupportedLanguages. The
101 number of languages supported by a driver is up
102 to the driver writer. Language is specified in
103 RFC 4646 or ISO 639-2 language code format.
105 @param[out] ControllerName A pointer to the Unicode string to return.
106 This Unicode string is the name of the
107 controller specified by ControllerHandle and
108 ChildHandle in the language specified by
109 Language from the point of view of the driver
112 @retval EFI_SUCCESS The Unicode string for the user-readable name in
113 the language specified by Language for the
114 driver specified by This was returned in
117 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
119 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
122 @retval EFI_INVALID_PARAMETER Language is NULL.
124 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
126 @retval EFI_UNSUPPORTED The driver specified by This is not currently
127 managing the controller specified by
128 ControllerHandle and ChildHandle.
130 @retval EFI_UNSUPPORTED The driver specified by This does not support
131 the language specified by Language.
136 Mtftp6ComponentNameGetControllerName (
137 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
138 IN EFI_HANDLE ControllerHandle
,
139 IN EFI_HANDLE ChildHandle OPTIONAL
,
141 OUT CHAR16
**ControllerName
145 // EFI Component Name Protocol
147 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMtftp6ComponentName
= {
148 Mtftp6ComponentNameGetDriverName
,
149 Mtftp6ComponentNameGetControllerName
,
154 // EFI Component Name 2 Protocol
156 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMtftp6ComponentName2
= {
157 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) Mtftp6ComponentNameGetDriverName
,
158 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) Mtftp6ComponentNameGetControllerName
,
162 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp6DriverNameTable
[] = {
165 L
"MTFTP6 Network Service Driver"
173 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gMtftp6ControllerNameTable
= NULL
;
176 Retrieves a Unicode string that is the user-readable name of the driver.
178 This function retrieves the user-readable name of a driver in the form of a
179 Unicode string. If the driver specified by This has a user-readable name in
180 the language specified by Language, then a pointer to the driver name is
181 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
182 by This does not support the language specified by Language,
183 then EFI_UNSUPPORTED is returned.
185 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
186 EFI_COMPONENT_NAME_PROTOCOL instance.
188 @param[in] Language A pointer to a Null-terminated ASCII string
189 array indicating the language. This is the
190 language of the driver name that the caller is
191 requesting, and it must match one of the
192 languages specified in SupportedLanguages. The
193 number of languages supported by a driver is up
194 to the driver writer. Language is specified
195 in RFC 4646 or ISO 639-2 language code format.
197 @param[out] DriverName A pointer to the Unicode string to return.
198 This Unicode string is the name of the
199 driver specified by This in the language
200 specified by Language.
202 @retval EFI_SUCCESS The Unicode string for the Driver specified by
203 This and the language specified by Language was
204 returned in DriverName.
206 @retval EFI_INVALID_PARAMETER Language is NULL.
208 @retval EFI_INVALID_PARAMETER DriverName is NULL.
210 @retval EFI_UNSUPPORTED The driver specified by This does not support
211 the language specified by Language.
216 Mtftp6ComponentNameGetDriverName (
217 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
219 OUT CHAR16
**DriverName
222 return LookupUnicodeString2 (
224 This
->SupportedLanguages
,
225 mMtftp6DriverNameTable
,
227 (BOOLEAN
)(This
== &gMtftp6ComponentName
)
232 Update the component name for the Mtftp6 child handle.
234 @param Mtftp6[in] A pointer to the EFI_MTFTP6_PROTOCOL.
237 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
238 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
243 IN EFI_MTFTP6_PROTOCOL
*Mtftp6
247 CHAR16 HandleName
[128];
248 EFI_MTFTP6_MODE_DATA Mtftp6ModeData
;
249 CHAR16 Address
[sizeof"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
251 if (Mtftp6
== NULL
) {
252 return EFI_INVALID_PARAMETER
;
256 // Format the child name into the string buffer.
258 Status
= Mtftp6
->GetModeData (Mtftp6
, &Mtftp6ModeData
);
259 if (!EFI_ERROR (Status
)) {
260 Status
= NetLibIp6ToStr (&Mtftp6ModeData
.ConfigData
.ServerIp
, Address
, sizeof(Address
));
261 if (EFI_ERROR (Status
)) {
264 UnicodeSPrint (HandleName
, sizeof (HandleName
),
265 L
"MTFTPv6(ServerIp=%s, InitialServerPort=%d)",
267 Mtftp6ModeData
.ConfigData
.InitialServerPort
270 UnicodeSPrint (HandleName
, 0x100, L
"MTFTPv6(%r)", Status
);
273 if (gMtftp6ControllerNameTable
!= NULL
) {
274 FreeUnicodeStringTable (gMtftp6ControllerNameTable
);
275 gMtftp6ControllerNameTable
= NULL
;
278 Status
= AddUnicodeString2 (
280 gMtftp6ComponentName
.SupportedLanguages
,
281 &gMtftp6ControllerNameTable
,
285 if (EFI_ERROR (Status
)) {
289 return AddUnicodeString2 (
291 gMtftp6ComponentName2
.SupportedLanguages
,
292 &gMtftp6ControllerNameTable
,
300 Retrieves a Unicode string that is the user-readable name of the controller
301 that is being managed by a driver.
303 This function retrieves the user-readable name of the controller specified by
304 ControllerHandle and ChildHandle in the form of a Unicode string. If the
305 driver specified by This has a user-readable name in the language specified by
306 Language, then a pointer to the controller name is returned in ControllerName,
307 and EFI_SUCCESS is returned. If the driver specified by This is not currently
308 managing the controller specified by ControllerHandle and ChildHandle,
309 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
310 support the language specified by Language, then EFI_UNSUPPORTED is returned.
312 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
313 EFI_COMPONENT_NAME_PROTOCOL instance.
315 @param[in] ControllerHandle The handle of a controller that the driver
316 specified by This is managing. This handle
317 specifies the controller whose name is to be
320 @param[in] ChildHandle The handle of the child controller to retrieve
321 the name of. This is an optional parameter that
322 may be NULL. It will be NULL for device
323 drivers. It will also be NULL for a bus drivers
324 attempting to retrieve the name of the bus
325 controller. It will not be NULL for a bus
326 driver that attempts to retrieve the name of a
329 @param[in] Language A pointer to a Null-terminated ASCII string
330 array indicating the language. This is the
331 language of the driver name that the caller is
332 requesting, and it must match one of the
333 languages specified in SupportedLanguages. The
334 number of languages supported by a driver is up
335 to the driver writer. Language is specified in
336 RFC 4646 or ISO 639-2 language code format.
338 @param[out] ControllerName A pointer to the Unicode string to return.
339 This Unicode string is the name of the
340 controller specified by ControllerHandle and
341 ChildHandle in the language specified by
342 Language from the point of view of the driver
345 @retval EFI_SUCCESS The Unicode string for the user-readable name in
346 the language specified by Language for the
347 driver specified by This was returned in
350 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
352 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
355 @retval EFI_INVALID_PARAMETER Language is NULL.
357 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
359 @retval EFI_UNSUPPORTED The driver specified by This is not currently
360 managing the controller specified by
361 ControllerHandle and ChildHandle.
363 @retval EFI_UNSUPPORTED The driver specified by This does not support
364 the language specified by Language.
369 Mtftp6ComponentNameGetControllerName (
370 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
371 IN EFI_HANDLE ControllerHandle
,
372 IN EFI_HANDLE ChildHandle OPTIONAL
,
374 OUT CHAR16
**ControllerName
378 EFI_MTFTP6_PROTOCOL
*Mtftp6
;
381 // Only provide names for child handles.
383 if (ChildHandle
== NULL
) {
384 return EFI_UNSUPPORTED
;
388 // Make sure this driver produced ChildHandle
390 Status
= EfiTestChildHandle (
393 &gEfiUdp6ProtocolGuid
395 if (EFI_ERROR (Status
)) {
400 // Retrieve an instance of a produced protocol from ChildHandle
402 Status
= gBS
->OpenProtocol (
404 &gEfiMtftp6ProtocolGuid
,
408 EFI_OPEN_PROTOCOL_GET_PROTOCOL
410 if (EFI_ERROR (Status
)) {
415 // Update the component name for this child handle.
417 Status
= UpdateName (Mtftp6
);
418 if (EFI_ERROR (Status
)) {
422 return LookupUnicodeString2 (
424 This
->SupportedLanguages
,
425 gMtftp6ControllerNameTable
,
427 (BOOLEAN
)(This
== &gMtftp6ComponentName
)