3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
15 // The package level header files this module uses
20 // The protocols, PPI and GUID defintions for this module
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>
29 #include "WinNtBusDriver.h"
32 // EFI Component Name Functions
35 Retrieves a Unicode string that is the user readable name of the driver.
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.
44 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
45 EFI_COMPONENT_NAME_PROTOCOL instance.
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.
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.
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.
65 @retval EFI_INVALID_PARAMETER Language is NULL.
67 @retval EFI_INVALID_PARAMETER DriverName is NULL.
69 @retval EFI_UNSUPPORTED The driver specified by This does not support
70 the language specified by Language.
75 WinNtBusDriverComponentNameGetDriverName (
76 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
78 OUT CHAR16
**DriverName
83 Retrieves a Unicode string that is the user readable name of the controller
84 that is being managed by a driver.
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.
95 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
96 EFI_COMPONENT_NAME_PROTOCOL instance.
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
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
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.
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
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
133 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
135 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
138 @retval EFI_INVALID_PARAMETER Language is NULL.
140 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
142 @retval EFI_UNSUPPORTED The driver specified by This is not currently
143 managing the controller specified by
144 ControllerHandle and ChildHandle.
146 @retval EFI_UNSUPPORTED The driver specified by This does not support
147 the language specified by Language.
152 WinNtBusDriverComponentNameGetControllerName (
153 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
154 IN EFI_HANDLE ControllerHandle
,
155 IN EFI_HANDLE ChildHandle OPTIONAL
,
157 OUT CHAR16
**ControllerName
162 // EFI Component Name Protocol
164 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtBusDriverComponentName
= {
165 WinNtBusDriverComponentNameGetDriverName
,
166 WinNtBusDriverComponentNameGetControllerName
,
171 // EFI Component Name 2 Protocol
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
,
180 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtBusDriverNameTable
[] = {
181 { "eng;en", L
"Windows Bus Driver" },
186 Retrieves a Unicode string that is the user readable name of the driver.
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.
195 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
196 EFI_COMPONENT_NAME_PROTOCOL instance.
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.
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.
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.
216 @retval EFI_INVALID_PARAMETER Language is NULL.
218 @retval EFI_INVALID_PARAMETER DriverName is NULL.
220 @retval EFI_UNSUPPORTED The driver specified by This does not support
221 the language specified by Language.
226 WinNtBusDriverComponentNameGetDriverName (
227 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
229 OUT CHAR16
**DriverName
232 return LookupUnicodeString2 (
234 This
->SupportedLanguages
,
235 mWinNtBusDriverNameTable
,
237 (BOOLEAN
)(This
== &gWinNtBusDriverComponentName
)
242 Retrieves a Unicode string that is the user readable name of the controller
243 that is being managed by a driver.
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.
254 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
255 EFI_COMPONENT_NAME_PROTOCOL instance.
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
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
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.
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
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
292 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
294 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
297 @retval EFI_INVALID_PARAMETER Language is NULL.
299 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
301 @retval EFI_UNSUPPORTED The driver specified by This is not currently
302 managing the controller specified by
303 ControllerHandle and ChildHandle.
305 @retval EFI_UNSUPPORTED The driver specified by This does not support
306 the language specified by Language.
311 WinNtBusDriverComponentNameGetControllerName (
312 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
313 IN EFI_HANDLE ControllerHandle
,
314 IN EFI_HANDLE ChildHandle OPTIONAL
,
316 OUT CHAR16
**ControllerName
320 EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
;
321 WIN_NT_IO_DEVICE
*Private
;
324 // Make sure this driver is currently managing ControllHandle
326 Status
= EfiTestManagedDevice (
328 gWinNtBusDriverBinding
.DriverBindingHandle
,
329 &gEfiWinNtThunkProtocolGuid
331 if (EFI_ERROR (Status
)) {
336 // This is a bus driver, so ChildHandle can not be NULL.
338 if (ChildHandle
== NULL
) {
339 return EFI_UNSUPPORTED
;
342 Status
= EfiTestChildHandle (
345 &gEfiWinNtThunkProtocolGuid
347 if (EFI_ERROR (Status
)) {
352 // Get our context back
354 Status
= gBS
->OpenProtocol (
356 &gEfiWinNtIoProtocolGuid
,
358 gWinNtBusDriverBinding
.DriverBindingHandle
,
360 EFI_OPEN_PROTOCOL_GET_PROTOCOL
362 if (EFI_ERROR (Status
)) {
363 return EFI_UNSUPPORTED
;
366 Private
= WIN_NT_IO_DEVICE_FROM_THIS (WinNtIo
);
368 return LookupUnicodeString2 (
370 This
->SupportedLanguages
,
371 Private
->ControllerNameTable
,
373 (BOOLEAN
)(This
== &gWinNtBusDriverComponentName
)