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