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