3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 // The package level header files this module uses
27 // The protocols, PPI and GUID defintions for this module
29 #include <Guid/EventGroup.h>
30 #include <Protocol/WinNtIo.h>
31 #include <Protocol/ComponentName.h>
32 #include <Protocol/SimpleTextIn.h>
33 #include <Protocol/DriverBinding.h>
34 #include <Protocol/GraphicsOutput.h>
36 // The Library classes this module consumes
38 #include <Library/DebugLib.h>
39 #include <Library/BaseLib.h>
40 #include <Library/UefiDriverEntryPoint.h>
41 #include <Library/UefiLib.h>
42 #include <Library/BaseMemoryLib.h>
43 #include <Library/UefiBootServicesTableLib.h>
44 #include <Library/MemoryAllocationLib.h>
49 // EFI Component Name Functions
52 Retrieves a Unicode string that is the user readable name of the driver.
54 This function retrieves the user readable name of a driver in the form of a
55 Unicode string. If the driver specified by This has a user readable name in
56 the language specified by Language, then a pointer to the driver name is
57 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
58 by This does not support the language specified by Language,
59 then EFI_UNSUPPORTED is returned.
61 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
62 EFI_COMPONENT_NAME_PROTOCOL instance.
64 @param Language[in] A pointer to a Null-terminated ASCII string
65 array indicating the language. This is the
66 language of the driver name that the caller is
67 requesting, and it must match one of the
68 languages specified in SupportedLanguages. The
69 number of languages supported by a driver is up
70 to the driver writer. Language is specified
71 in RFC 4646 or ISO 639-2 language code format.
73 @param DriverName[out] A pointer to the Unicode string to return.
74 This Unicode string is the name of the
75 driver specified by This in the language
76 specified by Language.
78 @retval EFI_SUCCESS The Unicode string for the Driver specified by
79 This and the language specified by Language was
80 returned in DriverName.
82 @retval EFI_INVALID_PARAMETER Language is NULL.
84 @retval EFI_INVALID_PARAMETER DriverName is NULL.
86 @retval EFI_UNSUPPORTED The driver specified by This does not support
87 the language specified by Language.
92 WinNtGopComponentNameGetDriverName (
93 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
95 OUT CHAR16
**DriverName
100 Retrieves a Unicode string that is the user readable name of the controller
101 that is being managed by a driver.
103 This function retrieves the user readable name of the controller specified by
104 ControllerHandle and ChildHandle in the form of a Unicode string. If the
105 driver specified by This has a user readable name in the language specified by
106 Language, then a pointer to the controller name is returned in ControllerName,
107 and EFI_SUCCESS is returned. If the driver specified by This is not currently
108 managing the controller specified by ControllerHandle and ChildHandle,
109 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
110 support the language specified by Language, then EFI_UNSUPPORTED is returned.
112 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
113 EFI_COMPONENT_NAME_PROTOCOL instance.
115 @param ControllerHandle[in] The handle of a controller that the driver
116 specified by This is managing. This handle
117 specifies the controller whose name is to be
120 @param ChildHandle[in] The handle of the child controller to retrieve
121 the name of. This is an optional parameter that
122 may be NULL. It will be NULL for device
123 drivers. It will also be NULL for a bus drivers
124 that wish to retrieve the name of the bus
125 controller. It will not be NULL for a bus
126 driver that wishes to retrieve the name of a
129 @param Language[in] A pointer to a Null-terminated ASCII string
130 array indicating the language. This is the
131 language of the driver name that the caller is
132 requesting, and it must match one of the
133 languages specified in SupportedLanguages. The
134 number of languages supported by a driver is up
135 to the driver writer. Language is specified in
136 RFC 4646 or ISO 639-2 language code format.
138 @param ControllerName[out] A pointer to the Unicode string to return.
139 This Unicode string is the name of the
140 controller specified by ControllerHandle and
141 ChildHandle in the language specified by
142 Language from the point of view of the driver
145 @retval EFI_SUCCESS The Unicode string for the user readable name in
146 the language specified by Language for the
147 driver specified by This was returned in
150 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
152 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
155 @retval EFI_INVALID_PARAMETER Language is NULL.
157 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
159 @retval EFI_UNSUPPORTED The driver specified by This is not currently
160 managing the controller specified by
161 ControllerHandle and ChildHandle.
163 @retval EFI_UNSUPPORTED The driver specified by This does not support
164 the language specified by Language.
169 WinNtGopComponentNameGetControllerName (
170 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
171 IN EFI_HANDLE ControllerHandle
,
172 IN EFI_HANDLE ChildHandle OPTIONAL
,
174 OUT CHAR16
**ControllerName
179 // EFI Component Name Protocol
181 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtGopComponentName
= {
182 WinNtGopComponentNameGetDriverName
,
183 WinNtGopComponentNameGetControllerName
,
188 // EFI Component Name 2 Protocol
190 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtGopComponentName2
= {
191 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) WinNtGopComponentNameGetDriverName
,
192 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) WinNtGopComponentNameGetControllerName
,
197 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtGopDriverNameTable
[] = {
198 { "eng;en", L
"Windows GOP Driver" },
204 Retrieves a Unicode string that is the user readable name of the driver.
206 This function retrieves the user readable name of a driver in the form of a
207 Unicode string. If the driver specified by This has a user readable name in
208 the language specified by Language, then a pointer to the driver name is
209 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
210 by This does not support the language specified by Language,
211 then EFI_UNSUPPORTED is returned.
213 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
214 EFI_COMPONENT_NAME_PROTOCOL instance.
216 @param Language[in] A pointer to a Null-terminated ASCII string
217 array indicating the language. This is the
218 language of the driver name that the caller is
219 requesting, and it must match one of the
220 languages specified in SupportedLanguages. The
221 number of languages supported by a driver is up
222 to the driver writer. Language is specified
223 in RFC 4646 or ISO 639-2 language code format.
225 @param DriverName[out] A pointer to the Unicode string to return.
226 This Unicode string is the name of the
227 driver specified by This in the language
228 specified by Language.
230 @retval EFI_SUCCESS The Unicode string for the Driver specified by
231 This and the language specified by Language was
232 returned in DriverName.
234 @retval EFI_INVALID_PARAMETER Language is NULL.
236 @retval EFI_INVALID_PARAMETER DriverName is NULL.
238 @retval EFI_UNSUPPORTED The driver specified by This does not support
239 the language specified by Language.
244 WinNtGopComponentNameGetDriverName (
245 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
247 OUT CHAR16
**DriverName
250 return LookupUnicodeString2 (
252 This
->SupportedLanguages
,
253 mWinNtGopDriverNameTable
,
255 (BOOLEAN
)(This
== &gWinNtGopComponentName
)
261 Retrieves a Unicode string that is the user readable name of the controller
262 that is being managed by a driver.
264 This function retrieves the user readable name of the controller specified by
265 ControllerHandle and ChildHandle in the form of a Unicode string. If the
266 driver specified by This has a user readable name in the language specified by
267 Language, then a pointer to the controller name is returned in ControllerName,
268 and EFI_SUCCESS is returned. If the driver specified by This is not currently
269 managing the controller specified by ControllerHandle and ChildHandle,
270 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
271 support the language specified by Language, then EFI_UNSUPPORTED is returned.
273 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
274 EFI_COMPONENT_NAME_PROTOCOL instance.
276 @param ControllerHandle[in] The handle of a controller that the driver
277 specified by This is managing. This handle
278 specifies the controller whose name is to be
281 @param ChildHandle[in] The handle of the child controller to retrieve
282 the name of. This is an optional parameter that
283 may be NULL. It will be NULL for device
284 drivers. It will also be NULL for a bus drivers
285 that wish to retrieve the name of the bus
286 controller. It will not be NULL for a bus
287 driver that wishes to retrieve the name of a
290 @param Language[in] A pointer to a Null-terminated ASCII string
291 array indicating the language. This is the
292 language of the driver name that the caller is
293 requesting, and it must match one of the
294 languages specified in SupportedLanguages. The
295 number of languages supported by a driver is up
296 to the driver writer. Language is specified in
297 RFC 4646 or ISO 639-2 language code format.
299 @param ControllerName[out] A pointer to the Unicode string to return.
300 This Unicode string is the name of the
301 controller specified by ControllerHandle and
302 ChildHandle in the language specified by
303 Language from the point of view of the driver
306 @retval EFI_SUCCESS The Unicode string for the user readable name in
307 the language specified by Language for the
308 driver specified by This was returned in
311 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
313 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
316 @retval EFI_INVALID_PARAMETER Language is NULL.
318 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
320 @retval EFI_UNSUPPORTED The driver specified by This is not currently
321 managing the controller specified by
322 ControllerHandle and ChildHandle.
324 @retval EFI_UNSUPPORTED The driver specified by This does not support
325 the language specified by Language.
330 WinNtGopComponentNameGetControllerName (
331 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
332 IN EFI_HANDLE ControllerHandle
,
333 IN EFI_HANDLE ChildHandle OPTIONAL
,
335 OUT CHAR16
**ControllerName
339 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
340 GOP_PRIVATE_DATA
*Private
;
343 // This is a device driver, so ChildHandle must be NULL.
345 if (ChildHandle
!= NULL
) {
346 return EFI_UNSUPPORTED
;
349 // Make sure this driver is currently managing ControllerHandle
351 Status
= EfiTestManagedDevice (
353 gWinNtGopDriverBinding
.DriverBindingHandle
,
354 &gEfiWinNtIoProtocolGuid
356 if (EFI_ERROR (Status
)) {
357 return EFI_UNSUPPORTED
;
360 // Get our context back
362 Status
= gBS
->OpenProtocol (
364 &gEfiGraphicsOutputProtocolGuid
,
365 (VOID
**) &GraphicsOutput
,
366 gWinNtGopDriverBinding
.DriverBindingHandle
,
368 EFI_OPEN_PROTOCOL_GET_PROTOCOL
370 if (EFI_ERROR (Status
)) {
371 return EFI_UNSUPPORTED
;
374 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
376 return LookupUnicodeString2 (
378 This
->SupportedLanguages
,
379 Private
->ControllerNameTable
,
381 (BOOLEAN
)(This
== &gWinNtGopComponentName
)