c9fc89a3 |
1 | /** @file\r |
2 | \r |
8f2a5f80 |
3 | Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r |
9d2eedba |
4 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
c9fc89a3 |
5 | \r |
6 | Module Name:\r |
7 | \r |
8 | ComponentName.c\r |
9 | \r |
10 | Abstract:\r |
11 | \r |
12 | \r |
13 | **/\r |
14 | \r |
15 | //\r |
16 | // The package level header files this module uses\r |
17 | //\r |
18 | #include <Uefi.h>\r |
19 | #include <WinNtDxe.h>\r |
20 | //\r |
21 | // The protocols, PPI and GUID defintions for this module\r |
22 | //\r |
23 | #include <Guid/EventGroup.h>\r |
24 | #include <Protocol/WinNtIo.h>\r |
25 | #include <Protocol/ComponentName.h>\r |
26 | #include <Protocol/SimpleTextIn.h>\r |
27 | #include <Protocol/DriverBinding.h>\r |
28 | #include <Protocol/GraphicsOutput.h>\r |
29 | //\r |
30 | // The Library classes this module consumes\r |
31 | //\r |
32 | #include <Library/DebugLib.h>\r |
33 | #include <Library/BaseLib.h>\r |
34 | #include <Library/UefiDriverEntryPoint.h>\r |
35 | #include <Library/UefiLib.h>\r |
36 | #include <Library/BaseMemoryLib.h>\r |
37 | #include <Library/UefiBootServicesTableLib.h>\r |
38 | #include <Library/MemoryAllocationLib.h>\r |
39 | \r |
40 | #include "WinNtGop.h"\r |
41 | \r |
42 | //\r |
43 | // EFI Component Name Functions\r |
44 | //\r |
e6e53c97 |
45 | /**\r |
46 | Retrieves a Unicode string that is the user readable name of the driver.\r |
47 | \r |
48 | This function retrieves the user readable name of a driver in the form of a\r |
49 | Unicode string. If the driver specified by This has a user readable name in\r |
50 | the language specified by Language, then a pointer to the driver name is\r |
51 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r |
52 | by This does not support the language specified by Language,\r |
53 | then EFI_UNSUPPORTED is returned.\r |
54 | \r |
55 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
56 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
57 | \r |
58 | @param Language[in] A pointer to a Null-terminated ASCII string\r |
59 | array indicating the language. This is the\r |
60 | language of the driver name that the caller is\r |
61 | requesting, and it must match one of the\r |
62 | languages specified in SupportedLanguages. The\r |
63 | number of languages supported by a driver is up\r |
64 | to the driver writer. Language is specified\r |
44c40247 |
65 | in RFC 4646 or ISO 639-2 language code format.\r |
e6e53c97 |
66 | \r |
67 | @param DriverName[out] A pointer to the Unicode string to return.\r |
68 | This Unicode string is the name of the\r |
69 | driver specified by This in the language\r |
70 | specified by Language.\r |
71 | \r |
72 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r |
73 | This and the language specified by Language was\r |
74 | returned in DriverName.\r |
75 | \r |
76 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
77 | \r |
78 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r |
79 | \r |
80 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
81 | the language specified by Language.\r |
82 | \r |
83 | **/\r |
c9fc89a3 |
84 | EFI_STATUS\r |
85 | EFIAPI\r |
86 | WinNtGopComponentNameGetDriverName (\r |
87 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
88 | IN CHAR8 *Language,\r |
89 | OUT CHAR16 **DriverName\r |
90 | );\r |
91 | \r |
e6e53c97 |
92 | \r |
93 | /**\r |
94 | Retrieves a Unicode string that is the user readable name of the controller\r |
95 | that is being managed by a driver.\r |
96 | \r |
97 | This function retrieves the user readable name of the controller specified by\r |
98 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r |
99 | driver specified by This has a user readable name in the language specified by\r |
100 | Language, then a pointer to the controller name is returned in ControllerName,\r |
101 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r |
102 | managing the controller specified by ControllerHandle and ChildHandle,\r |
103 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r |
104 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r |
105 | \r |
106 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
107 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
108 | \r |
109 | @param ControllerHandle[in] The handle of a controller that the driver\r |
110 | specified by This is managing. This handle\r |
111 | specifies the controller whose name is to be\r |
112 | returned.\r |
113 | \r |
114 | @param ChildHandle[in] The handle of the child controller to retrieve\r |
115 | the name of. This is an optional parameter that\r |
116 | may be NULL. It will be NULL for device\r |
117 | drivers. It will also be NULL for a bus drivers\r |
118 | that wish to retrieve the name of the bus\r |
119 | controller. It will not be NULL for a bus\r |
120 | driver that wishes to retrieve the name of a\r |
121 | child controller.\r |
122 | \r |
123 | @param Language[in] A pointer to a Null-terminated ASCII string\r |
124 | array indicating the language. This is the\r |
125 | language of the driver name that the caller is\r |
126 | requesting, and it must match one of the\r |
127 | languages specified in SupportedLanguages. The\r |
128 | number of languages supported by a driver is up\r |
129 | to the driver writer. Language is specified in\r |
44c40247 |
130 | RFC 4646 or ISO 639-2 language code format.\r |
e6e53c97 |
131 | \r |
132 | @param ControllerName[out] A pointer to the Unicode string to return.\r |
133 | This Unicode string is the name of the\r |
134 | controller specified by ControllerHandle and\r |
135 | ChildHandle in the language specified by\r |
136 | Language from the point of view of the driver\r |
137 | specified by This.\r |
138 | \r |
139 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r |
140 | the language specified by Language for the\r |
141 | driver specified by This was returned in\r |
142 | DriverName.\r |
143 | \r |
144 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r |
145 | \r |
146 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r |
147 | EFI_HANDLE.\r |
148 | \r |
149 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
150 | \r |
151 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r |
152 | \r |
153 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r |
154 | managing the controller specified by\r |
155 | ControllerHandle and ChildHandle.\r |
156 | \r |
157 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
158 | the language specified by Language.\r |
159 | \r |
160 | **/\r |
c9fc89a3 |
161 | EFI_STATUS\r |
162 | EFIAPI\r |
163 | WinNtGopComponentNameGetControllerName (\r |
164 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
165 | IN EFI_HANDLE ControllerHandle,\r |
166 | IN EFI_HANDLE ChildHandle OPTIONAL,\r |
167 | IN CHAR8 *Language,\r |
168 | OUT CHAR16 **ControllerName\r |
169 | );\r |
170 | \r |
e6e53c97 |
171 | \r |
c9fc89a3 |
172 | //\r |
173 | // EFI Component Name Protocol\r |
174 | //\r |
1307dcd7 |
175 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtGopComponentName = {\r |
c9fc89a3 |
176 | WinNtGopComponentNameGetDriverName,\r |
177 | WinNtGopComponentNameGetControllerName,\r |
178 | "eng"\r |
1307dcd7 |
179 | };\r |
e6e53c97 |
180 | \r |
181 | //\r |
182 | // EFI Component Name 2 Protocol\r |
183 | //\r |
1307dcd7 |
184 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtGopComponentName2 = {\r |
e6e53c97 |
185 | (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) WinNtGopComponentNameGetDriverName,\r |
186 | (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) WinNtGopComponentNameGetControllerName,\r |
187 | "en"\r |
1307dcd7 |
188 | };\r |
e6e53c97 |
189 | \r |
c9fc89a3 |
190 | \r |
d1aeb0bd |
191 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtGopDriverNameTable[] = {\r |
e6e53c97 |
192 | { "eng;en", L"Windows GOP Driver" },\r |
c9fc89a3 |
193 | { NULL , NULL }\r |
194 | };\r |
195 | \r |
196 | \r |
197 | /**\r |
e6e53c97 |
198 | Retrieves a Unicode string that is the user readable name of the driver.\r |
199 | \r |
200 | This function retrieves the user readable name of a driver in the form of a\r |
201 | Unicode string. If the driver specified by This has a user readable name in\r |
202 | the language specified by Language, then a pointer to the driver name is\r |
203 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r |
204 | by This does not support the language specified by Language,\r |
205 | then EFI_UNSUPPORTED is returned.\r |
206 | \r |
207 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
208 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
209 | \r |
210 | @param Language[in] A pointer to a Null-terminated ASCII string\r |
211 | array indicating the language. This is the\r |
212 | language of the driver name that the caller is\r |
213 | requesting, and it must match one of the\r |
214 | languages specified in SupportedLanguages. The\r |
215 | number of languages supported by a driver is up\r |
216 | to the driver writer. Language is specified\r |
44c40247 |
217 | in RFC 4646 or ISO 639-2 language code format.\r |
e6e53c97 |
218 | \r |
219 | @param DriverName[out] A pointer to the Unicode string to return.\r |
220 | This Unicode string is the name of the\r |
221 | driver specified by This in the language\r |
222 | specified by Language.\r |
223 | \r |
224 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r |
225 | This and the language specified by Language was\r |
226 | returned in DriverName.\r |
227 | \r |
228 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
229 | \r |
230 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r |
231 | \r |
232 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
233 | the language specified by Language.\r |
c9fc89a3 |
234 | \r |
235 | **/\r |
236 | EFI_STATUS\r |
237 | EFIAPI\r |
238 | WinNtGopComponentNameGetDriverName (\r |
239 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
240 | IN CHAR8 *Language,\r |
241 | OUT CHAR16 **DriverName\r |
242 | )\r |
243 | {\r |
e6e53c97 |
244 | return LookupUnicodeString2 (\r |
245 | Language,\r |
246 | This->SupportedLanguages,\r |
247 | mWinNtGopDriverNameTable,\r |
248 | DriverName,\r |
249 | (BOOLEAN)(This == &gWinNtGopComponentName)\r |
250 | );\r |
c9fc89a3 |
251 | }\r |
252 | \r |
253 | \r |
254 | /**\r |
255 | Retrieves a Unicode string that is the user readable name of the controller\r |
e6e53c97 |
256 | that is being managed by a driver.\r |
257 | \r |
258 | This function retrieves the user readable name of the controller specified by\r |
259 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r |
260 | driver specified by This has a user readable name in the language specified by\r |
261 | Language, then a pointer to the controller name is returned in ControllerName,\r |
262 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r |
263 | managing the controller specified by ControllerHandle and ChildHandle,\r |
264 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r |
265 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r |
266 | \r |
267 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
268 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
269 | \r |
270 | @param ControllerHandle[in] The handle of a controller that the driver\r |
271 | specified by This is managing. This handle\r |
272 | specifies the controller whose name is to be\r |
273 | returned.\r |
274 | \r |
275 | @param ChildHandle[in] The handle of the child controller to retrieve\r |
276 | the name of. This is an optional parameter that\r |
277 | may be NULL. It will be NULL for device\r |
278 | drivers. It will also be NULL for a bus drivers\r |
279 | that wish to retrieve the name of the bus\r |
280 | controller. It will not be NULL for a bus\r |
281 | driver that wishes to retrieve the name of a\r |
282 | child controller.\r |
283 | \r |
284 | @param Language[in] A pointer to a Null-terminated ASCII string\r |
285 | array indicating the language. This is the\r |
286 | language of the driver name that the caller is\r |
287 | requesting, and it must match one of the\r |
288 | languages specified in SupportedLanguages. The\r |
289 | number of languages supported by a driver is up\r |
290 | to the driver writer. Language is specified in\r |
44c40247 |
291 | RFC 4646 or ISO 639-2 language code format.\r |
e6e53c97 |
292 | \r |
293 | @param ControllerName[out] A pointer to the Unicode string to return.\r |
294 | This Unicode string is the name of the\r |
295 | controller specified by ControllerHandle and\r |
296 | ChildHandle in the language specified by\r |
297 | Language from the point of view of the driver\r |
298 | specified by This.\r |
299 | \r |
300 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r |
301 | the language specified by Language for the\r |
302 | driver specified by This was returned in\r |
303 | DriverName.\r |
304 | \r |
305 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r |
306 | \r |
307 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r |
308 | EFI_HANDLE.\r |
309 | \r |
310 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
311 | \r |
312 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r |
313 | \r |
314 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r |
315 | managing the controller specified by\r |
316 | ControllerHandle and ChildHandle.\r |
317 | \r |
318 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
319 | the language specified by Language.\r |
c9fc89a3 |
320 | \r |
321 | **/\r |
322 | EFI_STATUS\r |
323 | EFIAPI\r |
324 | WinNtGopComponentNameGetControllerName (\r |
325 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
326 | IN EFI_HANDLE ControllerHandle,\r |
327 | IN EFI_HANDLE ChildHandle OPTIONAL,\r |
328 | IN CHAR8 *Language,\r |
329 | OUT CHAR16 **ControllerName\r |
330 | )\r |
331 | {\r |
332 | EFI_STATUS Status;\r |
333 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r |
334 | GOP_PRIVATE_DATA *Private;\r |
335 | \r |
336 | //\r |
337 | // This is a device driver, so ChildHandle must be NULL.\r |
338 | //\r |
339 | if (ChildHandle != NULL) {\r |
340 | return EFI_UNSUPPORTED;\r |
341 | }\r |
342 | //\r |
343 | // Make sure this driver is currently managing ControllerHandle\r |
344 | //\r |
345 | Status = EfiTestManagedDevice (\r |
346 | ControllerHandle,\r |
347 | gWinNtGopDriverBinding.DriverBindingHandle,\r |
348 | &gEfiWinNtIoProtocolGuid\r |
349 | );\r |
350 | if (EFI_ERROR (Status)) {\r |
351 | return EFI_UNSUPPORTED;\r |
352 | }\r |
353 | //\r |
354 | // Get our context back\r |
355 | //\r |
356 | Status = gBS->OpenProtocol (\r |
357 | ControllerHandle,\r |
358 | &gEfiGraphicsOutputProtocolGuid,\r |
63941829 |
359 | (VOID **) &GraphicsOutput,\r |
c9fc89a3 |
360 | gWinNtGopDriverBinding.DriverBindingHandle,\r |
361 | ControllerHandle,\r |
362 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r |
363 | );\r |
364 | if (EFI_ERROR (Status)) {\r |
365 | return EFI_UNSUPPORTED;\r |
366 | }\r |
367 | \r |
368 | Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);\r |
369 | \r |
e6e53c97 |
370 | return LookupUnicodeString2 (\r |
371 | Language,\r |
372 | This->SupportedLanguages,\r |
373 | Private->ControllerNameTable,\r |
374 | ControllerName,\r |
375 | (BOOLEAN)(This == &gWinNtGopComponentName)\r |
376 | );\r |
c9fc89a3 |
377 | }\r |