2 UEFI Component Name(2) protocol implementation for Mtftp4Dxe driver.
4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php<BR>
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "Mtftp4Impl.h"
18 // EFI Component Name Functions
21 Retrieves a Unicode string that is the user readable name of the driver.
23 This function retrieves the user readable name of a driver in the form of a
24 Unicode string. If the driver specified by This has a user readable name in
25 the language specified by Language, then a pointer to the driver name is
26 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
27 by This does not support the language specified by Language,
28 then EFI_UNSUPPORTED is returned.
30 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
31 EFI_COMPONENT_NAME_PROTOCOL instance.
33 @param[in] Language A pointer to a Null-terminated ASCII string
34 array indicating the language. This is the
35 language of the driver name that the caller is
36 requesting, and it must match one of the
37 languages specified in SupportedLanguages. The
38 number of languages supported by a driver is up
39 to the driver writer. Language is specified
40 in RFC 4646 or ISO 639-2 language code format.
42 @param[out] DriverName A pointer to the Unicode string to return.
43 This Unicode string is the name of the
44 driver specified by This in the language
45 specified by Language.
47 @retval EFI_SUCCESS The Unicode string for the Driver specified by
48 This and the language specified by Language was
49 returned in DriverName.
51 @retval EFI_INVALID_PARAMETER Language is NULL.
53 @retval EFI_INVALID_PARAMETER DriverName is NULL.
55 @retval EFI_UNSUPPORTED The driver specified by This does not support
56 the language specified by Language.
61 Mtftp4ComponentNameGetDriverName (
62 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
64 OUT CHAR16
**DriverName
69 Retrieves a Unicode string that is the user readable name of the controller
70 that is being managed by a driver.
72 This function retrieves the user readable name of the controller specified by
73 ControllerHandle and ChildHandle in the form of a Unicode string. If the
74 driver specified by This has a user readable name in the language specified by
75 Language, then a pointer to the controller name is returned in ControllerName,
76 and EFI_SUCCESS is returned. If the driver specified by This is not currently
77 managing the controller specified by ControllerHandle and ChildHandle,
78 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
79 support the language specified by Language, then EFI_UNSUPPORTED is returned.
81 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
82 EFI_COMPONENT_NAME_PROTOCOL instance.
84 @param[in] ControllerHandle The handle of a controller that the driver
85 specified by This is managing. This handle
86 specifies the controller whose name is to be
89 @param[in] ChildHandle The handle of the child controller to retrieve
90 the name of. This is an optional parameter that
91 may be NULL. It will be NULL for device
92 drivers. It will also be NULL for a bus drivers
93 that wish to retrieve the name of the bus
94 controller. It will not be NULL for a bus
95 driver that wishes to retrieve the name of a
98 @param[in] Language A pointer to a Null-terminated ASCII string
99 array indicating the language. This is the
100 language of the driver name that the caller is
101 requesting, and it must match one of the
102 languages specified in SupportedLanguages. The
103 number of languages supported by a driver is up
104 to the driver writer. Language is specified in
105 RFC 4646 or ISO 639-2 language code format.
107 @param[out] ControllerName A pointer to the Unicode string to return.
108 This Unicode string is the name of the
109 controller specified by ControllerHandle and
110 ChildHandle in the language specified by
111 Language from the point of view of the driver
114 @retval EFI_SUCCESS The Unicode string for the user readable name in
115 the language specified by Language for the
116 driver specified by This was returned in
119 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
121 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
124 @retval EFI_INVALID_PARAMETER Language is NULL.
126 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
128 @retval EFI_UNSUPPORTED The driver specified by This is not currently
129 managing the controller specified by
130 ControllerHandle and ChildHandle.
132 @retval EFI_UNSUPPORTED The driver specified by This does not support
133 the language specified by Language.
138 Mtftp4ComponentNameGetControllerName (
139 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
140 IN EFI_HANDLE ControllerHandle
,
141 IN EFI_HANDLE ChildHandle OPTIONAL
,
143 OUT CHAR16
**ControllerName
148 /// EFI Component Name Protocol
150 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMtftp4ComponentName
= {
151 Mtftp4ComponentNameGetDriverName
,
152 Mtftp4ComponentNameGetControllerName
,
157 /// EFI Component Name 2 Protocol
159 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMtftp4ComponentName2
= {
160 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) Mtftp4ComponentNameGetDriverName
,
161 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) Mtftp4ComponentNameGetControllerName
,
166 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp4DriverNameTable
[] = {
169 L
"MTFTP4 Network Service"
177 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gMtftp4ControllerNameTable
= NULL
;
180 Retrieves a Unicode string that is the user readable name of the driver.
182 This function retrieves the user readable name of a driver in the form of a
183 Unicode string. If the driver specified by This has a user readable name in
184 the language specified by Language, then a pointer to the driver name is
185 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
186 by This does not support the language specified by Language,
187 then EFI_UNSUPPORTED is returned.
189 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
190 EFI_COMPONENT_NAME_PROTOCOL instance.
192 @param[in] Language A pointer to a Null-terminated ASCII string
193 array indicating the language. This is the
194 language of the driver name that the caller is
195 requesting, and it must match one of the
196 languages specified in SupportedLanguages. The
197 number of languages supported by a driver is up
198 to the driver writer. Language is specified
199 in RFC 4646 or ISO 639-2 language code format.
201 @param[out] DriverName A pointer to the Unicode string to return.
202 This Unicode string is the name of the
203 driver specified by This in the language
204 specified by Language.
206 @retval EFI_SUCCESS The Unicode string for the Driver specified by
207 This and the language specified by Language was
208 returned in DriverName.
210 @retval EFI_INVALID_PARAMETER Language is NULL.
212 @retval EFI_INVALID_PARAMETER DriverName is NULL.
214 @retval EFI_UNSUPPORTED The driver specified by This does not support
215 the language specified by Language.
220 Mtftp4ComponentNameGetDriverName (
221 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
223 OUT CHAR16
**DriverName
226 return LookupUnicodeString2 (
228 This
->SupportedLanguages
,
229 mMtftp4DriverNameTable
,
231 (BOOLEAN
)(This
== &gMtftp4ComponentName
)
236 Update the component name for the Mtftp4 child handle.
238 @param Mtftp4[in] A pointer to the EFI_MTFTP4_PROTOCOL.
241 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
242 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
247 IN EFI_MTFTP4_PROTOCOL
*Mtftp4
251 CHAR16 HandleName
[80];
252 EFI_MTFTP4_MODE_DATA ModeData
;
254 if (Mtftp4
== NULL
) {
255 return EFI_INVALID_PARAMETER
;
259 // Format the child name into the string buffer as:
260 // MTFTPv4 (ServerIp=192.168.1.10, ServerPort=69)
262 Status
= Mtftp4
->GetModeData (Mtftp4
, &ModeData
);
263 if (EFI_ERROR (Status
)) {
267 UnicodeSPrint (HandleName
, sizeof (HandleName
),
268 L
"MTFTPv4 (ServerIp=%d.%d.%d.%d, ServerPort=%d)",
269 ModeData
.ConfigData
.ServerIp
.Addr
[0],
270 ModeData
.ConfigData
.ServerIp
.Addr
[1],
271 ModeData
.ConfigData
.ServerIp
.Addr
[2],
272 ModeData
.ConfigData
.ServerIp
.Addr
[3],
273 ModeData
.ConfigData
.InitialServerPort
276 if (gMtftp4ControllerNameTable
!= NULL
) {
277 FreeUnicodeStringTable (gMtftp4ControllerNameTable
);
278 gMtftp4ControllerNameTable
= NULL
;
281 Status
= AddUnicodeString2 (
283 gMtftp4ComponentName
.SupportedLanguages
,
284 &gMtftp4ControllerNameTable
,
288 if (EFI_ERROR (Status
)) {
292 return AddUnicodeString2 (
294 gMtftp4ComponentName2
.SupportedLanguages
,
295 &gMtftp4ControllerNameTable
,
302 Retrieves a Unicode string that is the user readable name of the controller
303 that is being managed by a driver.
305 This function retrieves the user readable name of the controller specified by
306 ControllerHandle and ChildHandle in the form of a Unicode string. If the
307 driver specified by This has a user readable name in the language specified by
308 Language, then a pointer to the controller name is returned in ControllerName,
309 and EFI_SUCCESS is returned. If the driver specified by This is not currently
310 managing the controller specified by ControllerHandle and ChildHandle,
311 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
312 support the language specified by Language, then EFI_UNSUPPORTED is returned.
314 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
315 EFI_COMPONENT_NAME_PROTOCOL instance.
317 @param[in] ControllerHandle The handle of a controller that the driver
318 specified by This is managing. This handle
319 specifies the controller whose name is to be
322 @param[in] ChildHandle The handle of the child controller to retrieve
323 the name of. This is an optional parameter that
324 may be NULL. It will be NULL for device
325 drivers. It will also be NULL for a bus drivers
326 that wish to retrieve the name of the bus
327 controller. It will not be NULL for a bus
328 driver that wishes to retrieve the name of a
331 @param[in] Language A pointer to a Null-terminated ASCII string
332 array indicating the language. This is the
333 language of the driver name that the caller is
334 requesting, and it must match one of the
335 languages specified in SupportedLanguages. The
336 number of languages supported by a driver is up
337 to the driver writer. Language is specified in
338 RFC 4646 or ISO 639-2 language code format.
340 @param[out] ControllerName A pointer to the Unicode string to return.
341 This Unicode string is the name of the
342 controller specified by ControllerHandle and
343 ChildHandle in the language specified by
344 Language from the point of view of the driver
347 @retval EFI_SUCCESS The Unicode string for the user readable name in
348 the language specified by Language for the
349 driver specified by This was returned in
352 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
354 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
357 @retval EFI_INVALID_PARAMETER Language is NULL.
359 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
361 @retval EFI_UNSUPPORTED The driver specified by This is not currently
362 managing the controller specified by
363 ControllerHandle and ChildHandle.
365 @retval EFI_UNSUPPORTED The driver specified by This does not support
366 the language specified by Language.
371 Mtftp4ComponentNameGetControllerName (
372 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
373 IN EFI_HANDLE ControllerHandle
,
374 IN EFI_HANDLE ChildHandle OPTIONAL
,
376 OUT CHAR16
**ControllerName
380 EFI_MTFTP4_PROTOCOL
*Mtftp4
;
383 // Only provide names for child handles.
385 if (ChildHandle
== NULL
) {
386 return EFI_UNSUPPORTED
;
390 // Make sure this driver produced ChildHandle
392 Status
= EfiTestChildHandle (
395 &gEfiUdp4ProtocolGuid
397 if (EFI_ERROR (Status
)) {
402 // Retrieve an instance of a produced protocol from ChildHandle
404 Status
= gBS
->OpenProtocol (
406 &gEfiMtftp4ProtocolGuid
,
410 EFI_OPEN_PROTOCOL_GET_PROTOCOL
412 if (EFI_ERROR (Status
)) {
417 // Update the component name for this child handle.
419 Status
= UpdateName (Mtftp4
);
420 if (EFI_ERROR (Status
)) {
424 return LookupUnicodeString2 (
426 This
->SupportedLanguages
,
427 gMtftp4ControllerNameTable
,
429 (BOOLEAN
)(This
== &gMtftp4ComponentName
)