]> git.proxmox.com Git - mirror_edk2.git/blob - OptionRomPkg/UndiRuntimeDxe/ComponentName.c
OptionRomPkg: Fix GCC build failure
[mirror_edk2.git] / OptionRomPkg / UndiRuntimeDxe / ComponentName.c
1 /** @file
2 UEFI Component Name(2) protocol implementation for EFI UNDI32 driver.
3
4 Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed
6 and made available under the terms and conditions of the BSD License which
7 accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
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.
12
13 **/
14
15
16 #include "Undi32.h"
17
18 //
19 // EFI Component Name Functions
20 //
21 /**
22 Retrieves a Unicode string that is the user readable name of the driver.
23
24 This function retrieves the user readable name of a driver in the form of a
25 Unicode string. If the driver specified by This has a user readable name in
26 the language specified by Language, then a pointer to the driver name is
27 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
28 by This does not support the language specified by Language,
29 then EFI_UNSUPPORTED is returned.
30
31 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
32 EFI_COMPONENT_NAME_PROTOCOL instance.
33
34 @param Language[in] A pointer to a Null-terminated ASCII string
35 array indicating the language. This is the
36 language of the driver name that the caller is
37 requesting, and it must match one of the
38 languages specified in SupportedLanguages. The
39 number of languages supported by a driver is up
40 to the driver writer. Language is specified
41 in RFC 4646 or ISO 639-2 language code format.
42
43 @param DriverName[out] A pointer to the Unicode string to return.
44 This Unicode string is the name of the
45 driver specified by This in the language
46 specified by Language.
47
48 @retval EFI_SUCCESS The Unicode string for the Driver specified by
49 This and the language specified by Language was
50 returned in DriverName.
51
52 @retval EFI_INVALID_PARAMETER Language is NULL.
53
54 @retval EFI_INVALID_PARAMETER DriverName is NULL.
55
56 @retval EFI_UNSUPPORTED The driver specified by This does not support
57 the language specified by Language.
58
59 **/
60 EFI_STATUS
61 EFIAPI
62 UndiComponentNameGetDriverName (
63 IN EFI_COMPONENT_NAME_PROTOCOL *This,
64 IN CHAR8 *Language,
65 OUT CHAR16 **DriverName
66 );
67
68
69 /**
70 Retrieves a Unicode string that is the user readable name of the controller
71 that is being managed by a driver.
72
73 This function retrieves the user readable name of the controller specified by
74 ControllerHandle and ChildHandle in the form of a Unicode string. If the
75 driver specified by This has a user readable name in the language specified by
76 Language, then a pointer to the controller name is returned in ControllerName,
77 and EFI_SUCCESS is returned. If the driver specified by This is not currently
78 managing the controller specified by ControllerHandle and ChildHandle,
79 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
80 support the language specified by Language, then EFI_UNSUPPORTED is returned.
81
82 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
83 EFI_COMPONENT_NAME_PROTOCOL instance.
84
85 @param ControllerHandle[in] The handle of a controller that the driver
86 specified by This is managing. This handle
87 specifies the controller whose name is to be
88 returned.
89
90 @param ChildHandle[in] The handle of the child controller to retrieve
91 the name of. This is an optional parameter that
92 may be NULL. It will be NULL for device
93 drivers. It will also be NULL for a bus drivers
94 that wish to retrieve the name of the bus
95 controller. It will not be NULL for a bus
96 driver that wishes to retrieve the name of a
97 child controller.
98
99 @param Language[in] A pointer to a Null-terminated ASCII string
100 array indicating the language. This is the
101 language of the driver name that the caller is
102 requesting, and it must match one of the
103 languages specified in SupportedLanguages. The
104 number of languages supported by a driver is up
105 to the driver writer. Language is specified in
106 RFC 4646 or ISO 639-2 language code format.
107
108 @param ControllerName[out] A pointer to the Unicode string to return.
109 This Unicode string is the name of the
110 controller specified by ControllerHandle and
111 ChildHandle in the language specified by
112 Language from the point of view of the driver
113 specified by This.
114
115 @retval EFI_SUCCESS The Unicode string for the user readable name in
116 the language specified by Language for the
117 driver specified by This was returned in
118 DriverName.
119
120 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
121
122 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
123 EFI_HANDLE.
124
125 @retval EFI_INVALID_PARAMETER Language is NULL.
126
127 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
128
129 @retval EFI_UNSUPPORTED The driver specified by This is not currently
130 managing the controller specified by
131 ControllerHandle and ChildHandle.
132
133 @retval EFI_UNSUPPORTED The driver specified by This does not support
134 the language specified by Language.
135
136 **/
137 EFI_STATUS
138 EFIAPI
139 UndiComponentNameGetControllerName (
140 IN EFI_COMPONENT_NAME_PROTOCOL *This,
141 IN EFI_HANDLE ControllerHandle,
142 IN EFI_HANDLE ChildHandle OPTIONAL,
143 IN CHAR8 *Language,
144 OUT CHAR16 **ControllerName
145 );
146
147
148 //
149 // EFI Component Name Protocol
150 //
151 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUndiComponentName = {
152 UndiComponentNameGetDriverName,
153 UndiComponentNameGetControllerName,
154 "eng"
155 };
156
157 //
158 // EFI Component Name 2 Protocol
159 //
160 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUndiComponentName2 = {
161 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UndiComponentNameGetDriverName,
162 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UndiComponentNameGetControllerName,
163 "en"
164 };
165
166
167 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUndiDriverNameTable[] = {
168 {
169 "eng;en",
170 L"UNDI32 Driver"
171 },
172 {
173 NULL,
174 NULL
175 }
176 };
177
178 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUndiControllerNameTable[] = {
179 {
180 "eng;en",
181 L"UNDI32 Controller"
182 },
183 {
184 NULL,
185 NULL
186 }
187 };
188
189 /**
190 Retrieves a Unicode string that is the user readable name of the driver.
191
192 This function retrieves the user readable name of a driver in the form of a
193 Unicode string. If the driver specified by This has a user readable name in
194 the language specified by Language, then a pointer to the driver name is
195 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
196 by This does not support the language specified by Language,
197 then EFI_UNSUPPORTED is returned.
198
199 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
200 EFI_COMPONENT_NAME_PROTOCOL instance.
201
202 @param Language[in] A pointer to a Null-terminated ASCII string
203 array indicating the language. This is the
204 language of the driver name that the caller is
205 requesting, and it must match one of the
206 languages specified in SupportedLanguages. The
207 number of languages supported by a driver is up
208 to the driver writer. Language is specified
209 in RFC 4646 or ISO 639-2 language code format.
210
211 @param DriverName[out] A pointer to the Unicode string to return.
212 This Unicode string is the name of the
213 driver specified by This in the language
214 specified by Language.
215
216 @retval EFI_SUCCESS The Unicode string for the Driver specified by
217 This and the language specified by Language was
218 returned in DriverName.
219
220 @retval EFI_INVALID_PARAMETER Language is NULL.
221
222 @retval EFI_INVALID_PARAMETER DriverName is NULL.
223
224 @retval EFI_UNSUPPORTED The driver specified by This does not support
225 the language specified by Language.
226
227 **/
228 EFI_STATUS
229 EFIAPI
230 UndiComponentNameGetDriverName (
231 IN EFI_COMPONENT_NAME_PROTOCOL *This,
232 IN CHAR8 *Language,
233 OUT CHAR16 **DriverName
234 )
235 {
236 return LookupUnicodeString2 (
237 Language,
238 This->SupportedLanguages,
239 mUndiDriverNameTable,
240 DriverName,
241 (BOOLEAN)(This == &gUndiComponentName)
242 );
243 }
244
245 /**
246 Retrieves a Unicode string that is the user readable name of the controller
247 that is being managed by a driver.
248
249 This function retrieves the user readable name of the controller specified by
250 ControllerHandle and ChildHandle in the form of a Unicode string. If the
251 driver specified by This has a user readable name in the language specified by
252 Language, then a pointer to the controller name is returned in ControllerName,
253 and EFI_SUCCESS is returned. If the driver specified by This is not currently
254 managing the controller specified by ControllerHandle and ChildHandle,
255 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
256 support the language specified by Language, then EFI_UNSUPPORTED is returned.
257 Currently not implemented.
258
259 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
260 EFI_COMPONENT_NAME_PROTOCOL instance.
261
262 @param ControllerHandle[in] The handle of a controller that the driver
263 specified by This is managing. This handle
264 specifies the controller whose name is to be
265 returned.
266
267 @param ChildHandle[in] The handle of the child controller to retrieve
268 the name of. This is an optional parameter that
269 may be NULL. It will be NULL for device
270 drivers. It will also be NULL for a bus drivers
271 that wish to retrieve the name of the bus
272 controller. It will not be NULL for a bus
273 driver that wishes to retrieve the name of a
274 child controller.
275
276 @param Language[in] A pointer to a Null-terminated ASCII string
277 array indicating the language. This is the
278 language of the driver name that the caller is
279 requesting, and it must match one of the
280 languages specified in SupportedLanguages. The
281 number of languages supported by a driver is up
282 to the driver writer. Language is specified in
283 RFC 4646 or ISO 639-2 language code format.
284
285 @param ControllerName[out] A pointer to the Unicode string to return.
286 This Unicode string is the name of the
287 controller specified by ControllerHandle and
288 ChildHandle in the language specified by
289 Language from the point of view of the driver
290 specified by This.
291
292 @retval EFI_SUCCESS The Unicode string for the user readable name in
293 the language specified by Language for the
294 driver specified by This was returned in
295 DriverName.
296
297 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
298
299 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
300 EFI_HANDLE.
301
302 @retval EFI_INVALID_PARAMETER Language is NULL.
303
304 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
305
306 @retval EFI_UNSUPPORTED The driver specified by This is not currently
307 managing the controller specified by
308 ControllerHandle and ChildHandle.
309
310 @retval EFI_UNSUPPORTED The driver specified by This does not support
311 the language specified by Language.
312
313 **/
314 EFI_STATUS
315 EFIAPI
316 UndiComponentNameGetControllerName (
317 IN EFI_COMPONENT_NAME_PROTOCOL *This,
318 IN EFI_HANDLE ControllerHandle,
319 IN EFI_HANDLE ChildHandle OPTIONAL,
320 IN CHAR8 *Language,
321 OUT CHAR16 **ControllerName
322 )
323 {
324 EFI_STATUS Status;
325 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
326
327 if (ChildHandle != NULL) {
328 return EFI_UNSUPPORTED;
329 }
330
331 //
332 // Make sure this driver is currently managing ControllHandle
333 //
334 Status = EfiTestManagedDevice (
335 ControllerHandle,
336 gUndiDriverBinding.DriverBindingHandle,
337 &gEfiPciIoProtocolGuid
338 );
339 if (EFI_ERROR (Status)) {
340 return Status;
341 }
342
343 //
344 // Retrieve an instance of a produced protocol from ControllerHandle
345 //
346 Status = gBS->OpenProtocol (
347 ControllerHandle,
348 &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
349 (VOID **)&Nii,
350 NULL,
351 NULL,
352 EFI_OPEN_PROTOCOL_GET_PROTOCOL
353 );
354 if (EFI_ERROR (Status)) {
355 return Status;
356 }
357
358 return LookupUnicodeString2 (
359 Language,
360 This->SupportedLanguages,
361 mUndiControllerNameTable,
362 ControllerName,
363 (BOOLEAN)(This == &gUndiComponentName)
364 );
365 }