]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
MdeModulePkg/ConPlatform: Support GOP created as PCI's grandson
[mirror_edk2.git] / MdeModulePkg / Universal / Console / ConPlatformDxe / ConPlatform.h
CommitLineData
fb0b259e 1/** @file\r
2 Header file for Console Platfrom DXE Driver.\r
95276127 3\r
56dee83a 4Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5This program and the accompanying materials\r
fb0b259e 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
95276127 9\r
fb0b259e 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
95276127 12\r
fb0b259e 13**/\r
95276127 14\r
415df2a3 15#ifndef _CON_PLATFORM_H_\r
16#define _CON_PLATFORM_H_\r
95276127 17\r
60c93673 18#include <Uefi.h>\r
7b9ff698 19\r
859b72fa 20#include <Protocol/SimpleTextOut.h>\r
7b9ff698 21#include <Protocol/DevicePath.h>\r
22#include <Protocol/SimpleTextIn.h>\r
5b7183ef
RN
23#include <Protocol/PciIo.h>\r
24#include <Protocol/GraphicsOutput.h>\r
7b9ff698 25\r
859b72fa
A
26#include <Guid/GlobalVariable.h>\r
27#include <Guid/ConsoleInDevice.h>\r
fb0b259e 28#include <Guid/StandardErrorDevice.h>\r
29#include <Guid/ConsoleOutDevice.h>\r
fb0b259e 30\r
859b72fa
A
31#include <Library/DebugLib.h>\r
32#include <Library/UefiDriverEntryPoint.h>\r
33#include <Library/UefiLib.h>\r
34#include <Library/BaseMemoryLib.h>\r
35#include <Library/UefiBootServicesTableLib.h>\r
36#include <Library/UefiRuntimeServicesTableLib.h>\r
37#include <Library/DevicePathLib.h>\r
38#include <Library/MemoryAllocationLib.h>\r
56dee83a 39#include <Library/UefiBootManagerLib.h>\r
859b72fa 40\r
95276127 41//\r
859b72fa 42// Driver Binding Externs\r
95276127 43//\r
5bca971e 44extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding;\r
45extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName;\r
46extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2;\r
47extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding;\r
48extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName;\r
49extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2;\r
95276127 50\r
95276127 51\r
52typedef enum {\r
1ccdbf2a 53 Check,\r
54 Append,\r
55 Delete\r
95276127 56} CONPLATFORM_VAR_OPERATION;\r
57\r
9359e53f 58/**\r
c5ed97f6 59 Test to see if specific protocol could be supported on the ControllerHandle. \r
9359e53f 60\r
61 @param This Protocol instance pointer.\r
62 @param ControllerHandle Handle of device to test.\r
9359e53f 63 @param ProtocolGuid The specfic protocol.\r
64\r
65 @retval EFI_SUCCESS This driver supports this device\r
66 @retval other This driver does not support this device\r
67\r
68**/\r
95276127 69EFI_STATUS\r
70ConPlatformDriverBindingSupported (\r
71 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
72 IN EFI_HANDLE ControllerHandle,\r
95276127 73 IN EFI_GUID *ProtocolGuid\r
74 );\r
75\r
9359e53f 76/**\r
c5ed97f6 77 Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle. \r
9359e53f 78\r
79 @param This Protocol instance pointer.\r
80 @param ControllerHandle Handle of device to test.\r
81 @param RemainingDevicePath Optional parameter use to pick a specific child\r
82 device to start.\r
83\r
c5ed97f6 84 @retval EFI_SUCCESS This driver supports this device.\r
85 @retval other This driver does not support this device.\r
9359e53f 86\r
87**/\r
95276127 88EFI_STATUS\r
89EFIAPI\r
90ConPlatformTextInDriverBindingSupported (\r
91 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
92 IN EFI_HANDLE Handle,\r
c5ed97f6 93 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
95276127 94 );\r
95\r
9359e53f 96/**\r
c5ed97f6 97 Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle. \r
9359e53f 98\r
99 @param This Protocol instance pointer.\r
100 @param ControllerHandle Handle of device to test.\r
101 @param RemainingDevicePath Optional parameter use to pick a specific child\r
102 device to start.\r
103\r
c5ed97f6 104 @retval EFI_SUCCESS This driver supports this device.\r
105 @retval other This driver does not support this device.\r
9359e53f 106\r
107**/\r
95276127 108EFI_STATUS\r
109EFIAPI\r
110ConPlatformTextOutDriverBindingSupported (\r
111 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
112 IN EFI_HANDLE Handle,\r
c5ed97f6 113 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
95276127 114 );\r
115\r
9359e53f 116/**\r
c5ed97f6 117 Start this driver on the device for console input.\r
118\r
119 Start this driver on ControllerHandle by opening Simple Text Input Protocol,\r
24248368 120 reading Device Path, and installing Console In Devcice GUID on ControllerHandle.\r
9359e53f 121\r
122 If this devcie is not one hot-plug devce, append its device path into the \r
123 console environment variables ConInDev.\r
124 \r
125 @param This Protocol instance pointer.\r
126 @param ControllerHandle Handle of device to bind driver to\r
127 @param RemainingDevicePath Optional parameter use to pick a specific child\r
128 device to start.\r
129\r
130 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
131 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
c5ed97f6 132 @retval other This driver does not support this device.\r
9359e53f 133\r
134**/\r
95276127 135EFI_STATUS\r
136EFIAPI\r
137ConPlatformTextInDriverBindingStart (\r
138 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
139 IN EFI_HANDLE Handle,\r
140 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
141 );\r
142\r
9359e53f 143/**\r
0a18956d 144 Start this driver on the device for console output and standard error output.\r
c5ed97f6 145\r
146 Start this driver on ControllerHandle by opening Simple Text Output Protocol,\r
147 reading Device Path, and installing Console Out Devcic GUID, Standard Error\r
9359e53f 148 Device GUID on ControllerHandle.\r
149\r
150 If this devcie is not one hot-plug devce, append its device path into the \r
151 console environment variables ConOutDev, StdErrDev.\r
152 \r
153 @param This Protocol instance pointer.\r
154 @param ControllerHandle Handle of device to bind driver to\r
155 @param RemainingDevicePath Optional parameter use to pick a specific child\r
156 device to start.\r
157\r
158 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
159 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
160 @retval other This driver does not support this device\r
161\r
162**/\r
95276127 163EFI_STATUS\r
164EFIAPI\r
165ConPlatformTextOutDriverBindingStart (\r
166 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
167 IN EFI_HANDLE Handle,\r
168 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
169 );\r
170\r
9359e53f 171/**\r
24248368 172 Stop this driver on ControllerHandle by removing Console In Devcice GUID \r
c5ed97f6 173 and closing the Simple Text Input protocol on ControllerHandle.\r
9359e53f 174\r
175 @param This Protocol instance pointer.\r
176 @param ControllerHandle Handle of device to stop driver on\r
177 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
178 children is zero stop the entire bus driver.\r
179 @param ChildHandleBuffer List of Child Handles to Stop.\r
180\r
181 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
182 @retval other This driver was not removed from this device\r
183\r
184**/\r
95276127 185EFI_STATUS\r
186EFIAPI\r
187ConPlatformTextInDriverBindingStop (\r
188 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
189 IN EFI_HANDLE Handle,\r
190 IN UINTN NumberOfChildren,\r
191 IN EFI_HANDLE *ChildHandleBuffer\r
192 );\r
193\r
9359e53f 194/**\r
24248368 195 Stop this driver on ControllerHandle by removing Console Out Devcice GUID \r
c5ed97f6 196 and closing the Simple Text Output protocol on ControllerHandle.\r
9359e53f 197\r
198 @param This Protocol instance pointer.\r
199 @param ControllerHandle Handle of device to stop driver on\r
200 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
201 children is zero stop the entire bus driver.\r
202 @param ChildHandleBuffer List of Child Handles to Stop.\r
203\r
204 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
205 @retval other This driver was not removed from this device\r
206\r
207**/\r
95276127 208EFI_STATUS\r
209EFIAPI\r
210ConPlatformTextOutDriverBindingStop (\r
211 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
212 IN EFI_HANDLE Handle,\r
213 IN UINTN NumberOfChildren,\r
214 IN EFI_HANDLE *ChildHandleBuffer\r
215 );\r
216\r
9359e53f 217/**\r
7b9ff698 218 Uninstall the specified protocol.\r
9359e53f 219\r
220 @param This Protocol instance pointer.\r
7b9ff698 221 @param Handle Handle of device to uninstall protocol on.\r
222 @param ProtocolGuid The specified protocol need to be uninstalled.\r
9359e53f 223\r
9359e53f 224**/\r
95276127 225VOID\r
226ConPlatformUnInstallProtocol (\r
227 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
228 IN EFI_HANDLE Handle,\r
229 IN EFI_GUID *ProtocolGuid\r
230 );\r
231\r
9359e53f 232/**\r
233 Read the EFI variable (Name) and return a dynamically allocated\r
234 buffer, and the size of the buffer. On failure return NULL.\r
235\r
9359e53f 236 @param Name String part of EFI variable name\r
237\r
238 @return Dynamically allocated memory that contains a copy of the EFI variable.\r
7b9ff698 239 Caller is repsoncible freeing the buffer. Return NULL means Variable \r
240 was not read.\r
9359e53f 241\r
242**/\r
95276127 243VOID *\r
244ConPlatformGetVariable (\r
245 IN CHAR16 *Name\r
246 );\r
247\r
9359e53f 248/**\r
249 Function compares a device path data structure to that of all the nodes of a\r
250 second device path instance.\r
251\r
252\r
253 @param Multi A pointer to a multi-instance device path data structure.\r
254 @param Single A pointer to a single-instance device path data structure.\r
255 @param NewDevicePath If Delete is TRUE, this parameter must not be null, and it\r
256 points to the remaining device path data structure.\r
257 (remaining device path = Multi - Single.)\r
258 @param Delete If TRUE, means removing Single from Multi.\r
259 If FALSE, the routine just check whether Single matches\r
260 with any instance in Multi.\r
261\r
c5ed97f6 262 @retval EFI_SUCCESS If the Single is contained within Multi.\r
263 @retval EFI_NOT_FOUND If the Single is not contained within Multi.\r
264 @retval EFI_INVALID_PARAMETER Multi is NULL.\r
265 @retval EFI_INVALID_PARAMETER Single is NULL.\r
266 @retval EFI_INVALID_PARAMETER NewDevicePath is NULL when Delete is TRUE.\r
9359e53f 267\r
268**/\r
95276127 269EFI_STATUS\r
270ConPlatformMatchDevicePaths (\r
9359e53f 271 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
272 IN EFI_DEVICE_PATH_PROTOCOL *Single,\r
c5ed97f6 273 OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,\r
95276127 274 IN BOOLEAN Delete\r
275 );\r
276\r
9359e53f 277/**\r
7b9ff698 278 Update console environment variables.\r
9359e53f 279\r
280 @param VariableName Console environment variables, ConOutDev, ConInDev\r
281 StdErrDev, ConIn or ConOut.\r
282 @param DevicePath Console devcie's device path.\r
c5ed97f6 283 @param Operation Variable operations, including APPEND, CHECK and DELETE.\r
9359e53f 284\r
285 @retval EFI_SUCCESS Variable operates successfully.\r
286 @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.\r
287 @retval other Variable updating failed.\r
288\r
289**/\r
95276127 290EFI_STATUS\r
291ConPlatformUpdateDeviceVariable (\r
292 IN CHAR16 *VariableName,\r
293 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
294 IN CONPLATFORM_VAR_OPERATION Operation\r
295 );\r
296\r
9359e53f 297/**\r
f1aec6cc 298 Check if the device supports hot-plug through its device path.\r
9359e53f 299\r
f1aec6cc 300 This function could be updated to check more types of Hot Plug devices.\r
301 Currently, it checks USB and PCCard device.\r
302\r
303 @param DevicePath Pointer to device's device path.\r
9359e53f 304\r
305 @retval TRUE The devcie is a hot-plug device\r
306 @retval FALSE The devcie is not a hot-plug device.\r
307\r
308**/\r
95276127 309BOOLEAN\r
310IsHotPlugDevice (\r
f1aec6cc 311 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
95276127 312 );\r
313\r
859b72fa
A
314//\r
315// EFI Component Name Functions\r
316//\r
5bca971e 317/**\r
318 Retrieves a Unicode string that is the user readable name of the driver.\r
319\r
320 This function retrieves the user readable name of a driver in the form of a\r
321 Unicode string. If the driver specified by This has a user readable name in\r
322 the language specified by Language, then a pointer to the driver name is\r
323 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
324 by This does not support the language specified by Language,\r
325 then EFI_UNSUPPORTED is returned.\r
326\r
327 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
328 EFI_COMPONENT_NAME_PROTOCOL instance.\r
5bca971e 329 @param Language[in] A pointer to a Null-terminated ASCII string\r
330 array indicating the language. This is the\r
331 language of the driver name that the caller is\r
332 requesting, and it must match one of the\r
333 languages specified in SupportedLanguages. The\r
334 number of languages supported by a driver is up\r
335 to the driver writer. Language is specified\r
0254efc0 336 in RFC 4646 or ISO 639-2 language code format.\r
5bca971e 337 @param DriverName[out] A pointer to the Unicode string to return.\r
338 This Unicode string is the name of the\r
339 driver specified by This in the language\r
340 specified by Language.\r
341\r
342 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
343 This and the language specified by Language was\r
344 returned in DriverName.\r
5bca971e 345 @retval EFI_INVALID_PARAMETER Language is NULL.\r
5bca971e 346 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
5bca971e 347 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
348 the language specified by Language.\r
349\r
350**/\r
859b72fa
A
351EFI_STATUS\r
352EFIAPI\r
353ConPlatformComponentNameGetDriverName (\r
354 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
355 IN CHAR8 *Language,\r
356 OUT CHAR16 **DriverName\r
357 );\r
358\r
5bca971e 359\r
360/**\r
361 Retrieves a Unicode string that is the user readable name of the controller\r
362 that is being managed by a driver.\r
363\r
364 This function retrieves the user readable name of the controller specified by\r
365 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
366 driver specified by This has a user readable name in the language specified by\r
367 Language, then a pointer to the controller name is returned in ControllerName,\r
368 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
369 managing the controller specified by ControllerHandle and ChildHandle,\r
370 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
371 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
372\r
373 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
374 EFI_COMPONENT_NAME_PROTOCOL instance.\r
5bca971e 375 @param ControllerHandle[in] The handle of a controller that the driver\r
376 specified by This is managing. This handle\r
377 specifies the controller whose name is to be\r
378 returned.\r
5bca971e 379 @param ChildHandle[in] The handle of the child controller to retrieve\r
380 the name of. This is an optional parameter that\r
381 may be NULL. It will be NULL for device\r
382 drivers. It will also be NULL for a bus drivers\r
383 that wish to retrieve the name of the bus\r
384 controller. It will not be NULL for a bus\r
385 driver that wishes to retrieve the name of a\r
386 child controller.\r
5bca971e 387 @param Language[in] A pointer to a Null-terminated ASCII string\r
388 array indicating the language. This is the\r
389 language of the driver name that the caller is\r
390 requesting, and it must match one of the\r
391 languages specified in SupportedLanguages. The\r
392 number of languages supported by a driver is up\r
393 to the driver writer. Language is specified in\r
0254efc0 394 RFC 4646 or ISO 639-2 language code format.\r
5bca971e 395 @param ControllerName[out] A pointer to the Unicode string to return.\r
396 This Unicode string is the name of the\r
397 controller specified by ControllerHandle and\r
398 ChildHandle in the language specified by\r
399 Language from the point of view of the driver\r
400 specified by This.\r
401\r
402 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
403 the language specified by Language for the\r
404 driver specified by This was returned in\r
405 DriverName.\r
284ee2e8 406 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
5bca971e 407 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
408 EFI_HANDLE.\r
5bca971e 409 @retval EFI_INVALID_PARAMETER Language is NULL.\r
5bca971e 410 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
5bca971e 411 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
412 managing the controller specified by\r
413 ControllerHandle and ChildHandle.\r
5bca971e 414 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
415 the language specified by Language.\r
416\r
417**/\r
859b72fa
A
418EFI_STATUS\r
419EFIAPI\r
420ConPlatformComponentNameGetControllerName (\r
421 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
422 IN EFI_HANDLE ControllerHandle,\r
423 IN EFI_HANDLE ChildHandle OPTIONAL,\r
424 IN CHAR8 *Language,\r
425 OUT CHAR16 **ControllerName\r
426 );\r
427\r
5b7183ef
RN
428/**\r
429 Update ConOutDev and ErrOutDev variables to add the device path of\r
430 GOP controller itself and the sibling controllers.\r
431\r
432 @param DevicePath Pointer to device's device path.\r
433\r
434 @retval TRUE The devcie is a GOP device.\r
435 @retval FALSE The devcie is not a GOP device.\r
436\r
437**/\r
438BOOLEAN\r
439ConPlatformUpdateGopCandidate (\r
440 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
441 );\r
5bca971e 442\r
95276127 443#endif\r