]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/EmuGopDxe/ComponentName.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / EmulatorPkg / EmuGopDxe / ComponentName.c
1 /** @file
2
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
6
7 Module Name:
8
9 ComponentName.c
10
11 Abstract:
12
13 **/
14
15 #include "Gop.h"
16
17 //
18 // EFI Component Name Functions
19 //
20 EFI_STATUS
21 EFIAPI
22 EmuGopComponentNameGetDriverName (
23 IN EFI_COMPONENT_NAME_PROTOCOL *This,
24 IN CHAR8 *Language,
25 OUT CHAR16 **DriverName
26 );
27
28 EFI_STATUS
29 EFIAPI
30 EmuGopComponentNameGetControllerName (
31 IN EFI_COMPONENT_NAME_PROTOCOL *This,
32 IN EFI_HANDLE ControllerHandle,
33 IN EFI_HANDLE ChildHandle OPTIONAL,
34 IN CHAR8 *Language,
35 OUT CHAR16 **ControllerName
36 );
37
38 //
39 // EFI Component Name Protocol
40 //
41 EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName = {
42 EmuGopComponentNameGetDriverName,
43 EmuGopComponentNameGetControllerName,
44 "eng"
45 };
46
47 //
48 // EFI Component Name 2 Protocol
49 //
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,
53 "en"
54 };
55
56 EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = {
57 { "eng", L"Emulator GOP Driver" },
58 { NULL, NULL }
59 };
60
61 /**
62 Retrieves a Unicode string that is the user readable name of the driver.
63
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.
70
71 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
72 EFI_COMPONENT_NAME_PROTOCOL instance.
73
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.
82
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.
87
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.
91
92 @retval EFI_INVALID_PARAMETER Language is NULL.
93
94 @retval EFI_INVALID_PARAMETER DriverName is NULL.
95
96 @retval EFI_UNSUPPORTED The driver specified by This does not support
97 the language specified by Language.
98
99 **/
100 EFI_STATUS
101 EFIAPI
102 EmuGopComponentNameGetDriverName (
103 IN EFI_COMPONENT_NAME_PROTOCOL *This,
104 IN CHAR8 *Language,
105 OUT CHAR16 **DriverName
106 )
107 {
108 return LookupUnicodeString2 (
109 Language,
110 This->SupportedLanguages,
111 mEmuGopDriverNameTable,
112 DriverName,
113 (BOOLEAN)(This == &gEmuGopComponentName)
114 );
115 }
116
117 /**
118 Retrieves a Unicode string that is the user readable name of the controller
119 that is being managed by a driver.
120
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.
129
130 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
131 EFI_COMPONENT_NAME_PROTOCOL instance.
132
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
136 returned.
137
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
145 child controller.
146
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.
155
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
161 specified by This.
162
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
166 DriverName.
167
168 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
169
170 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
171 EFI_HANDLE.
172
173 @retval EFI_INVALID_PARAMETER Language is NULL.
174
175 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
176
177 @retval EFI_UNSUPPORTED The driver specified by This is not currently
178 managing the controller specified by
179 ControllerHandle and ChildHandle.
180
181 @retval EFI_UNSUPPORTED The driver specified by This does not support
182 the language specified by Language.
183
184 **/
185 EFI_STATUS
186 EFIAPI
187 EmuGopComponentNameGetControllerName (
188 IN EFI_COMPONENT_NAME_PROTOCOL *This,
189 IN EFI_HANDLE ControllerHandle,
190 IN EFI_HANDLE ChildHandle OPTIONAL,
191 IN CHAR8 *Language,
192 OUT CHAR16 **ControllerName
193 )
194 {
195 EFI_STATUS Status;
196 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
197 GOP_PRIVATE_DATA *Private;
198
199 //
200 // This is a device driver, so ChildHandle must be NULL.
201 //
202 if (ChildHandle != NULL) {
203 return EFI_UNSUPPORTED;
204 }
205
206 //
207 // Make sure this driver is currently managing ControllerHandle
208 //
209 Status = EfiTestManagedDevice (
210 ControllerHandle,
211 gEmuGopDriverBinding.DriverBindingHandle,
212 &gEmuIoThunkProtocolGuid
213 );
214 if (EFI_ERROR (Status)) {
215 return EFI_UNSUPPORTED;
216 }
217
218 //
219 // Get our context back
220 //
221 Status = gBS->OpenProtocol (
222 ControllerHandle,
223 &gEfiGraphicsOutputProtocolGuid,
224 (VOID **)&GraphicsOutput,
225 gEmuGopDriverBinding.DriverBindingHandle,
226 ControllerHandle,
227 EFI_OPEN_PROTOCOL_GET_PROTOCOL
228 );
229 if (EFI_ERROR (Status)) {
230 return EFI_UNSUPPORTED;
231 }
232
233 Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);
234
235 return LookupUnicodeString2 (
236 Language,
237 This->SupportedLanguages,
238 Private->ControllerNameTable,
239 ControllerName,
240 (BOOLEAN)(This == &gEmuGopComponentName)
241 );
242 }