3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2010,Apple Inc. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 // EFI Component Name Functions
28 EmuGopComponentNameGetDriverName (
29 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
31 OUT CHAR16
**DriverName
36 EmuGopComponentNameGetControllerName (
37 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
38 IN EFI_HANDLE ControllerHandle
,
39 IN EFI_HANDLE ChildHandle OPTIONAL
,
41 OUT CHAR16
**ControllerName
45 // EFI Component Name Protocol
47 EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName
= {
48 EmuGopComponentNameGetDriverName
,
49 EmuGopComponentNameGetControllerName
,
54 // EFI Component Name 2 Protocol
56 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2
= {
57 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) EmuGopComponentNameGetDriverName
,
58 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) EmuGopComponentNameGetControllerName
,
63 EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable
[] = {
64 { "eng", L
"Emulator GOP Driver" },
70 Retrieves a Unicode string that is the user readable name of the driver.
72 This function retrieves the user readable name of a driver in the form of a
73 Unicode string. If the driver specified by This has a user readable name in
74 the language specified by Language, then a pointer to the driver name is
75 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
76 by This does not support the language specified by Language,
77 then EFI_UNSUPPORTED is returned.
79 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
80 EFI_COMPONENT_NAME_PROTOCOL instance.
82 @param Language[in] A pointer to a Null-terminated ASCII string
83 array indicating the language. This is the
84 language of the driver name that the caller is
85 requesting, and it must match one of the
86 languages specified in SupportedLanguages. The
87 number of languages supported by a driver is up
88 to the driver writer. Language is specified
89 in RFC 4646 or ISO 639-2 language code format.
91 @param DriverName[out] A pointer to the Unicode string to return.
92 This Unicode string is the name of the
93 driver specified by This in the language
94 specified by Language.
96 @retval EFI_SUCCESS The Unicode string for the Driver specified by
97 This and the language specified by Language was
98 returned in DriverName.
100 @retval EFI_INVALID_PARAMETER Language is NULL.
102 @retval EFI_INVALID_PARAMETER DriverName is NULL.
104 @retval EFI_UNSUPPORTED The driver specified by This does not support
105 the language specified by Language.
110 EmuGopComponentNameGetDriverName (
111 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
113 OUT CHAR16
**DriverName
116 return LookupUnicodeString2 (
118 This
->SupportedLanguages
,
119 mEmuGopDriverNameTable
,
121 (BOOLEAN
)(This
== &gEmuGopComponentName
)
127 Retrieves a Unicode string that is the user readable name of the controller
128 that is being managed by a driver.
130 This function retrieves the user readable name of the controller specified by
131 ControllerHandle and ChildHandle in the form of a Unicode string. If the
132 driver specified by This has a user readable name in the language specified by
133 Language, then a pointer to the controller name is returned in ControllerName,
134 and EFI_SUCCESS is returned. If the driver specified by This is not currently
135 managing the controller specified by ControllerHandle and ChildHandle,
136 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
137 support the language specified by Language, then EFI_UNSUPPORTED is returned.
139 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
140 EFI_COMPONENT_NAME_PROTOCOL instance.
142 @param ControllerHandle[in] The handle of a controller that the driver
143 specified by This is managing. This handle
144 specifies the controller whose name is to be
147 @param ChildHandle[in] The handle of the child controller to retrieve
148 the name of. This is an optional parameter that
149 may be NULL. It will be NULL for device
150 drivers. It will also be NULL for a bus drivers
151 that wish to retrieve the name of the bus
152 controller. It will not be NULL for a bus
153 driver that wishes to retrieve the name of a
156 @param Language[in] A pointer to a Null-terminated ASCII string
157 array indicating the language. This is the
158 language of the driver name that the caller is
159 requesting, and it must match one of the
160 languages specified in SupportedLanguages. The
161 number of languages supported by a driver is up
162 to the driver writer. Language is specified in
163 RFC 4646 or ISO 639-2 language code format.
165 @param ControllerName[out] A pointer to the Unicode string to return.
166 This Unicode string is the name of the
167 controller specified by ControllerHandle and
168 ChildHandle in the language specified by
169 Language from the point of view of the driver
172 @retval EFI_SUCCESS The Unicode string for the user readable name in
173 the language specified by Language for the
174 driver specified by This was returned in
177 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
179 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
182 @retval EFI_INVALID_PARAMETER Language is NULL.
184 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
186 @retval EFI_UNSUPPORTED The driver specified by This is not currently
187 managing the controller specified by
188 ControllerHandle and ChildHandle.
190 @retval EFI_UNSUPPORTED The driver specified by This does not support
191 the language specified by Language.
196 EmuGopComponentNameGetControllerName (
197 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
198 IN EFI_HANDLE ControllerHandle
,
199 IN EFI_HANDLE ChildHandle OPTIONAL
,
201 OUT CHAR16
**ControllerName
205 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
206 GOP_PRIVATE_DATA
*Private
;
209 // This is a device driver, so ChildHandle must be NULL.
211 if (ChildHandle
!= NULL
) {
212 return EFI_UNSUPPORTED
;
216 // Make sure this driver is currently managing ControllerHandle
218 Status
= EfiTestManagedDevice (
220 gEmuGopDriverBinding
.DriverBindingHandle
,
221 &gEmuIoThunkProtocolGuid
223 if (EFI_ERROR (Status
)) {
224 return EFI_UNSUPPORTED
;
227 // Get our context back
229 Status
= gBS
->OpenProtocol (
231 &gEfiGraphicsOutputProtocolGuid
,
232 (VOID
**)&GraphicsOutput
,
233 gEmuGopDriverBinding
.DriverBindingHandle
,
235 EFI_OPEN_PROTOCOL_GET_PROTOCOL
237 if (EFI_ERROR (Status
)) {
238 return EFI_UNSUPPORTED
;
241 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
243 return LookupUnicodeString2 (
245 This
->SupportedLanguages
,
246 Private
->ControllerNameTable
,
248 (BOOLEAN
)(This
== &gEmuGopComponentName
)