]>
Commit | Line | Data |
---|---|---|
8a67d61d | 1 | /** @file\r |
2 | \r | |
d1102dba | 3 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 4 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
8a67d61d | 5 | \r |
8a67d61d | 6 | **/\r |
7 | \r | |
8a67d61d | 8 | #include "Udp4Impl.h"\r |
9 | \r | |
10 | //\r | |
11 | // EFI Component Name Functions\r | |
12 | //\r | |
d1050b9d | 13 | \r |
83cbd279 | 14 | /**\r |
15 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
16 | \r | |
17 | This function retrieves the user readable name of a driver in the form of a\r | |
18 | Unicode string. If the driver specified by This has a user readable name in\r | |
19 | the language specified by Language, then a pointer to the driver name is\r | |
20 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
21 | by This does not support the language specified by Language,\r | |
22 | then EFI_UNSUPPORTED is returned.\r | |
23 | \r | |
3e8c18da | 24 | @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
83cbd279 | 25 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
26 | \r | |
3e8c18da | 27 | @param[in] Language A pointer to a Null-terminated ASCII string\r |
83cbd279 | 28 | array indicating the language. This is the\r |
29 | language of the driver name that the caller is\r | |
30 | requesting, and it must match one of the\r | |
31 | languages specified in SupportedLanguages. The\r | |
32 | number of languages supported by a driver is up\r | |
33 | to the driver writer. Language is specified\r | |
0254efc0 | 34 | in RFC 4646 or ISO 639-2 language code format.\r |
83cbd279 | 35 | \r |
3e8c18da | 36 | @param[out] DriverName A pointer to the Unicode string to return.\r |
83cbd279 | 37 | This Unicode string is the name of the\r |
38 | driver specified by This in the language\r | |
39 | specified by Language.\r | |
40 | \r | |
41 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
42 | This and the language specified by Language was\r | |
43 | returned in DriverName.\r | |
44 | \r | |
45 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
46 | \r | |
47 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
48 | \r | |
49 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
50 | the language specified by Language.\r | |
51 | \r | |
52 | **/\r | |
8a67d61d | 53 | EFI_STATUS\r |
54 | EFIAPI\r | |
55 | UdpComponentNameGetDriverName (\r | |
56 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
57 | IN CHAR8 *Language,\r | |
58 | OUT CHAR16 **DriverName\r | |
59 | );\r | |
60 | \r | |
83cbd279 | 61 | /**\r |
62 | Retrieves a Unicode string that is the user readable name of the controller\r | |
63 | that is being managed by a driver.\r | |
64 | \r | |
65 | This function retrieves the user readable name of the controller specified by\r | |
66 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
67 | driver specified by This has a user readable name in the language specified by\r | |
68 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
69 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
70 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
71 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
72 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
73 | \r | |
3e8c18da | 74 | @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
83cbd279 | 75 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
76 | \r | |
3e8c18da | 77 | @param[in] ControllerHandle The handle of a controller that the driver\r |
83cbd279 | 78 | specified by This is managing. This handle\r |
79 | specifies the controller whose name is to be\r | |
80 | returned.\r | |
81 | \r | |
3e8c18da | 82 | @param[in] ChildHandle The handle of the child controller to retrieve\r |
83cbd279 | 83 | the name of. This is an optional parameter that\r |
84 | may be NULL. It will be NULL for device\r | |
85 | drivers. It will also be NULL for a bus drivers\r | |
86 | that wish to retrieve the name of the bus\r | |
87 | controller. It will not be NULL for a bus\r | |
88 | driver that wishes to retrieve the name of a\r | |
89 | child controller.\r | |
90 | \r | |
3e8c18da | 91 | @param[in] Language A pointer to a Null-terminated ASCII string\r |
83cbd279 | 92 | array indicating the language. This is the\r |
93 | language of the driver name that the caller is\r | |
94 | requesting, and it must match one of the\r | |
95 | languages specified in SupportedLanguages. The\r | |
96 | number of languages supported by a driver is up\r | |
97 | to the driver writer. Language is specified in\r | |
0254efc0 | 98 | RFC 4646 or ISO 639-2 language code format.\r |
83cbd279 | 99 | \r |
3e8c18da | 100 | @param[out] ControllerName A pointer to the Unicode string to return.\r |
83cbd279 | 101 | This Unicode string is the name of the\r |
102 | controller specified by ControllerHandle and\r | |
103 | ChildHandle in the language specified by\r | |
104 | Language from the point of view of the driver\r | |
105 | specified by This.\r | |
106 | \r | |
107 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
108 | the language specified by Language for the\r | |
109 | driver specified by This was returned in\r | |
110 | DriverName.\r | |
111 | \r | |
284ee2e8 | 112 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r |
83cbd279 | 113 | \r |
114 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
115 | EFI_HANDLE.\r | |
116 | \r | |
117 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
118 | \r | |
119 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
120 | \r | |
121 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
122 | managing the controller specified by\r | |
123 | ControllerHandle and ChildHandle.\r | |
124 | \r | |
125 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
126 | the language specified by Language.\r | |
127 | \r | |
128 | **/\r | |
8a67d61d | 129 | EFI_STATUS\r |
130 | EFIAPI\r | |
131 | UdpComponentNameGetControllerName (\r | |
d1050b9d MK |
132 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
133 | IN EFI_HANDLE ControllerHandle,\r | |
134 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
135 | IN CHAR8 *Language,\r | |
136 | OUT CHAR16 **ControllerName\r | |
8a67d61d | 137 | );\r |
138 | \r | |
139 | //\r | |
140 | // EFI Component Name Protocol\r | |
141 | //\r | |
1307dcd7 | 142 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName = {\r |
8a67d61d | 143 | UdpComponentNameGetDriverName,\r |
144 | UdpComponentNameGetControllerName,\r | |
145 | "eng"\r | |
1307dcd7 | 146 | };\r |
83cbd279 | 147 | \r |
148 | //\r | |
149 | // EFI Component Name 2 Protocol\r | |
150 | //\r | |
d1050b9d MK |
151 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUdp4ComponentName2 = {\r |
152 | (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)UdpComponentNameGetDriverName,\r | |
153 | (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)UdpComponentNameGetControllerName,\r | |
83cbd279 | 154 | "en"\r |
1307dcd7 | 155 | };\r |
83cbd279 | 156 | \r |
d1050b9d | 157 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUdpDriverNameTable[] = {\r |
8a67d61d | 158 | {\r |
83cbd279 | 159 | "eng;en",\r |
8a67d61d | 160 | L"UDP Network Service Driver"\r |
161 | },\r | |
162 | {\r | |
163 | NULL,\r | |
164 | NULL\r | |
165 | }\r | |
166 | };\r | |
167 | \r | |
d1050b9d | 168 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gUdpControllerNameTable = NULL;\r |
d1102dba | 169 | \r |
83cbd279 | 170 | /**\r |
171 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
172 | \r | |
173 | This function retrieves the user readable name of a driver in the form of a\r | |
174 | Unicode string. If the driver specified by This has a user readable name in\r | |
175 | the language specified by Language, then a pointer to the driver name is\r | |
176 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
177 | by This does not support the language specified by Language,\r | |
178 | then EFI_UNSUPPORTED is returned.\r | |
179 | \r | |
3e8c18da | 180 | @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
83cbd279 | 181 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
182 | \r | |
3e8c18da | 183 | @param[in] Language A pointer to a Null-terminated ASCII string\r |
83cbd279 | 184 | array indicating the language. This is the\r |
185 | language of the driver name that the caller is\r | |
186 | requesting, and it must match one of the\r | |
187 | languages specified in SupportedLanguages. The\r | |
188 | number of languages supported by a driver is up\r | |
189 | to the driver writer. Language is specified\r | |
0254efc0 | 190 | in RFC 4646 or ISO 639-2 language code format.\r |
83cbd279 | 191 | \r |
3e8c18da | 192 | @param[out] DriverName A pointer to the Unicode string to return.\r |
83cbd279 | 193 | This Unicode string is the name of the\r |
194 | driver specified by This in the language\r | |
195 | specified by Language.\r | |
196 | \r | |
197 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
198 | This and the language specified by Language was\r | |
199 | returned in DriverName.\r | |
200 | \r | |
201 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
202 | \r | |
203 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
204 | \r | |
205 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
206 | the language specified by Language.\r | |
207 | \r | |
208 | **/\r | |
8a67d61d | 209 | EFI_STATUS\r |
210 | EFIAPI\r | |
211 | UdpComponentNameGetDriverName (\r | |
212 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
213 | IN CHAR8 *Language,\r | |
214 | OUT CHAR16 **DriverName\r | |
215 | )\r | |
83cbd279 | 216 | {\r |
217 | return LookupUnicodeString2 (\r | |
218 | Language,\r | |
219 | This->SupportedLanguages,\r | |
220 | mUdpDriverNameTable,\r | |
221 | DriverName,\r | |
222 | (BOOLEAN)(This == &gUdp4ComponentName)\r | |
223 | );\r | |
224 | }\r | |
8a67d61d | 225 | \r |
216f7970 | 226 | /**\r |
227 | Update the component name for the Udp4 child handle.\r | |
228 | \r | |
229 | @param Udp4[in] A pointer to the EFI_UDP4_PROTOCOL.\r | |
230 | \r | |
d1102dba | 231 | \r |
216f7970 | 232 | @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.\r |
233 | @retval EFI_INVALID_PARAMETER The input parameter is invalid.\r | |
d1102dba | 234 | \r |
216f7970 | 235 | **/\r |
236 | EFI_STATUS\r | |
237 | UpdateName (\r | |
d1050b9d | 238 | EFI_UDP4_PROTOCOL *Udp4\r |
216f7970 | 239 | )\r |
240 | {\r | |
d1050b9d MK |
241 | EFI_STATUS Status;\r |
242 | CHAR16 HandleName[64];\r | |
243 | EFI_UDP4_CONFIG_DATA Udp4ConfigData;\r | |
216f7970 | 244 | \r |
245 | if (Udp4 == NULL) {\r | |
246 | return EFI_INVALID_PARAMETER;\r | |
247 | }\r | |
248 | \r | |
249 | //\r | |
250 | // Format the child name into the string buffer as:\r | |
251 | // UDPv4 (SrcPort=59, DestPort=60)\r | |
252 | //\r | |
253 | Status = Udp4->GetModeData (Udp4, &Udp4ConfigData, NULL, NULL, NULL);\r | |
254 | if (!EFI_ERROR (Status)) {\r | |
d1050b9d MK |
255 | UnicodeSPrint (\r |
256 | HandleName,\r | |
257 | sizeof (HandleName),\r | |
216f7970 | 258 | L"UDPv4 (SrcPort=%d, DestPort=%d)",\r |
259 | Udp4ConfigData.StationPort,\r | |
260 | Udp4ConfigData.RemotePort\r | |
261 | );\r | |
262 | } else if (Status == EFI_NOT_STARTED) {\r | |
263 | UnicodeSPrint (\r | |
264 | HandleName,\r | |
265 | sizeof (HandleName),\r | |
266 | L"UDPv4 (Not started)"\r | |
267 | );\r | |
268 | } else {\r | |
269 | return Status;\r | |
270 | }\r | |
271 | \r | |
272 | if (gUdpControllerNameTable != NULL) {\r | |
273 | FreeUnicodeStringTable (gUdpControllerNameTable);\r | |
274 | gUdpControllerNameTable = NULL;\r | |
275 | }\r | |
d1102dba | 276 | \r |
216f7970 | 277 | Status = AddUnicodeString2 (\r |
278 | "eng",\r | |
279 | gUdp4ComponentName.SupportedLanguages,\r | |
280 | &gUdpControllerNameTable,\r | |
281 | HandleName,\r | |
282 | TRUE\r | |
283 | );\r | |
284 | if (EFI_ERROR (Status)) {\r | |
285 | return Status;\r | |
286 | }\r | |
d1102dba | 287 | \r |
216f7970 | 288 | return AddUnicodeString2 (\r |
289 | "en",\r | |
290 | gUdp4ComponentName2.SupportedLanguages,\r | |
291 | &gUdpControllerNameTable,\r | |
292 | HandleName,\r | |
293 | FALSE\r | |
294 | );\r | |
295 | }\r | |
296 | \r | |
83cbd279 | 297 | /**\r |
298 | Retrieves a Unicode string that is the user readable name of the controller\r | |
299 | that is being managed by a driver.\r | |
8a67d61d | 300 | \r |
83cbd279 | 301 | This function retrieves the user readable name of the controller specified by\r |
302 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
303 | driver specified by This has a user readable name in the language specified by\r | |
304 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
305 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
306 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
307 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
308 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
8a67d61d | 309 | \r |
3e8c18da | 310 | @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
83cbd279 | 311 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
8a67d61d | 312 | \r |
3e8c18da | 313 | @param[in] ControllerHandle The handle of a controller that the driver\r |
83cbd279 | 314 | specified by This is managing. This handle\r |
315 | specifies the controller whose name is to be\r | |
316 | returned.\r | |
8a67d61d | 317 | \r |
3e8c18da | 318 | @param[in] ChildHandle The handle of the child controller to retrieve\r |
83cbd279 | 319 | the name of. This is an optional parameter that\r |
320 | may be NULL. It will be NULL for device\r | |
321 | drivers. It will also be NULL for a bus drivers\r | |
322 | that wish to retrieve the name of the bus\r | |
323 | controller. It will not be NULL for a bus\r | |
324 | driver that wishes to retrieve the name of a\r | |
325 | child controller.\r | |
8a67d61d | 326 | \r |
3e8c18da | 327 | @param[in] Language A pointer to a Null-terminated ASCII string\r |
83cbd279 | 328 | array indicating the language. This is the\r |
329 | language of the driver name that the caller is\r | |
330 | requesting, and it must match one of the\r | |
331 | languages specified in SupportedLanguages. The\r | |
332 | number of languages supported by a driver is up\r | |
333 | to the driver writer. Language is specified in\r | |
0254efc0 | 334 | RFC 4646 or ISO 639-2 language code format.\r |
8a67d61d | 335 | \r |
3e8c18da | 336 | @param[out] ControllerName A pointer to the Unicode string to return.\r |
83cbd279 | 337 | This Unicode string is the name of the\r |
338 | controller specified by ControllerHandle and\r | |
339 | ChildHandle in the language specified by\r | |
340 | Language from the point of view of the driver\r | |
341 | specified by This.\r | |
342 | \r | |
343 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
344 | the language specified by Language for the\r | |
345 | driver specified by This was returned in\r | |
346 | DriverName.\r | |
347 | \r | |
284ee2e8 | 348 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r |
83cbd279 | 349 | \r |
350 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
351 | EFI_HANDLE.\r | |
352 | \r | |
353 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
354 | \r | |
355 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
356 | \r | |
357 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
358 | managing the controller specified by\r | |
359 | ControllerHandle and ChildHandle.\r | |
8a67d61d | 360 | \r |
83cbd279 | 361 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
362 | the language specified by Language.\r | |
363 | \r | |
364 | **/\r | |
8a67d61d | 365 | EFI_STATUS\r |
366 | EFIAPI\r | |
367 | UdpComponentNameGetControllerName (\r | |
d1050b9d MK |
368 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
369 | IN EFI_HANDLE ControllerHandle,\r | |
370 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
371 | IN CHAR8 *Language,\r | |
372 | OUT CHAR16 **ControllerName\r | |
8a67d61d | 373 | )\r |
8a67d61d | 374 | {\r |
d1050b9d MK |
375 | EFI_STATUS Status;\r |
376 | EFI_UDP4_PROTOCOL *Udp4;\r | |
216f7970 | 377 | \r |
378 | //\r | |
379 | // Only provide names for child handles.\r | |
380 | //\r | |
381 | if (ChildHandle == NULL) {\r | |
382 | return EFI_UNSUPPORTED;\r | |
383 | }\r | |
d1102dba | 384 | \r |
216f7970 | 385 | //\r |
386 | // Make sure this driver produced ChildHandle\r | |
387 | //\r | |
388 | Status = EfiTestChildHandle (\r | |
389 | ControllerHandle,\r | |
390 | ChildHandle,\r | |
391 | &gEfiIp4ProtocolGuid\r | |
392 | );\r | |
393 | if (EFI_ERROR (Status)) {\r | |
394 | return Status;\r | |
395 | }\r | |
396 | \r | |
397 | //\r | |
398 | // Retrieve an instance of a produced protocol from ChildHandle\r | |
399 | //\r | |
400 | Status = gBS->OpenProtocol (\r | |
401 | ChildHandle,\r | |
402 | &gEfiUdp4ProtocolGuid,\r | |
403 | (VOID **)&Udp4,\r | |
404 | NULL,\r | |
405 | NULL,\r | |
406 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
407 | );\r | |
408 | if (EFI_ERROR (Status)) {\r | |
409 | return Status;\r | |
410 | }\r | |
411 | \r | |
412 | //\r | |
413 | // Update the component name for this child handle.\r | |
414 | //\r | |
415 | Status = UpdateName (Udp4);\r | |
416 | if (EFI_ERROR (Status)) {\r | |
417 | return Status;\r | |
418 | }\r | |
419 | \r | |
420 | return LookupUnicodeString2 (\r | |
421 | Language,\r | |
422 | This->SupportedLanguages,\r | |
423 | gUdpControllerNameTable,\r | |
424 | ControllerName,\r | |
425 | (BOOLEAN)(This == &gUdp4ComponentName)\r | |
426 | );\r | |
8a67d61d | 427 | }\r |