2 Header file for GraphicsConsole driver.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _GRAPHICS_CONSOLE_H_
10 #define _GRAPHICS_CONSOLE_H_
13 #include <Protocol/SimpleTextOut.h>
14 #include <Protocol/GraphicsOutput.h>
15 #include <Protocol/UgaDraw.h>
16 #include <Protocol/DevicePath.h>
17 #include <Library/DebugLib.h>
18 #include <Library/UefiDriverEntryPoint.h>
19 #include <Library/UefiLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/MemoryAllocationLib.h>
22 #include <Library/UefiBootServicesTableLib.h>
23 #include <Library/HiiLib.h>
24 #include <Library/BaseLib.h>
25 #include <Library/PcdLib.h>
27 #include <Guid/MdeModuleHii.h>
29 #include <Protocol/HiiFont.h>
30 #include <Protocol/HiiDatabase.h>
33 extern EFI_COMPONENT_NAME_PROTOCOL gGraphicsConsoleComponentName
;
34 extern EFI_COMPONENT_NAME2_PROTOCOL gGraphicsConsoleComponentName2
;
35 extern EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding
;
36 extern EFI_NARROW_GLYPH gUsStdNarrowGlyphData
[];
38 extern UINT32 mNarrowFontSize
;
41 EFI_NARROW_GLYPH NarrowGlyph
;
42 EFI_WIDE_GLYPH WideGlyph
;
48 #define GRAPHICS_CONSOLE_DEV_SIGNATURE SIGNATURE_32 ('g', 's', 't', 'o')
58 } GRAPHICS_CONSOLE_MODE_DATA
;
62 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
63 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
64 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput
;
65 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode
;
66 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
67 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*LineBuffer
;
68 } GRAPHICS_CONSOLE_DEV
;
70 #define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \
71 CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)
75 // EFI Component Name Functions
78 Retrieves a Unicode string that is the user readable name of the driver.
80 This function retrieves the user readable name of a driver in the form of a
81 Unicode string. If the driver specified by This has a user readable name in
82 the language specified by Language, then a pointer to the driver name is
83 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
84 by This does not support the language specified by Language,
85 then EFI_UNSUPPORTED is returned.
87 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
88 EFI_COMPONENT_NAME_PROTOCOL instance.
90 @param Language[in] A pointer to a Null-terminated ASCII string
91 array indicating the language. This is the
92 language of the driver name that the caller is
93 requesting, and it must match one of the
94 languages specified in SupportedLanguages. The
95 number of languages supported by a driver is up
96 to the driver writer. Language is specified
97 in RFC 4646 or ISO 639-2 language code format.
99 @param DriverName[out] A pointer to the Unicode string to return.
100 This Unicode string is the name of the
101 driver specified by This in the language
102 specified by Language.
104 @retval EFI_SUCCESS The Unicode string for the Driver specified by
105 This and the language specified by Language was
106 returned in DriverName.
108 @retval EFI_INVALID_PARAMETER Language is NULL.
110 @retval EFI_INVALID_PARAMETER DriverName is NULL.
112 @retval EFI_UNSUPPORTED The driver specified by This does not support
113 the language specified by Language.
118 GraphicsConsoleComponentNameGetDriverName (
119 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
121 OUT CHAR16
**DriverName
126 Retrieves a Unicode string that is the user readable name of the controller
127 that is being managed by a driver.
129 This function retrieves the user readable name of the controller specified by
130 ControllerHandle and ChildHandle in the form of a Unicode string. If the
131 driver specified by This has a user readable name in the language specified by
132 Language, then a pointer to the controller name is returned in ControllerName,
133 and EFI_SUCCESS is returned. If the driver specified by This is not currently
134 managing the controller specified by ControllerHandle and ChildHandle,
135 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
136 support the language specified by Language, then EFI_UNSUPPORTED is returned.
138 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
139 EFI_COMPONENT_NAME_PROTOCOL instance.
141 @param ControllerHandle[in] The handle of a controller that the driver
142 specified by This is managing. This handle
143 specifies the controller whose name is to be
146 @param ChildHandle[in] The handle of the child controller to retrieve
147 the name of. This is an optional parameter that
148 may be NULL. It will be NULL for device
149 drivers. It will also be NULL for a bus drivers
150 that wish to retrieve the name of the bus
151 controller. It will not be NULL for a bus
152 driver that wishes to retrieve the name of a
155 @param Language[in] A pointer to a Null-terminated ASCII string
156 array indicating the language. This is the
157 language of the driver name that the caller is
158 requesting, and it must match one of the
159 languages specified in SupportedLanguages. The
160 number of languages supported by a driver is up
161 to the driver writer. Language is specified in
162 RFC 4646 or ISO 639-2 language code format.
164 @param ControllerName[out] A pointer to the Unicode string to return.
165 This Unicode string is the name of the
166 controller specified by ControllerHandle and
167 ChildHandle in the language specified by
168 Language from the point of view of the driver
171 @retval EFI_SUCCESS The Unicode string for the user readable name in
172 the language specified by Language for the
173 driver specified by This was returned in
176 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
178 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
181 @retval EFI_INVALID_PARAMETER Language is NULL.
183 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
185 @retval EFI_UNSUPPORTED The driver specified by This is not currently
186 managing the controller specified by
187 ControllerHandle and ChildHandle.
189 @retval EFI_UNSUPPORTED The driver specified by This does not support
190 the language specified by Language.
195 GraphicsConsoleComponentNameGetControllerName (
196 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
197 IN EFI_HANDLE ControllerHandle
,
198 IN EFI_HANDLE ChildHandle OPTIONAL
,
200 OUT CHAR16
**ControllerName
205 Reset the text output device hardware and optionally run diagnostics.
207 Implements SIMPLE_TEXT_OUTPUT.Reset().
208 If ExtendedVerification is TRUE, then perform dependent Graphics Console
209 device reset, and set display mode to mode 0.
210 If ExtendedVerification is FALSE, only set display mode to mode 0.
212 @param This Protocol instance pointer.
213 @param ExtendedVerification Indicates that the driver may perform a more
214 exhaustive verification operation of the device
217 @retval EFI_SUCCESS The text output device was reset.
218 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
224 GraphicsConsoleConOutReset (
225 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
226 IN BOOLEAN ExtendedVerification
230 Write a Unicode string to the output device.
232 Implements SIMPLE_TEXT_OUTPUT.OutputString().
233 The Unicode string will be converted to Glyphs and will be
234 sent to the Graphics Console.
236 @param This Protocol instance pointer.
237 @param WString The NULL-terminated Unicode string to be displayed
238 on the output device(s). All output devices must
239 also support the Unicode drawing defined in this file.
241 @retval EFI_SUCCESS The string was output to the device.
242 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
244 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
246 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
247 characters in the Unicode string could not be
248 rendered and were skipped.
253 GraphicsConsoleConOutOutputString (
254 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
259 Verifies that all characters in a Unicode string can be output to the
262 Implements SIMPLE_TEXT_OUTPUT.TestString().
263 If one of the characters in the *Wstring is neither valid valid Unicode
264 drawing characters, not ASCII code, then this function will return
267 @param This Protocol instance pointer.
268 @param WString The NULL-terminated Unicode string to be examined for the output
271 @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
272 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be
273 rendered by one or more of the output devices mapped
279 GraphicsConsoleConOutTestString (
280 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
285 Returns information for an available text mode that the output device(s)
288 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
289 It returns information for an available text mode that the Graphics Console supports.
290 In this driver,we only support text mode 80x25, which is defined as mode 0.
292 @param This Protocol instance pointer.
293 @param ModeNumber The mode number to return information on.
294 @param Columns The returned columns of the requested mode.
295 @param Rows The returned rows of the requested mode.
297 @retval EFI_SUCCESS The requested mode information is returned.
298 @retval EFI_UNSUPPORTED The mode number is not valid.
303 GraphicsConsoleConOutQueryMode (
304 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
312 Sets the output device(s) to a specified mode.
314 Implements SIMPLE_TEXT_OUTPUT.SetMode().
315 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
317 @param This Protocol instance pointer.
318 @param ModeNumber The text mode to set.
320 @retval EFI_SUCCESS The requested text mode is set.
321 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
322 Graphics Console device error.
323 @retval EFI_UNSUPPORTED The text mode number is not valid.
328 GraphicsConsoleConOutSetMode (
329 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
334 Sets the background and foreground colors for the OutputString () and
335 ClearScreen () functions.
337 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
339 @param This Protocol instance pointer.
340 @param Attribute The attribute to set. Bits 0..3 are the foreground
341 color, and bits 4..6 are the background color.
342 All other bits are undefined and must be zero.
344 @retval EFI_SUCCESS The requested attribute is set.
345 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
346 @retval EFI_UNSUPPORTED The attribute requested is not defined.
351 GraphicsConsoleConOutSetAttribute (
352 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
357 Clears the output device(s) display to the currently selected background
360 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
362 @param This Protocol instance pointer.
364 @retval EFI_SUCCESS The operation completed successfully.
365 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
366 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
371 GraphicsConsoleConOutClearScreen (
372 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
376 Sets the current coordinates of the cursor position.
378 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
380 @param This Protocol instance pointer.
381 @param Column The position to set the cursor to. Must be greater than or
382 equal to zero and less than the number of columns and rows
384 @param Row The position to set the cursor to. Must be greater than or
385 equal to zero and less than the number of columns and rows
388 @retval EFI_SUCCESS The operation completed successfully.
389 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
390 @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
391 cursor position is invalid for the current mode.
396 GraphicsConsoleConOutSetCursorPosition (
397 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
404 Makes the cursor visible or invisible.
406 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
408 @param This Protocol instance pointer.
409 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
410 the cursor is set to be invisible.
412 @retval EFI_SUCCESS The operation completed successfully.
417 GraphicsConsoleConOutEnableCursor (
418 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
423 Test to see if Graphics Console could be supported on the Controller.
425 Graphics Console could be supported if Graphics Output Protocol or UGADraw
426 Protocol exists on the Controller. (UGA Draw Protocol could be skipped
427 if PcdUgaConsumeSupport is set to FALSE.)
429 @param This Protocol instance pointer.
430 @param Controller Handle of device to test.
431 @param RemainingDevicePath Optional parameter use to pick a specific child
434 @retval EFI_SUCCESS This driver supports this device.
435 @retval other This driver does not support this device.
440 GraphicsConsoleControllerDriverSupported (
441 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
442 IN EFI_HANDLE Controller
,
443 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
448 Start this driver on Controller by opening Graphics Output protocol or
449 UGA Draw protocol, and installing Simple Text Out protocol on Controller.
450 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
452 @param This Protocol instance pointer.
453 @param Controller Handle of device to bind driver to
454 @param RemainingDevicePath Optional parameter use to pick a specific child
457 @retval EFI_SUCCESS This driver is added to Controller.
458 @retval other This driver does not support this device.
463 GraphicsConsoleControllerDriverStart (
464 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
465 IN EFI_HANDLE Controller
,
466 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
470 Stop this driver on Controller by removing Simple Text Out protocol
471 and closing the Graphics Output Protocol or UGA Draw protocol on Controller.
472 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
475 @param This Protocol instance pointer.
476 @param Controller Handle of device to stop driver on
477 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
478 children is zero stop the entire bus driver.
479 @param ChildHandleBuffer List of Child Handles to Stop.
481 @retval EFI_SUCCESS This driver is removed Controller.
482 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
484 @retval other This driver was not removed from this device.
489 GraphicsConsoleControllerDriverStop (
490 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
491 IN EFI_HANDLE Controller
,
492 IN UINTN NumberOfChildren
,
493 IN EFI_HANDLE
*ChildHandleBuffer
498 Locate HII Database protocol and HII Font protocol.
500 @retval EFI_SUCCESS HII Database protocol and HII Font protocol
501 are located successfully.
502 @return other Failed to locate HII Database protocol or
507 EfiLocateHiiProtocol (
513 Gets Graphics Console device's foreground color and background color.
515 @param This Protocol instance pointer.
516 @param Foreground Returned text foreground color.
517 @param Background Returned text background color.
519 @retval EFI_SUCCESS It returned always.
524 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
525 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
526 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
530 Draw Unicode string on the Graphics Console device's screen.
532 @param This Protocol instance pointer.
533 @param UnicodeWeight One Unicode string to be displayed.
534 @param Count The count of Unicode string.
536 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
537 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
539 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
543 DrawUnicodeWeightAtCursorN (
544 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
545 IN CHAR16
*UnicodeWeight
,
550 Flush the cursor on the screen.
552 If CursorVisible is FALSE, nothing to do and return directly.
553 If CursorVisible is TRUE,
554 i) If the cursor shows on screen, it will be erased.
555 ii) If the cursor does not show on screen, it will be shown.
557 @param This Protocol instance pointer.
559 @retval EFI_SUCCESS The cursor is erased successfully.
564 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
568 Check if the current specific mode supported the user defined resolution
569 for the Graphics Console device based on Graphics Output Protocol.
571 If yes, set the graphic device's current mode to this specific mode.
573 @param GraphicsOutput Graphics Output Protocol instance pointer.
574 @param HorizontalResolution User defined horizontal resolution
575 @param VerticalResolution User defined vertical resolution.
576 @param CurrentModeNumber Current specific mode to be check.
578 @retval EFI_SUCCESS The mode is supported.
579 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
581 @retval other The specific mode does not support user defined
582 resolution or failed to set the current mode to the
583 specific mode on graphics device.
588 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
589 IN UINT32 HorizontalResolution
,
590 IN UINT32 VerticalResolution
,
591 OUT UINT32
*CurrentModeNumber