3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2010,Apple Inc. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
18 // EFI Component Name Functions
22 EmuGopComponentNameGetDriverName (
23 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
25 OUT CHAR16
**DriverName
30 EmuGopComponentNameGetControllerName (
31 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
32 IN EFI_HANDLE ControllerHandle
,
33 IN EFI_HANDLE ChildHandle OPTIONAL
,
35 OUT CHAR16
**ControllerName
39 // EFI Component Name Protocol
41 EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName
= {
42 EmuGopComponentNameGetDriverName
,
43 EmuGopComponentNameGetControllerName
,
48 // EFI Component Name 2 Protocol
50 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2
= {
51 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)EmuGopComponentNameGetDriverName
,
52 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)EmuGopComponentNameGetControllerName
,
56 EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable
[] = {
57 { "eng", L
"Emulator GOP Driver" },
62 Retrieves a Unicode string that is the user readable name of the driver.
64 This function retrieves the user readable name of a driver in the form of a
65 Unicode string. If the driver specified by This has a user readable name in
66 the language specified by Language, then a pointer to the driver name is
67 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
68 by This does not support the language specified by Language,
69 then EFI_UNSUPPORTED is returned.
71 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
72 EFI_COMPONENT_NAME_PROTOCOL instance.
74 @param Language[in] A pointer to a Null-terminated ASCII string
75 array indicating the language. This is the
76 language of the driver name that the caller is
77 requesting, and it must match one of the
78 languages specified in SupportedLanguages. The
79 number of languages supported by a driver is up
80 to the driver writer. Language is specified
81 in RFC 4646 or ISO 639-2 language code format.
83 @param DriverName[out] A pointer to the Unicode string to return.
84 This Unicode string is the name of the
85 driver specified by This in the language
86 specified by Language.
88 @retval EFI_SUCCESS The Unicode string for the Driver specified by
89 This and the language specified by Language was
90 returned in DriverName.
92 @retval EFI_INVALID_PARAMETER Language is NULL.
94 @retval EFI_INVALID_PARAMETER DriverName is NULL.
96 @retval EFI_UNSUPPORTED The driver specified by This does not support
97 the language specified by Language.
102 EmuGopComponentNameGetDriverName (
103 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
105 OUT CHAR16
**DriverName
108 return LookupUnicodeString2 (
110 This
->SupportedLanguages
,
111 mEmuGopDriverNameTable
,
113 (BOOLEAN
)(This
== &gEmuGopComponentName
)
118 Retrieves a Unicode string that is the user readable name of the controller
119 that is being managed by a driver.
121 This function retrieves the user readable name of the controller specified by
122 ControllerHandle and ChildHandle in the form of a Unicode string. If the
123 driver specified by This has a user readable name in the language specified by
124 Language, then a pointer to the controller name is returned in ControllerName,
125 and EFI_SUCCESS is returned. If the driver specified by This is not currently
126 managing the controller specified by ControllerHandle and ChildHandle,
127 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
128 support the language specified by Language, then EFI_UNSUPPORTED is returned.
130 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
131 EFI_COMPONENT_NAME_PROTOCOL instance.
133 @param ControllerHandle[in] The handle of a controller that the driver
134 specified by This is managing. This handle
135 specifies the controller whose name is to be
138 @param ChildHandle[in] The handle of the child controller to retrieve
139 the name of. This is an optional parameter that
140 may be NULL. It will be NULL for device
141 drivers. It will also be NULL for a bus drivers
142 that wish to retrieve the name of the bus
143 controller. It will not be NULL for a bus
144 driver that wishes to retrieve the name of a
147 @param Language[in] A pointer to a Null-terminated ASCII string
148 array indicating the language. This is the
149 language of the driver name that the caller is
150 requesting, and it must match one of the
151 languages specified in SupportedLanguages. The
152 number of languages supported by a driver is up
153 to the driver writer. Language is specified in
154 RFC 4646 or ISO 639-2 language code format.
156 @param ControllerName[out] A pointer to the Unicode string to return.
157 This Unicode string is the name of the
158 controller specified by ControllerHandle and
159 ChildHandle in the language specified by
160 Language from the point of view of the driver
163 @retval EFI_SUCCESS The Unicode string for the user readable name in
164 the language specified by Language for the
165 driver specified by This was returned in
168 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
170 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
173 @retval EFI_INVALID_PARAMETER Language is NULL.
175 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
177 @retval EFI_UNSUPPORTED The driver specified by This is not currently
178 managing the controller specified by
179 ControllerHandle and ChildHandle.
181 @retval EFI_UNSUPPORTED The driver specified by This does not support
182 the language specified by Language.
187 EmuGopComponentNameGetControllerName (
188 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
189 IN EFI_HANDLE ControllerHandle
,
190 IN EFI_HANDLE ChildHandle OPTIONAL
,
192 OUT CHAR16
**ControllerName
196 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
197 GOP_PRIVATE_DATA
*Private
;
200 // This is a device driver, so ChildHandle must be NULL.
202 if (ChildHandle
!= NULL
) {
203 return EFI_UNSUPPORTED
;
207 // Make sure this driver is currently managing ControllerHandle
209 Status
= EfiTestManagedDevice (
211 gEmuGopDriverBinding
.DriverBindingHandle
,
212 &gEmuIoThunkProtocolGuid
214 if (EFI_ERROR (Status
)) {
215 return EFI_UNSUPPORTED
;
219 // Get our context back
221 Status
= gBS
->OpenProtocol (
223 &gEfiGraphicsOutputProtocolGuid
,
224 (VOID
**)&GraphicsOutput
,
225 gEmuGopDriverBinding
.DriverBindingHandle
,
227 EFI_OPEN_PROTOCOL_GET_PROTOCOL
229 if (EFI_ERROR (Status
)) {
230 return EFI_UNSUPPORTED
;
233 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
235 return LookupUnicodeString2 (
237 This
->SupportedLanguages
,
238 Private
->ControllerNameTable
,
240 (BOOLEAN
)(This
== &gEmuGopComponentName
)