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