3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
16 // The package level header files this module uses
21 // The protocols, PPI and GUID defintions for this module
23 #include <Guid/EventGroup.h>
24 #include <Protocol/WinNtIo.h>
25 #include <Protocol/ComponentName.h>
26 #include <Protocol/SimpleTextIn.h>
27 #include <Protocol/DriverBinding.h>
28 #include <Protocol/GraphicsOutput.h>
30 // The Library classes this module consumes
32 #include <Library/DebugLib.h>
33 #include <Library/BaseLib.h>
34 #include <Library/UefiDriverEntryPoint.h>
35 #include <Library/UefiLib.h>
36 #include <Library/BaseMemoryLib.h>
37 #include <Library/UefiBootServicesTableLib.h>
38 #include <Library/MemoryAllocationLib.h>
43 // EFI Component Name Functions
46 Retrieves a Unicode string that is the user readable name of the driver.
48 This function retrieves the user readable name of a driver in the form of a
49 Unicode string. If the driver specified by This has a user readable name in
50 the language specified by Language, then a pointer to the driver name is
51 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
52 by This does not support the language specified by Language,
53 then EFI_UNSUPPORTED is returned.
55 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
56 EFI_COMPONENT_NAME_PROTOCOL instance.
58 @param Language[in] A pointer to a Null-terminated ASCII string
59 array indicating the language. This is the
60 language of the driver name that the caller is
61 requesting, and it must match one of the
62 languages specified in SupportedLanguages. The
63 number of languages supported by a driver is up
64 to the driver writer. Language is specified
65 in RFC 4646 or ISO 639-2 language code format.
67 @param DriverName[out] A pointer to the Unicode string to return.
68 This Unicode string is the name of the
69 driver specified by This in the language
70 specified by Language.
72 @retval EFI_SUCCESS The Unicode string for the Driver specified by
73 This and the language specified by Language was
74 returned in DriverName.
76 @retval EFI_INVALID_PARAMETER Language is NULL.
78 @retval EFI_INVALID_PARAMETER DriverName is NULL.
80 @retval EFI_UNSUPPORTED The driver specified by This does not support
81 the language specified by Language.
86 WinNtGopComponentNameGetDriverName (
87 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
89 OUT CHAR16
**DriverName
94 Retrieves a Unicode string that is the user readable name of the controller
95 that is being managed by a driver.
97 This function retrieves the user readable name of the controller specified by
98 ControllerHandle and ChildHandle in the form of a Unicode string. If the
99 driver specified by This has a user readable name in the language specified by
100 Language, then a pointer to the controller name is returned in ControllerName,
101 and EFI_SUCCESS is returned. If the driver specified by This is not currently
102 managing the controller specified by ControllerHandle and ChildHandle,
103 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
104 support the language specified by Language, then EFI_UNSUPPORTED is returned.
106 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
107 EFI_COMPONENT_NAME_PROTOCOL instance.
109 @param ControllerHandle[in] The handle of a controller that the driver
110 specified by This is managing. This handle
111 specifies the controller whose name is to be
114 @param ChildHandle[in] The handle of the child controller to retrieve
115 the name of. This is an optional parameter that
116 may be NULL. It will be NULL for device
117 drivers. It will also be NULL for a bus drivers
118 that wish to retrieve the name of the bus
119 controller. It will not be NULL for a bus
120 driver that wishes to retrieve the name of a
123 @param Language[in] A pointer to a Null-terminated ASCII string
124 array indicating the language. This is the
125 language of the driver name that the caller is
126 requesting, and it must match one of the
127 languages specified in SupportedLanguages. The
128 number of languages supported by a driver is up
129 to the driver writer. Language is specified in
130 RFC 4646 or ISO 639-2 language code format.
132 @param ControllerName[out] A pointer to the Unicode string to return.
133 This Unicode string is the name of the
134 controller specified by ControllerHandle and
135 ChildHandle in the language specified by
136 Language from the point of view of the driver
139 @retval EFI_SUCCESS The Unicode string for the user readable name in
140 the language specified by Language for the
141 driver specified by This was returned in
144 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
146 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
149 @retval EFI_INVALID_PARAMETER Language is NULL.
151 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
153 @retval EFI_UNSUPPORTED The driver specified by This is not currently
154 managing the controller specified by
155 ControllerHandle and ChildHandle.
157 @retval EFI_UNSUPPORTED The driver specified by This does not support
158 the language specified by Language.
163 WinNtGopComponentNameGetControllerName (
164 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
165 IN EFI_HANDLE ControllerHandle
,
166 IN EFI_HANDLE ChildHandle OPTIONAL
,
168 OUT CHAR16
**ControllerName
173 // EFI Component Name Protocol
175 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtGopComponentName
= {
176 WinNtGopComponentNameGetDriverName
,
177 WinNtGopComponentNameGetControllerName
,
182 // EFI Component Name 2 Protocol
184 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtGopComponentName2
= {
185 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) WinNtGopComponentNameGetDriverName
,
186 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) WinNtGopComponentNameGetControllerName
,
191 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtGopDriverNameTable
[] = {
192 { "eng;en", L
"Windows GOP Driver" },
198 Retrieves a Unicode string that is the user readable name of the driver.
200 This function retrieves the user readable name of a driver in the form of a
201 Unicode string. If the driver specified by This has a user readable name in
202 the language specified by Language, then a pointer to the driver name is
203 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
204 by This does not support the language specified by Language,
205 then EFI_UNSUPPORTED is returned.
207 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
208 EFI_COMPONENT_NAME_PROTOCOL instance.
210 @param Language[in] A pointer to a Null-terminated ASCII string
211 array indicating the language. This is the
212 language of the driver name that the caller is
213 requesting, and it must match one of the
214 languages specified in SupportedLanguages. The
215 number of languages supported by a driver is up
216 to the driver writer. Language is specified
217 in RFC 4646 or ISO 639-2 language code format.
219 @param DriverName[out] A pointer to the Unicode string to return.
220 This Unicode string is the name of the
221 driver specified by This in the language
222 specified by Language.
224 @retval EFI_SUCCESS The Unicode string for the Driver specified by
225 This and the language specified by Language was
226 returned in DriverName.
228 @retval EFI_INVALID_PARAMETER Language is NULL.
230 @retval EFI_INVALID_PARAMETER DriverName is NULL.
232 @retval EFI_UNSUPPORTED The driver specified by This does not support
233 the language specified by Language.
238 WinNtGopComponentNameGetDriverName (
239 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
241 OUT CHAR16
**DriverName
244 return LookupUnicodeString2 (
246 This
->SupportedLanguages
,
247 mWinNtGopDriverNameTable
,
249 (BOOLEAN
)(This
== &gWinNtGopComponentName
)
255 Retrieves a Unicode string that is the user readable name of the controller
256 that is being managed by a driver.
258 This function retrieves the user readable name of the controller specified by
259 ControllerHandle and ChildHandle in the form of a Unicode string. If the
260 driver specified by This has a user readable name in the language specified by
261 Language, then a pointer to the controller name is returned in ControllerName,
262 and EFI_SUCCESS is returned. If the driver specified by This is not currently
263 managing the controller specified by ControllerHandle and ChildHandle,
264 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
265 support the language specified by Language, then EFI_UNSUPPORTED is returned.
267 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
268 EFI_COMPONENT_NAME_PROTOCOL instance.
270 @param ControllerHandle[in] The handle of a controller that the driver
271 specified by This is managing. This handle
272 specifies the controller whose name is to be
275 @param ChildHandle[in] The handle of the child controller to retrieve
276 the name of. This is an optional parameter that
277 may be NULL. It will be NULL for device
278 drivers. It will also be NULL for a bus drivers
279 that wish to retrieve the name of the bus
280 controller. It will not be NULL for a bus
281 driver that wishes to retrieve the name of a
284 @param Language[in] A pointer to a Null-terminated ASCII string
285 array indicating the language. This is the
286 language of the driver name that the caller is
287 requesting, and it must match one of the
288 languages specified in SupportedLanguages. The
289 number of languages supported by a driver is up
290 to the driver writer. Language is specified in
291 RFC 4646 or ISO 639-2 language code format.
293 @param ControllerName[out] A pointer to the Unicode string to return.
294 This Unicode string is the name of the
295 controller specified by ControllerHandle and
296 ChildHandle in the language specified by
297 Language from the point of view of the driver
300 @retval EFI_SUCCESS The Unicode string for the user readable name in
301 the language specified by Language for the
302 driver specified by This was returned in
305 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
307 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
310 @retval EFI_INVALID_PARAMETER Language is NULL.
312 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
314 @retval EFI_UNSUPPORTED The driver specified by This is not currently
315 managing the controller specified by
316 ControllerHandle and ChildHandle.
318 @retval EFI_UNSUPPORTED The driver specified by This does not support
319 the language specified by Language.
324 WinNtGopComponentNameGetControllerName (
325 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
326 IN EFI_HANDLE ControllerHandle
,
327 IN EFI_HANDLE ChildHandle OPTIONAL
,
329 OUT CHAR16
**ControllerName
333 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
334 GOP_PRIVATE_DATA
*Private
;
337 // This is a device driver, so ChildHandle must be NULL.
339 if (ChildHandle
!= NULL
) {
340 return EFI_UNSUPPORTED
;
343 // Make sure this driver is currently managing ControllerHandle
345 Status
= EfiTestManagedDevice (
347 gWinNtGopDriverBinding
.DriverBindingHandle
,
348 &gEfiWinNtIoProtocolGuid
350 if (EFI_ERROR (Status
)) {
351 return EFI_UNSUPPORTED
;
354 // Get our context back
356 Status
= gBS
->OpenProtocol (
358 &gEfiGraphicsOutputProtocolGuid
,
359 (VOID
**) &GraphicsOutput
,
360 gWinNtGopDriverBinding
.DriverBindingHandle
,
362 EFI_OPEN_PROTOCOL_GET_PROTOCOL
364 if (EFI_ERROR (Status
)) {
365 return EFI_UNSUPPORTED
;
368 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
370 return LookupUnicodeString2 (
372 This
->SupportedLanguages
,
373 Private
->ControllerNameTable
,
375 (BOOLEAN
)(This
== &gWinNtGopComponentName
)