2 Header file for Console Platfrom DXE Driver.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _CON_PLATFORM_H_
10 #define _CON_PLATFORM_H_
14 #include <Protocol/SimpleTextOut.h>
15 #include <Protocol/DevicePath.h>
16 #include <Protocol/SimpleTextIn.h>
17 #include <Protocol/PciIo.h>
18 #include <Protocol/UsbIo.h>
19 #include <Protocol/GraphicsOutput.h>
21 #include <Guid/GlobalVariable.h>
22 #include <Guid/ConsoleInDevice.h>
23 #include <Guid/StandardErrorDevice.h>
24 #include <Guid/ConsoleOutDevice.h>
26 #include <Library/DebugLib.h>
27 #include <Library/UefiDriverEntryPoint.h>
28 #include <Library/UefiLib.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/UefiBootServicesTableLib.h>
31 #include <Library/UefiRuntimeServicesTableLib.h>
32 #include <Library/DevicePathLib.h>
33 #include <Library/MemoryAllocationLib.h>
34 #include <Library/UefiBootManagerLib.h>
37 // Driver Binding Externs
39 extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding
;
40 extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName
;
41 extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2
;
42 extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding
;
43 extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName
;
44 extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2
;
50 } CONPLATFORM_VAR_OPERATION
;
53 Test to see if specific protocol could be supported on the ControllerHandle.
55 @param This Protocol instance pointer.
56 @param ControllerHandle Handle of device to test.
57 @param ProtocolGuid The specfic protocol.
59 @retval EFI_SUCCESS This driver supports this device
60 @retval other This driver does not support this device
64 ConPlatformDriverBindingSupported (
65 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
66 IN EFI_HANDLE ControllerHandle
,
67 IN EFI_GUID
*ProtocolGuid
71 Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle.
73 @param This Protocol instance pointer.
74 @param ControllerHandle Handle of device to test.
75 @param RemainingDevicePath Optional parameter use to pick a specific child
78 @retval EFI_SUCCESS This driver supports this device.
79 @retval other This driver does not support this device.
84 ConPlatformTextInDriverBindingSupported (
85 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
87 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
91 Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle.
93 @param This Protocol instance pointer.
94 @param ControllerHandle Handle of device to test.
95 @param RemainingDevicePath Optional parameter use to pick a specific child
98 @retval EFI_SUCCESS This driver supports this device.
99 @retval other This driver does not support this device.
104 ConPlatformTextOutDriverBindingSupported (
105 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
106 IN EFI_HANDLE Handle
,
107 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
111 Start this driver on the device for console input.
113 Start this driver on ControllerHandle by opening Simple Text Input Protocol,
114 reading Device Path, and installing Console In Devcice GUID on ControllerHandle.
116 Append its device path into the console environment variables ConInDev.
118 @param This Protocol instance pointer.
119 @param ControllerHandle Handle of device to bind driver to
120 @param RemainingDevicePath Optional parameter use to pick a specific child
123 @retval EFI_SUCCESS This driver is added to ControllerHandle
124 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
125 @retval other This driver does not support this device.
130 ConPlatformTextInDriverBindingStart (
131 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
132 IN EFI_HANDLE Handle
,
133 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
137 Start this driver on the device for console output and standard error output.
139 Start this driver on ControllerHandle by opening Simple Text Output Protocol,
140 reading Device Path, and installing Console Out Devcic GUID, Standard Error
141 Device GUID on ControllerHandle.
143 Append its device path into the console environment variables ConOutDev, ErrOutDev.
145 @param This Protocol instance pointer.
146 @param ControllerHandle Handle of device to bind driver to
147 @param RemainingDevicePath Optional parameter use to pick a specific child
150 @retval EFI_SUCCESS This driver is added to ControllerHandle
151 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
152 @retval other This driver does not support this device
157 ConPlatformTextOutDriverBindingStart (
158 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
159 IN EFI_HANDLE Handle
,
160 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
164 Stop this driver on ControllerHandle by removing Console In Devcice GUID
165 and closing the Simple Text Input protocol on ControllerHandle.
167 @param This Protocol instance pointer.
168 @param ControllerHandle Handle of device to stop driver on
169 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
170 children is zero stop the entire bus driver.
171 @param ChildHandleBuffer List of Child Handles to Stop.
173 @retval EFI_SUCCESS This driver is removed ControllerHandle
174 @retval other This driver was not removed from this device
179 ConPlatformTextInDriverBindingStop (
180 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
181 IN EFI_HANDLE Handle
,
182 IN UINTN NumberOfChildren
,
183 IN EFI_HANDLE
*ChildHandleBuffer
187 Stop this driver on ControllerHandle by removing Console Out Devcice GUID
188 and closing the Simple Text Output protocol on ControllerHandle.
190 @param This Protocol instance pointer.
191 @param ControllerHandle Handle of device to stop driver on
192 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
193 children is zero stop the entire bus driver.
194 @param ChildHandleBuffer List of Child Handles to Stop.
196 @retval EFI_SUCCESS This driver is removed ControllerHandle
197 @retval other This driver was not removed from this device
202 ConPlatformTextOutDriverBindingStop (
203 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
204 IN EFI_HANDLE Handle
,
205 IN UINTN NumberOfChildren
,
206 IN EFI_HANDLE
*ChildHandleBuffer
210 Uninstall the specified protocol.
212 @param This Protocol instance pointer.
213 @param Handle Handle of device to uninstall protocol on.
214 @param ProtocolGuid The specified protocol need to be uninstalled.
218 ConPlatformUnInstallProtocol (
219 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
220 IN EFI_HANDLE Handle
,
221 IN EFI_GUID
*ProtocolGuid
225 Read the EFI variable (Name) and return a dynamically allocated
226 buffer, and the size of the buffer. On failure return NULL.
228 @param Name String part of EFI variable name
230 @return Dynamically allocated memory that contains a copy of the EFI variable.
231 Caller is repsoncible freeing the buffer. Return NULL means Variable
236 ConPlatformGetVariable (
241 Function compares a device path data structure to that of all the nodes of a
242 second device path instance.
245 @param Multi A pointer to a multi-instance device path data structure.
246 @param Single A pointer to a single-instance device path data structure.
247 @param NewDevicePath If Delete is TRUE, this parameter must not be null, and it
248 points to the remaining device path data structure.
249 (remaining device path = Multi - Single.)
250 @param Delete If TRUE, means removing Single from Multi.
251 If FALSE, the routine just check whether Single matches
252 with any instance in Multi.
254 @retval EFI_SUCCESS If the Single is contained within Multi.
255 @retval EFI_NOT_FOUND If the Single is not contained within Multi.
256 @retval EFI_INVALID_PARAMETER Multi is NULL.
257 @retval EFI_INVALID_PARAMETER Single is NULL.
258 @retval EFI_INVALID_PARAMETER NewDevicePath is NULL when Delete is TRUE.
262 ConPlatformMatchDevicePaths (
263 IN EFI_DEVICE_PATH_PROTOCOL
*Multi
,
264 IN EFI_DEVICE_PATH_PROTOCOL
*Single
,
265 OUT EFI_DEVICE_PATH_PROTOCOL
**NewDevicePath OPTIONAL
,
270 Update console environment variables.
272 @param VariableName Console environment variables, ConOutDev, ConInDev
273 StdErrDev, ConIn or ConOut.
274 @param DevicePath Console devcie's device path.
275 @param Operation Variable operations, including APPEND, CHECK and DELETE.
277 @retval EFI_SUCCESS Variable operates successfully.
278 @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.
279 @retval other Variable updating failed.
283 ConPlatformUpdateDeviceVariable (
284 IN CHAR16
*VariableName
,
285 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
286 IN CONPLATFORM_VAR_OPERATION Operation
290 // EFI Component Name Functions
294 Retrieves a Unicode string that is the user readable name of the driver.
296 This function retrieves the user readable name of a driver in the form of a
297 Unicode string. If the driver specified by This has a user readable name in
298 the language specified by Language, then a pointer to the driver name is
299 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
300 by This does not support the language specified by Language,
301 then EFI_UNSUPPORTED is returned.
303 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
304 EFI_COMPONENT_NAME_PROTOCOL instance.
305 @param Language[in] A pointer to a Null-terminated ASCII string
306 array indicating the language. This is the
307 language of the driver name that the caller is
308 requesting, and it must match one of the
309 languages specified in SupportedLanguages. The
310 number of languages supported by a driver is up
311 to the driver writer. Language is specified
312 in RFC 4646 or ISO 639-2 language code format.
313 @param DriverName[out] A pointer to the Unicode string to return.
314 This Unicode string is the name of the
315 driver specified by This in the language
316 specified by Language.
318 @retval EFI_SUCCESS The Unicode string for the Driver specified by
319 This and the language specified by Language was
320 returned in DriverName.
321 @retval EFI_INVALID_PARAMETER Language is NULL.
322 @retval EFI_INVALID_PARAMETER DriverName is NULL.
323 @retval EFI_UNSUPPORTED The driver specified by This does not support
324 the language specified by Language.
329 ConPlatformComponentNameGetDriverName (
330 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
332 OUT CHAR16
**DriverName
336 Retrieves a Unicode string that is the user readable name of the controller
337 that is being managed by a driver.
339 This function retrieves the user readable name of the controller specified by
340 ControllerHandle and ChildHandle in the form of a Unicode string. If the
341 driver specified by This has a user readable name in the language specified by
342 Language, then a pointer to the controller name is returned in ControllerName,
343 and EFI_SUCCESS is returned. If the driver specified by This is not currently
344 managing the controller specified by ControllerHandle and ChildHandle,
345 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
346 support the language specified by Language, then EFI_UNSUPPORTED is returned.
348 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
349 EFI_COMPONENT_NAME_PROTOCOL instance.
350 @param ControllerHandle[in] The handle of a controller that the driver
351 specified by This is managing. This handle
352 specifies the controller whose name is to be
354 @param ChildHandle[in] The handle of the child controller to retrieve
355 the name of. This is an optional parameter that
356 may be NULL. It will be NULL for device
357 drivers. It will also be NULL for a bus drivers
358 that wish to retrieve the name of the bus
359 controller. It will not be NULL for a bus
360 driver that wishes to retrieve the name of a
362 @param Language[in] A pointer to a Null-terminated ASCII string
363 array indicating the language. This is the
364 language of the driver name that the caller is
365 requesting, and it must match one of the
366 languages specified in SupportedLanguages. The
367 number of languages supported by a driver is up
368 to the driver writer. Language is specified in
369 RFC 4646 or ISO 639-2 language code format.
370 @param ControllerName[out] A pointer to the Unicode string to return.
371 This Unicode string is the name of the
372 controller specified by ControllerHandle and
373 ChildHandle in the language specified by
374 Language from the point of view of the driver
377 @retval EFI_SUCCESS The Unicode string for the user readable name in
378 the language specified by Language for the
379 driver specified by This was returned in
381 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
382 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
384 @retval EFI_INVALID_PARAMETER Language is NULL.
385 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
386 @retval EFI_UNSUPPORTED The driver specified by This is not currently
387 managing the controller specified by
388 ControllerHandle and ChildHandle.
389 @retval EFI_UNSUPPORTED The driver specified by This does not support
390 the language specified by Language.
395 ConPlatformComponentNameGetControllerName (
396 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
397 IN EFI_HANDLE ControllerHandle
,
398 IN EFI_HANDLE ChildHandle OPTIONAL
,
400 OUT CHAR16
**ControllerName
404 Update ConOutDev and ErrOutDev variables to add the device path of
405 GOP controller itself and the sibling controllers.
407 @param DevicePath Pointer to device's device path.
409 @retval TRUE The devcie is a GOP device.
410 @retval FALSE The devcie is not a GOP device.
414 ConPlatformUpdateGopCandidate (
415 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath