]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/EmuGopDxe/ComponentName.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / EmulatorPkg / EmuGopDxe / ComponentName.c
CommitLineData
949f388f 1/** @file\r
2\r
3Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
4Portions copyright (c) 2010,Apple Inc. All rights reserved.<BR>\r
e3ba31da 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
949f388f 6\r
7Module Name:\r
8\r
9 ComponentName.c\r
10\r
11Abstract:\r
12\r
13**/\r
14\r
15#include "Gop.h"\r
16\r
17//\r
18// EFI Component Name Functions\r
19//\r
20EFI_STATUS\r
21EFIAPI\r
22EmuGopComponentNameGetDriverName (\r
23 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
24 IN CHAR8 *Language,\r
25 OUT CHAR16 **DriverName\r
26 );\r
27\r
28EFI_STATUS\r
29EFIAPI\r
30EmuGopComponentNameGetControllerName (\r
a550d468
MK
31 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
32 IN EFI_HANDLE ControllerHandle,\r
33 IN EFI_HANDLE ChildHandle OPTIONAL,\r
34 IN CHAR8 *Language,\r
35 OUT CHAR16 **ControllerName\r
949f388f 36 );\r
37\r
38//\r
39// EFI Component Name Protocol\r
40//\r
a550d468 41EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName = {\r
949f388f 42 EmuGopComponentNameGetDriverName,\r
43 EmuGopComponentNameGetControllerName,\r
44 "eng"\r
45};\r
46\r
47//\r
48// EFI Component Name 2 Protocol\r
49//\r
a550d468
MK
50GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2 = {\r
51 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuGopComponentNameGetDriverName,\r
52 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuGopComponentNameGetControllerName,\r
949f388f 53 "en"\r
54};\r
55\r
a550d468 56EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = {\r
bb89ec1a 57 { "eng", L"Emulator GOP Driver" },\r
a550d468 58 { NULL, NULL }\r
949f388f 59};\r
60\r
949f388f 61/**\r
62 Retrieves a Unicode string that is the user readable name of the driver.\r
63\r
64 This function retrieves the user readable name of a driver in the form of a\r
65 Unicode string. If the driver specified by This has a user readable name in\r
66 the language specified by Language, then a pointer to the driver name is\r
67 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
68 by This does not support the language specified by Language,\r
69 then EFI_UNSUPPORTED is returned.\r
70\r
71 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
72 EFI_COMPONENT_NAME_PROTOCOL instance.\r
73\r
74 @param Language[in] A pointer to a Null-terminated ASCII string\r
75 array indicating the language. This is the\r
76 language of the driver name that the caller is\r
77 requesting, and it must match one of the\r
78 languages specified in SupportedLanguages. The\r
79 number of languages supported by a driver is up\r
80 to the driver writer. Language is specified\r
81 in RFC 4646 or ISO 639-2 language code format.\r
82\r
83 @param DriverName[out] A pointer to the Unicode string to return.\r
84 This Unicode string is the name of the\r
85 driver specified by This in the language\r
86 specified by Language.\r
87\r
88 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
89 This and the language specified by Language was\r
90 returned in DriverName.\r
91\r
92 @retval EFI_INVALID_PARAMETER Language is NULL.\r
93\r
94 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
95\r
96 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
97 the language specified by Language.\r
98\r
99**/\r
100EFI_STATUS\r
101EFIAPI\r
102EmuGopComponentNameGetDriverName (\r
103 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
104 IN CHAR8 *Language,\r
105 OUT CHAR16 **DriverName\r
106 )\r
107{\r
108 return LookupUnicodeString2 (\r
109 Language,\r
110 This->SupportedLanguages,\r
111 mEmuGopDriverNameTable,\r
112 DriverName,\r
113 (BOOLEAN)(This == &gEmuGopComponentName)\r
114 );\r
115}\r
116\r
949f388f 117/**\r
118 Retrieves a Unicode string that is the user readable name of the controller\r
119 that is being managed by a driver.\r
120\r
121 This function retrieves the user readable name of the controller specified by\r
122 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
123 driver specified by This has a user readable name in the language specified by\r
124 Language, then a pointer to the controller name is returned in ControllerName,\r
125 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
126 managing the controller specified by ControllerHandle and ChildHandle,\r
127 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
128 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
129\r
130 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
131 EFI_COMPONENT_NAME_PROTOCOL instance.\r
132\r
133 @param ControllerHandle[in] The handle of a controller that the driver\r
134 specified by This is managing. This handle\r
135 specifies the controller whose name is to be\r
136 returned.\r
137\r
138 @param ChildHandle[in] The handle of the child controller to retrieve\r
139 the name of. This is an optional parameter that\r
140 may be NULL. It will be NULL for device\r
141 drivers. It will also be NULL for a bus drivers\r
142 that wish to retrieve the name of the bus\r
143 controller. It will not be NULL for a bus\r
144 driver that wishes to retrieve the name of a\r
145 child controller.\r
146\r
147 @param Language[in] A pointer to a Null-terminated ASCII string\r
148 array indicating the language. This is the\r
149 language of the driver name that the caller is\r
150 requesting, and it must match one of the\r
151 languages specified in SupportedLanguages. The\r
152 number of languages supported by a driver is up\r
153 to the driver writer. Language is specified in\r
154 RFC 4646 or ISO 639-2 language code format.\r
155\r
156 @param ControllerName[out] A pointer to the Unicode string to return.\r
157 This Unicode string is the name of the\r
158 controller specified by ControllerHandle and\r
159 ChildHandle in the language specified by\r
160 Language from the point of view of the driver\r
161 specified by This.\r
162\r
163 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
164 the language specified by Language for the\r
165 driver specified by This was returned in\r
166 DriverName.\r
167\r
168 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
169\r
170 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
171 EFI_HANDLE.\r
172\r
173 @retval EFI_INVALID_PARAMETER Language is NULL.\r
174\r
175 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
176\r
177 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
178 managing the controller specified by\r
179 ControllerHandle and ChildHandle.\r
180\r
181 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
182 the language specified by Language.\r
183\r
184**/\r
185EFI_STATUS\r
186EFIAPI\r
187EmuGopComponentNameGetControllerName (\r
a550d468
MK
188 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
189 IN EFI_HANDLE ControllerHandle,\r
190 IN EFI_HANDLE ChildHandle OPTIONAL,\r
191 IN CHAR8 *Language,\r
192 OUT CHAR16 **ControllerName\r
949f388f 193 )\r
194{\r
195 EFI_STATUS Status;\r
196 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
197 GOP_PRIVATE_DATA *Private;\r
198\r
199 //\r
200 // This is a device driver, so ChildHandle must be NULL.\r
201 //\r
202 if (ChildHandle != NULL) {\r
203 return EFI_UNSUPPORTED;\r
204 }\r
205\r
206 //\r
207 // Make sure this driver is currently managing ControllerHandle\r
208 //\r
209 Status = EfiTestManagedDevice (\r
210 ControllerHandle,\r
211 gEmuGopDriverBinding.DriverBindingHandle,\r
212 &gEmuIoThunkProtocolGuid\r
213 );\r
214 if (EFI_ERROR (Status)) {\r
215 return EFI_UNSUPPORTED;\r
216 }\r
a550d468 217\r
949f388f 218 //\r
219 // Get our context back\r
220 //\r
221 Status = gBS->OpenProtocol (\r
222 ControllerHandle,\r
223 &gEfiGraphicsOutputProtocolGuid,\r
224 (VOID **)&GraphicsOutput,\r
225 gEmuGopDriverBinding.DriverBindingHandle,\r
226 ControllerHandle,\r
227 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
228 );\r
229 if (EFI_ERROR (Status)) {\r
230 return EFI_UNSUPPORTED;\r
231 }\r
232\r
233 Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);\r
234\r
235 return LookupUnicodeString2 (\r
236 Language,\r
237 This->SupportedLanguages,\r
238 Private->ControllerNameTable,\r
239 ControllerName,\r
240 (BOOLEAN)(This == &gEmuGopComponentName)\r
241 );\r
242}\r