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