]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / Console / ConPlatformDxe / ConPlatform.h
... / ...
CommitLineData
1/** @file\r
2 Header file for Console Platfrom DXE Driver.\r
3\r
4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
5SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9#ifndef _CON_PLATFORM_H_\r
10#define _CON_PLATFORM_H_\r
11\r
12#include <Uefi.h>\r
13\r
14#include <Protocol/SimpleTextOut.h>\r
15#include <Protocol/DevicePath.h>\r
16#include <Protocol/SimpleTextIn.h>\r
17#include <Protocol/PciIo.h>\r
18#include <Protocol/UsbIo.h>\r
19#include <Protocol/GraphicsOutput.h>\r
20\r
21#include <Guid/GlobalVariable.h>\r
22#include <Guid/ConsoleInDevice.h>\r
23#include <Guid/StandardErrorDevice.h>\r
24#include <Guid/ConsoleOutDevice.h>\r
25\r
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
34#include <Library/UefiBootManagerLib.h>\r
35\r
36//\r
37// Driver Binding Externs\r
38//\r
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
45\r
46\r
47typedef enum {\r
48 Check,\r
49 Append,\r
50 Delete\r
51} CONPLATFORM_VAR_OPERATION;\r
52\r
53/**\r
54 Test to see if specific protocol could be supported on the ControllerHandle.\r
55\r
56 @param This Protocol instance pointer.\r
57 @param ControllerHandle Handle of device to test.\r
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
64EFI_STATUS\r
65ConPlatformDriverBindingSupported (\r
66 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
67 IN EFI_HANDLE ControllerHandle,\r
68 IN EFI_GUID *ProtocolGuid\r
69 );\r
70\r
71/**\r
72 Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle.\r
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
79 @retval EFI_SUCCESS This driver supports this device.\r
80 @retval other This driver does not support this device.\r
81\r
82**/\r
83EFI_STATUS\r
84EFIAPI\r
85ConPlatformTextInDriverBindingSupported (\r
86 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
87 IN EFI_HANDLE Handle,\r
88 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
89 );\r
90\r
91/**\r
92 Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle.\r
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
99 @retval EFI_SUCCESS This driver supports this device.\r
100 @retval other This driver does not support this device.\r
101\r
102**/\r
103EFI_STATUS\r
104EFIAPI\r
105ConPlatformTextOutDriverBindingSupported (\r
106 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
107 IN EFI_HANDLE Handle,\r
108 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
109 );\r
110\r
111/**\r
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
115 reading Device Path, and installing Console In Devcice GUID on ControllerHandle.\r
116\r
117 Append its device path into the console environment variables ConInDev.\r
118\r
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
126 @retval other This driver does not support this device.\r
127\r
128**/\r
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
137/**\r
138 Start this driver on the device for console output and standard error output.\r
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
142 Device GUID on ControllerHandle.\r
143\r
144 Append its device path into the console environment variables ConOutDev, ErrOutDev.\r
145\r
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
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
164/**\r
165 Stop this driver on ControllerHandle by removing Console In Devcice GUID\r
166 and closing the Simple Text Input protocol on ControllerHandle.\r
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
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
187/**\r
188 Stop this driver on ControllerHandle by removing Console Out Devcice GUID\r
189 and closing the Simple Text Output protocol on ControllerHandle.\r
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
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
210/**\r
211 Uninstall the specified protocol.\r
212\r
213 @param This Protocol instance pointer.\r
214 @param Handle Handle of device to uninstall protocol on.\r
215 @param ProtocolGuid The specified protocol need to be uninstalled.\r
216\r
217**/\r
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
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
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
232 Caller is repsoncible freeing the buffer. Return NULL means Variable\r
233 was not read.\r
234\r
235**/\r
236VOID *\r
237ConPlatformGetVariable (\r
238 IN CHAR16 *Name\r
239 );\r
240\r
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
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
260\r
261**/\r
262EFI_STATUS\r
263ConPlatformMatchDevicePaths (\r
264 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
265 IN EFI_DEVICE_PATH_PROTOCOL *Single,\r
266 OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,\r
267 IN BOOLEAN Delete\r
268 );\r
269\r
270/**\r
271 Update console environment variables.\r
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
276 @param Operation Variable operations, including APPEND, CHECK and DELETE.\r
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
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
290//\r
291// EFI Component Name Functions\r
292//\r
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
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
312 in RFC 4646 or ISO 639-2 language code format.\r
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
321 @retval EFI_INVALID_PARAMETER Language is NULL.\r
322 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
323 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
324 the language specified by Language.\r
325\r
326**/\r
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
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
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
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
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
370 RFC 4646 or ISO 639-2 language code format.\r
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
382 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
383 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
384 EFI_HANDLE.\r
385 @retval EFI_INVALID_PARAMETER Language is NULL.\r
386 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
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
390 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
391 the language specified by Language.\r
392\r
393**/\r
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
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
418\r
419#endif\r