2 Header file for Console Platfrom DXE Driver.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _CON_PLATFORM_H_
16 #define _CON_PLATFORM_H_
20 #include <Protocol/SimpleTextOut.h>
21 #include <Protocol/DevicePath.h>
22 #include <Protocol/SimpleTextIn.h>
23 #include <Protocol/PciIo.h>
24 #include <Protocol/UsbIo.h>
25 #include <Protocol/GraphicsOutput.h>
27 #include <Guid/GlobalVariable.h>
28 #include <Guid/ConsoleInDevice.h>
29 #include <Guid/StandardErrorDevice.h>
30 #include <Guid/ConsoleOutDevice.h>
32 #include <Library/DebugLib.h>
33 #include <Library/UefiDriverEntryPoint.h>
34 #include <Library/UefiLib.h>
35 #include <Library/BaseMemoryLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/UefiRuntimeServicesTableLib.h>
38 #include <Library/DevicePathLib.h>
39 #include <Library/MemoryAllocationLib.h>
40 #include <Library/UefiBootManagerLib.h>
43 // Driver Binding Externs
45 extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding
;
46 extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName
;
47 extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2
;
48 extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding
;
49 extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName
;
50 extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2
;
57 } CONPLATFORM_VAR_OPERATION
;
60 Test to see if specific protocol could be supported on the ControllerHandle.
62 @param This Protocol instance pointer.
63 @param ControllerHandle Handle of device to test.
64 @param ProtocolGuid The specfic protocol.
66 @retval EFI_SUCCESS This driver supports this device
67 @retval other This driver does not support this device
71 ConPlatformDriverBindingSupported (
72 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
73 IN EFI_HANDLE ControllerHandle
,
74 IN EFI_GUID
*ProtocolGuid
78 Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle.
80 @param This Protocol instance pointer.
81 @param ControllerHandle Handle of device to test.
82 @param RemainingDevicePath Optional parameter use to pick a specific child
85 @retval EFI_SUCCESS This driver supports this device.
86 @retval other This driver does not support this device.
91 ConPlatformTextInDriverBindingSupported (
92 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
94 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
98 Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle.
100 @param This Protocol instance pointer.
101 @param ControllerHandle Handle of device to test.
102 @param RemainingDevicePath Optional parameter use to pick a specific child
105 @retval EFI_SUCCESS This driver supports this device.
106 @retval other This driver does not support this device.
111 ConPlatformTextOutDriverBindingSupported (
112 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
113 IN EFI_HANDLE Handle
,
114 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
118 Start this driver on the device for console input.
120 Start this driver on ControllerHandle by opening Simple Text Input Protocol,
121 reading Device Path, and installing Console In Devcice GUID on ControllerHandle.
123 Append its device path into the console environment variables ConInDev.
125 @param This Protocol instance pointer.
126 @param ControllerHandle Handle of device to bind driver to
127 @param RemainingDevicePath Optional parameter use to pick a specific child
130 @retval EFI_SUCCESS This driver is added to ControllerHandle
131 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
132 @retval other This driver does not support this device.
137 ConPlatformTextInDriverBindingStart (
138 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
139 IN EFI_HANDLE Handle
,
140 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
144 Start this driver on the device for console output and standard error output.
146 Start this driver on ControllerHandle by opening Simple Text Output Protocol,
147 reading Device Path, and installing Console Out Devcic GUID, Standard Error
148 Device GUID on ControllerHandle.
150 Append its device path into the console environment variables ConOutDev, ErrOutDev.
152 @param This Protocol instance pointer.
153 @param ControllerHandle Handle of device to bind driver to
154 @param RemainingDevicePath Optional parameter use to pick a specific child
157 @retval EFI_SUCCESS This driver is added to ControllerHandle
158 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
159 @retval other This driver does not support this device
164 ConPlatformTextOutDriverBindingStart (
165 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
166 IN EFI_HANDLE Handle
,
167 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
171 Stop this driver on ControllerHandle by removing Console In Devcice GUID
172 and closing the Simple Text Input protocol on ControllerHandle.
174 @param This Protocol instance pointer.
175 @param ControllerHandle Handle of device to stop driver on
176 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
177 children is zero stop the entire bus driver.
178 @param ChildHandleBuffer List of Child Handles to Stop.
180 @retval EFI_SUCCESS This driver is removed ControllerHandle
181 @retval other This driver was not removed from this device
186 ConPlatformTextInDriverBindingStop (
187 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
188 IN EFI_HANDLE Handle
,
189 IN UINTN NumberOfChildren
,
190 IN EFI_HANDLE
*ChildHandleBuffer
194 Stop this driver on ControllerHandle by removing Console Out Devcice GUID
195 and closing the Simple Text Output protocol on ControllerHandle.
197 @param This Protocol instance pointer.
198 @param ControllerHandle Handle of device to stop driver on
199 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
200 children is zero stop the entire bus driver.
201 @param ChildHandleBuffer List of Child Handles to Stop.
203 @retval EFI_SUCCESS This driver is removed ControllerHandle
204 @retval other This driver was not removed from this device
209 ConPlatformTextOutDriverBindingStop (
210 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
211 IN EFI_HANDLE Handle
,
212 IN UINTN NumberOfChildren
,
213 IN EFI_HANDLE
*ChildHandleBuffer
217 Uninstall the specified protocol.
219 @param This Protocol instance pointer.
220 @param Handle Handle of device to uninstall protocol on.
221 @param ProtocolGuid The specified protocol need to be uninstalled.
225 ConPlatformUnInstallProtocol (
226 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
227 IN EFI_HANDLE Handle
,
228 IN EFI_GUID
*ProtocolGuid
232 Read the EFI variable (Name) and return a dynamically allocated
233 buffer, and the size of the buffer. On failure return NULL.
235 @param Name String part of EFI variable name
237 @return Dynamically allocated memory that contains a copy of the EFI variable.
238 Caller is repsoncible freeing the buffer. Return NULL means Variable
243 ConPlatformGetVariable (
248 Function compares a device path data structure to that of all the nodes of a
249 second device path instance.
252 @param Multi A pointer to a multi-instance device path data structure.
253 @param Single A pointer to a single-instance device path data structure.
254 @param NewDevicePath If Delete is TRUE, this parameter must not be null, and it
255 points to the remaining device path data structure.
256 (remaining device path = Multi - Single.)
257 @param Delete If TRUE, means removing Single from Multi.
258 If FALSE, the routine just check whether Single matches
259 with any instance in Multi.
261 @retval EFI_SUCCESS If the Single is contained within Multi.
262 @retval EFI_NOT_FOUND If the Single is not contained within Multi.
263 @retval EFI_INVALID_PARAMETER Multi is NULL.
264 @retval EFI_INVALID_PARAMETER Single is NULL.
265 @retval EFI_INVALID_PARAMETER NewDevicePath is NULL when Delete is TRUE.
269 ConPlatformMatchDevicePaths (
270 IN EFI_DEVICE_PATH_PROTOCOL
*Multi
,
271 IN EFI_DEVICE_PATH_PROTOCOL
*Single
,
272 OUT EFI_DEVICE_PATH_PROTOCOL
**NewDevicePath OPTIONAL
,
277 Update console environment variables.
279 @param VariableName Console environment variables, ConOutDev, ConInDev
280 StdErrDev, ConIn or ConOut.
281 @param DevicePath Console devcie's device path.
282 @param Operation Variable operations, including APPEND, CHECK and DELETE.
284 @retval EFI_SUCCESS Variable operates successfully.
285 @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.
286 @retval other Variable updating failed.
290 ConPlatformUpdateDeviceVariable (
291 IN CHAR16
*VariableName
,
292 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
293 IN CONPLATFORM_VAR_OPERATION Operation
297 // EFI Component Name Functions
300 Retrieves a Unicode string that is the user readable name of the driver.
302 This function retrieves the user readable name of a driver in the form of a
303 Unicode string. If the driver specified by This has a user readable name in
304 the language specified by Language, then a pointer to the driver name is
305 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
306 by This does not support the language specified by Language,
307 then EFI_UNSUPPORTED is returned.
309 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
310 EFI_COMPONENT_NAME_PROTOCOL instance.
311 @param Language[in] A pointer to a Null-terminated ASCII string
312 array indicating the language. This is the
313 language of the driver name that the caller is
314 requesting, and it must match one of the
315 languages specified in SupportedLanguages. The
316 number of languages supported by a driver is up
317 to the driver writer. Language is specified
318 in RFC 4646 or ISO 639-2 language code format.
319 @param DriverName[out] A pointer to the Unicode string to return.
320 This Unicode string is the name of the
321 driver specified by This in the language
322 specified by Language.
324 @retval EFI_SUCCESS The Unicode string for the Driver specified by
325 This and the language specified by Language was
326 returned in DriverName.
327 @retval EFI_INVALID_PARAMETER Language is NULL.
328 @retval EFI_INVALID_PARAMETER DriverName is NULL.
329 @retval EFI_UNSUPPORTED The driver specified by This does not support
330 the language specified by Language.
335 ConPlatformComponentNameGetDriverName (
336 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
338 OUT CHAR16
**DriverName
343 Retrieves a Unicode string that is the user readable name of the controller
344 that is being managed by a driver.
346 This function retrieves the user readable name of the controller specified by
347 ControllerHandle and ChildHandle in the form of a Unicode string. If the
348 driver specified by This has a user readable name in the language specified by
349 Language, then a pointer to the controller name is returned in ControllerName,
350 and EFI_SUCCESS is returned. If the driver specified by This is not currently
351 managing the controller specified by ControllerHandle and ChildHandle,
352 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
353 support the language specified by Language, then EFI_UNSUPPORTED is returned.
355 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
356 EFI_COMPONENT_NAME_PROTOCOL instance.
357 @param ControllerHandle[in] The handle of a controller that the driver
358 specified by This is managing. This handle
359 specifies the controller whose name is to be
361 @param ChildHandle[in] The handle of the child controller to retrieve
362 the name of. This is an optional parameter that
363 may be NULL. It will be NULL for device
364 drivers. It will also be NULL for a bus drivers
365 that wish to retrieve the name of the bus
366 controller. It will not be NULL for a bus
367 driver that wishes to retrieve the name of a
369 @param Language[in] A pointer to a Null-terminated ASCII string
370 array indicating the language. This is the
371 language of the driver name that the caller is
372 requesting, and it must match one of the
373 languages specified in SupportedLanguages. The
374 number of languages supported by a driver is up
375 to the driver writer. Language is specified in
376 RFC 4646 or ISO 639-2 language code format.
377 @param ControllerName[out] A pointer to the Unicode string to return.
378 This Unicode string is the name of the
379 controller specified by ControllerHandle and
380 ChildHandle in the language specified by
381 Language from the point of view of the driver
384 @retval EFI_SUCCESS The Unicode string for the user readable name in
385 the language specified by Language for the
386 driver specified by This was returned in
388 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
389 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
391 @retval EFI_INVALID_PARAMETER Language is NULL.
392 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
393 @retval EFI_UNSUPPORTED The driver specified by This is not currently
394 managing the controller specified by
395 ControllerHandle and ChildHandle.
396 @retval EFI_UNSUPPORTED The driver specified by This does not support
397 the language specified by Language.
402 ConPlatformComponentNameGetControllerName (
403 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
404 IN EFI_HANDLE ControllerHandle
,
405 IN EFI_HANDLE ChildHandle OPTIONAL
,
407 OUT CHAR16
**ControllerName
411 Update ConOutDev and ErrOutDev variables to add the device path of
412 GOP controller itself and the sibling controllers.
414 @param DevicePath Pointer to device's device path.
416 @retval TRUE The devcie is a GOP device.
417 @retval FALSE The devcie is not a GOP device.
421 ConPlatformUpdateGopCandidate (
422 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath