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