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