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>
32 extern EFI_COMPONENT_NAME_PROTOCOL gGraphicsConsoleComponentName
;
33 extern EFI_COMPONENT_NAME2_PROTOCOL gGraphicsConsoleComponentName2
;
34 extern EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding
;
35 extern EFI_NARROW_GLYPH gUsStdNarrowGlyphData
[];
37 extern UINT32 mNarrowFontSize
;
40 EFI_NARROW_GLYPH NarrowGlyph
;
41 EFI_WIDE_GLYPH WideGlyph
;
47 #define GRAPHICS_CONSOLE_DEV_SIGNATURE SIGNATURE_32 ('g', 's', 't', 'o')
57 } GRAPHICS_CONSOLE_MODE_DATA
;
61 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
62 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
63 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput
;
64 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode
;
65 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
66 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*LineBuffer
;
67 } GRAPHICS_CONSOLE_DEV
;
69 #define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \
70 CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)
73 // EFI Component Name Functions
77 Retrieves a Unicode string that is the user readable name of the driver.
79 This function retrieves the user readable name of a driver in the form of a
80 Unicode string. If the driver specified by This has a user readable name in
81 the language specified by Language, then a pointer to the driver name is
82 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
83 by This does not support the language specified by Language,
84 then EFI_UNSUPPORTED is returned.
86 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
87 EFI_COMPONENT_NAME_PROTOCOL instance.
89 @param Language[in] A pointer to a Null-terminated ASCII string
90 array indicating the language. This is the
91 language of the driver name that the caller is
92 requesting, and it must match one of the
93 languages specified in SupportedLanguages. The
94 number of languages supported by a driver is up
95 to the driver writer. Language is specified
96 in RFC 4646 or ISO 639-2 language code format.
98 @param DriverName[out] A pointer to the Unicode string to return.
99 This Unicode string is the name of the
100 driver specified by This in the language
101 specified by Language.
103 @retval EFI_SUCCESS The Unicode string for the Driver specified by
104 This and the language specified by Language was
105 returned in DriverName.
107 @retval EFI_INVALID_PARAMETER Language is NULL.
109 @retval EFI_INVALID_PARAMETER DriverName is NULL.
111 @retval EFI_UNSUPPORTED The driver specified by This does not support
112 the language specified by Language.
117 GraphicsConsoleComponentNameGetDriverName (
118 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
120 OUT CHAR16
**DriverName
124 Retrieves a Unicode string that is the user readable name of the controller
125 that is being managed by a driver.
127 This function retrieves the user readable name of the controller specified by
128 ControllerHandle and ChildHandle in the form of a Unicode string. If the
129 driver specified by This has a user readable name in the language specified by
130 Language, then a pointer to the controller name is returned in ControllerName,
131 and EFI_SUCCESS is returned. If the driver specified by This is not currently
132 managing the controller specified by ControllerHandle and ChildHandle,
133 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
134 support the language specified by Language, then EFI_UNSUPPORTED is returned.
136 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
137 EFI_COMPONENT_NAME_PROTOCOL instance.
139 @param ControllerHandle[in] The handle of a controller that the driver
140 specified by This is managing. This handle
141 specifies the controller whose name is to be
144 @param ChildHandle[in] The handle of the child controller to retrieve
145 the name of. This is an optional parameter that
146 may be NULL. It will be NULL for device
147 drivers. It will also be NULL for a bus drivers
148 that wish to retrieve the name of the bus
149 controller. It will not be NULL for a bus
150 driver that wishes to retrieve the name of a
153 @param Language[in] A pointer to a Null-terminated ASCII string
154 array indicating the language. This is the
155 language of the driver name that the caller is
156 requesting, and it must match one of the
157 languages specified in SupportedLanguages. The
158 number of languages supported by a driver is up
159 to the driver writer. Language is specified in
160 RFC 4646 or ISO 639-2 language code format.
162 @param ControllerName[out] A pointer to the Unicode string to return.
163 This Unicode string is the name of the
164 controller specified by ControllerHandle and
165 ChildHandle in the language specified by
166 Language from the point of view of the driver
169 @retval EFI_SUCCESS The Unicode string for the user readable name in
170 the language specified by Language for the
171 driver specified by This was returned in
174 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
176 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
179 @retval EFI_INVALID_PARAMETER Language is NULL.
181 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
183 @retval EFI_UNSUPPORTED The driver specified by This is not currently
184 managing the controller specified by
185 ControllerHandle and ChildHandle.
187 @retval EFI_UNSUPPORTED The driver specified by This does not support
188 the language specified by Language.
193 GraphicsConsoleComponentNameGetControllerName (
194 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
195 IN EFI_HANDLE ControllerHandle
,
196 IN EFI_HANDLE ChildHandle OPTIONAL
,
198 OUT CHAR16
**ControllerName
202 Reset the text output device hardware and optionally run diagnostics.
204 Implements SIMPLE_TEXT_OUTPUT.Reset().
205 If ExtendedVerification is TRUE, then perform dependent Graphics Console
206 device reset, and set display mode to mode 0.
207 If ExtendedVerification is FALSE, only set display mode to mode 0.
209 @param This Protocol instance pointer.
210 @param ExtendedVerification Indicates that the driver may perform a more
211 exhaustive verification operation of the device
214 @retval EFI_SUCCESS The text output device was reset.
215 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
221 GraphicsConsoleConOutReset (
222 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
223 IN BOOLEAN ExtendedVerification
227 Write a Unicode string to the output device.
229 Implements SIMPLE_TEXT_OUTPUT.OutputString().
230 The Unicode string will be converted to Glyphs and will be
231 sent to the Graphics Console.
233 @param This Protocol instance pointer.
234 @param WString The NULL-terminated Unicode string to be displayed
235 on the output device(s). All output devices must
236 also support the Unicode drawing defined in this file.
238 @retval EFI_SUCCESS The string was output to the device.
239 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
241 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
243 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
244 characters in the Unicode string could not be
245 rendered and were skipped.
250 GraphicsConsoleConOutOutputString (
251 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
256 Verifies that all characters in a Unicode string can be output to the
259 Implements SIMPLE_TEXT_OUTPUT.TestString().
260 If one of the characters in the *Wstring is neither valid valid Unicode
261 drawing characters, not ASCII code, then this function will return
264 @param This Protocol instance pointer.
265 @param WString The NULL-terminated Unicode string to be examined for the output
268 @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
269 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be
270 rendered by one or more of the output devices mapped
276 GraphicsConsoleConOutTestString (
277 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
282 Returns information for an available text mode that the output device(s)
285 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
286 It returns information for an available text mode that the Graphics Console supports.
287 In this driver,we only support text mode 80x25, which is defined as mode 0.
289 @param This Protocol instance pointer.
290 @param ModeNumber The mode number to return information on.
291 @param Columns The returned columns of the requested mode.
292 @param Rows The returned rows of the requested mode.
294 @retval EFI_SUCCESS The requested mode information is returned.
295 @retval EFI_UNSUPPORTED The mode number is not valid.
300 GraphicsConsoleConOutQueryMode (
301 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
308 Sets the output device(s) to a specified mode.
310 Implements SIMPLE_TEXT_OUTPUT.SetMode().
311 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
313 @param This Protocol instance pointer.
314 @param ModeNumber The text mode to set.
316 @retval EFI_SUCCESS The requested text mode is set.
317 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
318 Graphics Console device error.
319 @retval EFI_UNSUPPORTED The text mode number is not valid.
324 GraphicsConsoleConOutSetMode (
325 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
330 Sets the background and foreground colors for the OutputString () and
331 ClearScreen () functions.
333 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
335 @param This Protocol instance pointer.
336 @param Attribute The attribute to set. Bits 0..3 are the foreground
337 color, and bits 4..6 are the background color.
338 All other bits are undefined and must be zero.
340 @retval EFI_SUCCESS The requested attribute is set.
341 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
342 @retval EFI_UNSUPPORTED The attribute requested is not defined.
347 GraphicsConsoleConOutSetAttribute (
348 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
353 Clears the output device(s) display to the currently selected background
356 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
358 @param This Protocol instance pointer.
360 @retval EFI_SUCCESS The operation completed successfully.
361 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
362 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
367 GraphicsConsoleConOutClearScreen (
368 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
372 Sets the current coordinates of the cursor position.
374 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
376 @param This Protocol instance pointer.
377 @param Column The position to set the cursor to. Must be greater than or
378 equal to zero and less than the number of columns and rows
380 @param Row The position to set the cursor to. Must be greater than or
381 equal to zero and less than the number of columns and rows
384 @retval EFI_SUCCESS The operation completed successfully.
385 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
386 @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
387 cursor position is invalid for the current mode.
392 GraphicsConsoleConOutSetCursorPosition (
393 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
399 Makes the cursor visible or invisible.
401 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
403 @param This Protocol instance pointer.
404 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
405 the cursor is set to be invisible.
407 @retval EFI_SUCCESS The operation completed successfully.
412 GraphicsConsoleConOutEnableCursor (
413 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
418 Test to see if Graphics Console could be supported on the Controller.
420 Graphics Console could be supported if Graphics Output Protocol or UGADraw
421 Protocol exists on the Controller. (UGA Draw Protocol could be skipped
422 if PcdUgaConsumeSupport is set to FALSE.)
424 @param This Protocol instance pointer.
425 @param Controller Handle of device to test.
426 @param RemainingDevicePath Optional parameter use to pick a specific child
429 @retval EFI_SUCCESS This driver supports this device.
430 @retval other This driver does not support this device.
435 GraphicsConsoleControllerDriverSupported (
436 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
437 IN EFI_HANDLE Controller
,
438 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
442 Start this driver on Controller by opening Graphics Output protocol or
443 UGA Draw protocol, and installing Simple Text Out protocol on Controller.
444 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
446 @param This Protocol instance pointer.
447 @param Controller Handle of device to bind driver to
448 @param RemainingDevicePath Optional parameter use to pick a specific child
451 @retval EFI_SUCCESS This driver is added to Controller.
452 @retval other This driver does not support this device.
457 GraphicsConsoleControllerDriverStart (
458 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
459 IN EFI_HANDLE Controller
,
460 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
464 Stop this driver on Controller by removing Simple Text Out protocol
465 and closing the Graphics Output Protocol or UGA Draw protocol on Controller.
466 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
469 @param This Protocol instance pointer.
470 @param Controller Handle of device to stop driver on
471 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
472 children is zero stop the entire bus driver.
473 @param ChildHandleBuffer List of Child Handles to Stop.
475 @retval EFI_SUCCESS This driver is removed Controller.
476 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
478 @retval other This driver was not removed from this device.
483 GraphicsConsoleControllerDriverStop (
484 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
485 IN EFI_HANDLE Controller
,
486 IN UINTN NumberOfChildren
,
487 IN EFI_HANDLE
*ChildHandleBuffer
491 Locate HII Database protocol and HII Font protocol.
493 @retval EFI_SUCCESS HII Database protocol and HII Font protocol
494 are located successfully.
495 @return other Failed to locate HII Database protocol or
500 EfiLocateHiiProtocol (
505 Gets Graphics Console device's foreground color and background color.
507 @param This Protocol instance pointer.
508 @param Foreground Returned text foreground color.
509 @param Background Returned text background color.
511 @retval EFI_SUCCESS It returned always.
516 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
517 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
518 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
522 Draw Unicode string on the Graphics Console device's screen.
524 @param This Protocol instance pointer.
525 @param UnicodeWeight One Unicode string to be displayed.
526 @param Count The count of Unicode string.
528 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
529 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
531 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
535 DrawUnicodeWeightAtCursorN (
536 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
537 IN CHAR16
*UnicodeWeight
,
542 Flush the cursor on the screen.
544 If CursorVisible is FALSE, nothing to do and return directly.
545 If CursorVisible is TRUE,
546 i) If the cursor shows on screen, it will be erased.
547 ii) If the cursor does not show on screen, it will be shown.
549 @param This Protocol instance pointer.
551 @retval EFI_SUCCESS The cursor is erased successfully.
556 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
560 Check if the current specific mode supported the user defined resolution
561 for the Graphics Console device based on Graphics Output Protocol.
563 If yes, set the graphic device's current mode to this specific mode.
565 @param GraphicsOutput Graphics Output Protocol instance pointer.
566 @param HorizontalResolution User defined horizontal resolution
567 @param VerticalResolution User defined vertical resolution.
568 @param CurrentModeNumber Current specific mode to be check.
570 @retval EFI_SUCCESS The mode is supported.
571 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
573 @retval other The specific mode does not support user defined
574 resolution or failed to set the current mode to the
575 specific mode on graphics device.
580 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
581 IN UINT32 HorizontalResolution
,
582 IN UINT32 VerticalResolution
,
583 OUT UINT32
*CurrentModeNumber