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