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