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
;
51 } CONPLATFORM_VAR_OPERATION
;
54 Test to see if specific protocol could be supported on the ControllerHandle.
56 @param This Protocol instance pointer.
57 @param ControllerHandle Handle of device to test.
58 @param ProtocolGuid The specfic protocol.
60 @retval EFI_SUCCESS This driver supports this device
61 @retval other This driver does not support this device
65 ConPlatformDriverBindingSupported (
66 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
67 IN EFI_HANDLE ControllerHandle
,
68 IN EFI_GUID
*ProtocolGuid
72 Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle.
74 @param This Protocol instance pointer.
75 @param ControllerHandle Handle of device to test.
76 @param RemainingDevicePath Optional parameter use to pick a specific child
79 @retval EFI_SUCCESS This driver supports this device.
80 @retval other This driver does not support this device.
85 ConPlatformTextInDriverBindingSupported (
86 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
88 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
92 Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle.
94 @param This Protocol instance pointer.
95 @param ControllerHandle Handle of device to test.
96 @param RemainingDevicePath Optional parameter use to pick a specific child
99 @retval EFI_SUCCESS This driver supports this device.
100 @retval other This driver does not support this device.
105 ConPlatformTextOutDriverBindingSupported (
106 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
107 IN EFI_HANDLE Handle
,
108 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
112 Start this driver on the device for console input.
114 Start this driver on ControllerHandle by opening Simple Text Input Protocol,
115 reading Device Path, and installing Console In Devcice GUID on ControllerHandle.
117 Append its device path into the console environment variables ConInDev.
119 @param This Protocol instance pointer.
120 @param ControllerHandle Handle of device to bind driver to
121 @param RemainingDevicePath Optional parameter use to pick a specific child
124 @retval EFI_SUCCESS This driver is added to ControllerHandle
125 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
126 @retval other This driver does not support this device.
131 ConPlatformTextInDriverBindingStart (
132 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
133 IN EFI_HANDLE Handle
,
134 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
138 Start this driver on the device for console output and standard error output.
140 Start this driver on ControllerHandle by opening Simple Text Output Protocol,
141 reading Device Path, and installing Console Out Devcic GUID, Standard Error
142 Device GUID on ControllerHandle.
144 Append its device path into the console environment variables ConOutDev, ErrOutDev.
146 @param This Protocol instance pointer.
147 @param ControllerHandle Handle of device to bind driver to
148 @param RemainingDevicePath Optional parameter use to pick a specific child
151 @retval EFI_SUCCESS This driver is added to ControllerHandle
152 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
153 @retval other This driver does not support this device
158 ConPlatformTextOutDriverBindingStart (
159 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
160 IN EFI_HANDLE Handle
,
161 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
165 Stop this driver on ControllerHandle by removing Console In Devcice GUID
166 and closing the Simple Text Input protocol on ControllerHandle.
168 @param This Protocol instance pointer.
169 @param ControllerHandle Handle of device to stop driver on
170 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
171 children is zero stop the entire bus driver.
172 @param ChildHandleBuffer List of Child Handles to Stop.
174 @retval EFI_SUCCESS This driver is removed ControllerHandle
175 @retval other This driver was not removed from this device
180 ConPlatformTextInDriverBindingStop (
181 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
182 IN EFI_HANDLE Handle
,
183 IN UINTN NumberOfChildren
,
184 IN EFI_HANDLE
*ChildHandleBuffer
188 Stop this driver on ControllerHandle by removing Console Out Devcice GUID
189 and closing the Simple Text Output protocol on ControllerHandle.
191 @param This Protocol instance pointer.
192 @param ControllerHandle Handle of device to stop driver on
193 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
194 children is zero stop the entire bus driver.
195 @param ChildHandleBuffer List of Child Handles to Stop.
197 @retval EFI_SUCCESS This driver is removed ControllerHandle
198 @retval other This driver was not removed from this device
203 ConPlatformTextOutDriverBindingStop (
204 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
205 IN EFI_HANDLE Handle
,
206 IN UINTN NumberOfChildren
,
207 IN EFI_HANDLE
*ChildHandleBuffer
211 Uninstall the specified protocol.
213 @param This Protocol instance pointer.
214 @param Handle Handle of device to uninstall protocol on.
215 @param ProtocolGuid The specified protocol need to be uninstalled.
219 ConPlatformUnInstallProtocol (
220 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
221 IN EFI_HANDLE Handle
,
222 IN EFI_GUID
*ProtocolGuid
226 Read the EFI variable (Name) and return a dynamically allocated
227 buffer, and the size of the buffer. On failure return NULL.
229 @param Name String part of EFI variable name
231 @return Dynamically allocated memory that contains a copy of the EFI variable.
232 Caller is repsoncible freeing the buffer. Return NULL means Variable
237 ConPlatformGetVariable (
242 Function compares a device path data structure to that of all the nodes of a
243 second device path instance.
246 @param Multi A pointer to a multi-instance device path data structure.
247 @param Single A pointer to a single-instance device path data structure.
248 @param NewDevicePath If Delete is TRUE, this parameter must not be null, and it
249 points to the remaining device path data structure.
250 (remaining device path = Multi - Single.)
251 @param Delete If TRUE, means removing Single from Multi.
252 If FALSE, the routine just check whether Single matches
253 with any instance in Multi.
255 @retval EFI_SUCCESS If the Single is contained within Multi.
256 @retval EFI_NOT_FOUND If the Single is not contained within Multi.
257 @retval EFI_INVALID_PARAMETER Multi is NULL.
258 @retval EFI_INVALID_PARAMETER Single is NULL.
259 @retval EFI_INVALID_PARAMETER NewDevicePath is NULL when Delete is TRUE.
263 ConPlatformMatchDevicePaths (
264 IN EFI_DEVICE_PATH_PROTOCOL
*Multi
,
265 IN EFI_DEVICE_PATH_PROTOCOL
*Single
,
266 OUT EFI_DEVICE_PATH_PROTOCOL
**NewDevicePath OPTIONAL
,
271 Update console environment variables.
273 @param VariableName Console environment variables, ConOutDev, ConInDev
274 StdErrDev, ConIn or ConOut.
275 @param DevicePath Console devcie's device path.
276 @param Operation Variable operations, including APPEND, CHECK and DELETE.
278 @retval EFI_SUCCESS Variable operates successfully.
279 @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.
280 @retval other Variable updating failed.
284 ConPlatformUpdateDeviceVariable (
285 IN CHAR16
*VariableName
,
286 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
287 IN CONPLATFORM_VAR_OPERATION Operation
291 // 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
337 Retrieves a Unicode string that is the user readable name of the controller
338 that is being managed by a driver.
340 This function retrieves the user readable name of the controller specified by
341 ControllerHandle and ChildHandle in the form of a Unicode string. If the
342 driver specified by This has a user readable name in the language specified by
343 Language, then a pointer to the controller name is returned in ControllerName,
344 and EFI_SUCCESS is returned. If the driver specified by This is not currently
345 managing the controller specified by ControllerHandle and ChildHandle,
346 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
347 support the language specified by Language, then EFI_UNSUPPORTED is returned.
349 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
350 EFI_COMPONENT_NAME_PROTOCOL instance.
351 @param ControllerHandle[in] The handle of a controller that the driver
352 specified by This is managing. This handle
353 specifies the controller whose name is to be
355 @param ChildHandle[in] The handle of the child controller to retrieve
356 the name of. This is an optional parameter that
357 may be NULL. It will be NULL for device
358 drivers. It will also be NULL for a bus drivers
359 that wish to retrieve the name of the bus
360 controller. It will not be NULL for a bus
361 driver that wishes to retrieve the name of a
363 @param Language[in] A pointer to a Null-terminated ASCII string
364 array indicating the language. This is the
365 language of the driver name that the caller is
366 requesting, and it must match one of the
367 languages specified in SupportedLanguages. The
368 number of languages supported by a driver is up
369 to the driver writer. Language is specified in
370 RFC 4646 or ISO 639-2 language code format.
371 @param ControllerName[out] A pointer to the Unicode string to return.
372 This Unicode string is the name of the
373 controller specified by ControllerHandle and
374 ChildHandle in the language specified by
375 Language from the point of view of the driver
378 @retval EFI_SUCCESS The Unicode string for the user readable name in
379 the language specified by Language for the
380 driver specified by This was returned in
382 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
383 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
385 @retval EFI_INVALID_PARAMETER Language is NULL.
386 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
387 @retval EFI_UNSUPPORTED The driver specified by This is not currently
388 managing the controller specified by
389 ControllerHandle and ChildHandle.
390 @retval EFI_UNSUPPORTED The driver specified by This does not support
391 the language specified by Language.
396 ConPlatformComponentNameGetControllerName (
397 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
398 IN EFI_HANDLE ControllerHandle
,
399 IN EFI_HANDLE ChildHandle OPTIONAL
,
401 OUT CHAR16
**ControllerName
405 Update ConOutDev and ErrOutDev variables to add the device path of
406 GOP controller itself and the sibling controllers.
408 @param DevicePath Pointer to device's device path.
410 @retval TRUE The devcie is a GOP device.
411 @retval FALSE The devcie is not a GOP device.
415 ConPlatformUpdateGopCandidate (
416 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath