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