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