2 Header file for GraphicsConsole driver.
4 Copyright (c) 2006 - 2011, 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 _GRAPHICS_CONSOLE_H_
16 #define _GRAPHICS_CONSOLE_H_
19 #include <Protocol/SimpleTextOut.h>
20 #include <Protocol/GraphicsOutput.h>
21 #include <Protocol/UgaDraw.h>
22 #include <Protocol/DevicePath.h>
23 #include <Library/DebugLib.h>
24 #include <Library/UefiDriverEntryPoint.h>
25 #include <Library/UefiLib.h>
26 #include <Library/BaseMemoryLib.h>
27 #include <Library/MemoryAllocationLib.h>
28 #include <Library/UefiBootServicesTableLib.h>
29 #include <Library/HiiLib.h>
30 #include <Library/BaseLib.h>
31 #include <Library/PcdLib.h>
33 #include <Guid/MdeModuleHii.h>
35 #include <Protocol/HiiFont.h>
36 #include <Protocol/HiiDatabase.h>
39 extern EFI_COMPONENT_NAME_PROTOCOL gGraphicsConsoleComponentName
;
40 extern EFI_COMPONENT_NAME2_PROTOCOL gGraphicsConsoleComponentName2
;
41 extern EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding
;
42 extern EFI_NARROW_GLYPH gUsStdNarrowGlyphData
[];
44 extern UINT32 mNarrowFontSize
;
47 EFI_NARROW_GLYPH NarrowGlyph
;
48 EFI_WIDE_GLYPH WideGlyph
;
54 #define GRAPHICS_CONSOLE_DEV_SIGNATURE SIGNATURE_32 ('g', 's', 't', 'o')
64 } GRAPHICS_CONSOLE_MODE_DATA
;
66 #define GRAPHICS_MAX_MODE 5
70 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
71 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
72 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput
;
73 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode
;
74 GRAPHICS_CONSOLE_MODE_DATA ModeData
[GRAPHICS_MAX_MODE
];
75 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*LineBuffer
;
76 } GRAPHICS_CONSOLE_DEV
;
78 #define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \
79 CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)
83 // EFI Component Name Functions
86 Retrieves a Unicode string that is the user readable name of the driver.
88 This function retrieves the user readable name of a driver in the form of a
89 Unicode string. If the driver specified by This has a user readable name in
90 the language specified by Language, then a pointer to the driver name is
91 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
92 by This does not support the language specified by Language,
93 then EFI_UNSUPPORTED is returned.
95 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
96 EFI_COMPONENT_NAME_PROTOCOL instance.
98 @param Language[in] A pointer to a Null-terminated ASCII string
99 array indicating the language. This is the
100 language of the driver name that the caller is
101 requesting, and it must match one of the
102 languages specified in SupportedLanguages. The
103 number of languages supported by a driver is up
104 to the driver writer. Language is specified
105 in RFC 4646 or ISO 639-2 language code format.
107 @param DriverName[out] A pointer to the Unicode string to return.
108 This Unicode string is the name of the
109 driver specified by This in the language
110 specified by Language.
112 @retval EFI_SUCCESS The Unicode string for the Driver specified by
113 This and the language specified by Language was
114 returned in DriverName.
116 @retval EFI_INVALID_PARAMETER Language is NULL.
118 @retval EFI_INVALID_PARAMETER DriverName is NULL.
120 @retval EFI_UNSUPPORTED The driver specified by This does not support
121 the language specified by Language.
126 GraphicsConsoleComponentNameGetDriverName (
127 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
129 OUT CHAR16
**DriverName
134 Retrieves a Unicode string that is the user readable name of the controller
135 that is being managed by a driver.
137 This function retrieves the user readable name of the controller specified by
138 ControllerHandle and ChildHandle in the form of a Unicode string. If the
139 driver specified by This has a user readable name in the language specified by
140 Language, then a pointer to the controller name is returned in ControllerName,
141 and EFI_SUCCESS is returned. If the driver specified by This is not currently
142 managing the controller specified by ControllerHandle and ChildHandle,
143 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
144 support the language specified by Language, then EFI_UNSUPPORTED is returned.
146 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
147 EFI_COMPONENT_NAME_PROTOCOL instance.
149 @param ControllerHandle[in] The handle of a controller that the driver
150 specified by This is managing. This handle
151 specifies the controller whose name is to be
154 @param ChildHandle[in] The handle of the child controller to retrieve
155 the name of. This is an optional parameter that
156 may be NULL. It will be NULL for device
157 drivers. It will also be NULL for a bus drivers
158 that wish to retrieve the name of the bus
159 controller. It will not be NULL for a bus
160 driver that wishes to retrieve the name of a
163 @param Language[in] A pointer to a Null-terminated ASCII string
164 array indicating the language. This is the
165 language of the driver name that the caller is
166 requesting, and it must match one of the
167 languages specified in SupportedLanguages. The
168 number of languages supported by a driver is up
169 to the driver writer. Language is specified in
170 RFC 4646 or ISO 639-2 language code format.
172 @param ControllerName[out] A pointer to the Unicode string to return.
173 This Unicode string is the name of the
174 controller specified by ControllerHandle and
175 ChildHandle in the language specified by
176 Language from the point of view of the driver
179 @retval EFI_SUCCESS The Unicode string for the user readable name in
180 the language specified by Language for the
181 driver specified by This was returned in
184 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
186 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
189 @retval EFI_INVALID_PARAMETER Language is NULL.
191 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
193 @retval EFI_UNSUPPORTED The driver specified by This is not currently
194 managing the controller specified by
195 ControllerHandle and ChildHandle.
197 @retval EFI_UNSUPPORTED The driver specified by This does not support
198 the language specified by Language.
203 GraphicsConsoleComponentNameGetControllerName (
204 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
205 IN EFI_HANDLE ControllerHandle
,
206 IN EFI_HANDLE ChildHandle OPTIONAL
,
208 OUT CHAR16
**ControllerName
213 Reset the text output device hardware and optionally run diagnostics.
215 Implements SIMPLE_TEXT_OUTPUT.Reset().
216 If ExtendeVerification is TRUE, then perform dependent Graphics Console
217 device reset, and set display mode to mode 0.
218 If ExtendedVerification is FALSE, only set display mode to mode 0.
220 @param This Protocol instance pointer.
221 @param ExtendedVerification Indicates that the driver may perform a more
222 exhaustive verification operation of the device
225 @retval EFI_SUCCESS The text output device was reset.
226 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
232 GraphicsConsoleConOutReset (
233 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
234 IN BOOLEAN ExtendedVerification
238 Write a Unicode string to the output device.
240 Implements SIMPLE_TEXT_OUTPUT.OutputString().
241 The Unicode string will be converted to Glyphs and will be
242 sent to the Graphics Console.
244 @param This Protocol instance pointer.
245 @param WString The NULL-terminated Unicode string to be displayed
246 on the output device(s). All output devices must
247 also support the Unicode drawing defined in this file.
249 @retval EFI_SUCCESS The string was output to the device.
250 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
252 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
254 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
255 characters in the Unicode string could not be
256 rendered and were skipped.
261 GraphicsConsoleConOutOutputString (
262 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
267 Verifies that all characters in a Unicode string can be output to the
270 Implements SIMPLE_TEXT_OUTPUT.TestString().
271 If one of the characters in the *Wstring is neither valid valid Unicode
272 drawing characters, not ASCII code, then this function will return
275 @param This Protocol instance pointer.
276 @param WString The NULL-terminated Unicode string to be examined for the output
279 @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
280 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be
281 rendered by one or more of the output devices mapped
287 GraphicsConsoleConOutTestString (
288 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
293 Returns information for an available text mode that the output device(s)
296 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
297 It returnes information for an available text mode that the Graphics Console supports.
298 In this driver,we only support text mode 80x25, which is defined as mode 0.
300 @param This Protocol instance pointer.
301 @param ModeNumber The mode number to return information on.
302 @param Columns The returned columns of the requested mode.
303 @param Rows The returned rows of the requested mode.
305 @retval EFI_SUCCESS The requested mode information is returned.
306 @retval EFI_UNSUPPORTED The mode number is not valid.
311 GraphicsConsoleConOutQueryMode (
312 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
320 Sets the output device(s) to a specified mode.
322 Implements SIMPLE_TEXT_OUTPUT.SetMode().
323 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
325 @param This Protocol instance pointer.
326 @param ModeNumber The text mode to set.
328 @retval EFI_SUCCESS The requested text mode is set.
329 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
330 Graphics Console device error.
331 @retval EFI_UNSUPPORTED The text mode number is not valid.
336 GraphicsConsoleConOutSetMode (
337 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
342 Sets the background and foreground colors for the OutputString () and
343 ClearScreen () functions.
345 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
347 @param This Protocol instance pointer.
348 @param Attribute The attribute to set. Bits 0..3 are the foreground
349 color, and bits 4..6 are the background color.
350 All other bits are undefined and must be zero.
352 @retval EFI_SUCCESS The requested attribute is set.
353 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
354 @retval EFI_UNSUPPORTED The attribute requested is not defined.
359 GraphicsConsoleConOutSetAttribute (
360 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
365 Clears the output device(s) display to the currently selected background
368 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
370 @param This Protocol instance pointer.
372 @retval EFI_SUCCESS The operation completed successfully.
373 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
374 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
379 GraphicsConsoleConOutClearScreen (
380 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
384 Sets the current coordinates of the cursor position.
386 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
388 @param This Protocol instance pointer.
389 @param Column The position to set the cursor to. Must be greater than or
390 equal to zero and less than the number of columns and rows
392 @param Row The position to set the cursor to. Must be greater than or
393 equal to zero and less than the number of columns and rows
396 @retval EFI_SUCCESS The operation completed successfully.
397 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
398 @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
399 cursor position is invalid for the current mode.
404 GraphicsConsoleConOutSetCursorPosition (
405 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
412 Makes the cursor visible or invisible.
414 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
416 @param This Protocol instance pointer.
417 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
418 the cursor is set to be invisible.
420 @retval EFI_SUCCESS The operation completed successfully.
425 GraphicsConsoleConOutEnableCursor (
426 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
431 Test to see if Graphics Console could be supported on the Controller.
433 Graphics Console could be supported if Graphics Output Protocol or UGA Draw
434 Protocol exists on the Controller. (UGA Draw Protocol could be skipped
435 if PcdUgaConsumeSupport is set to FALSE.)
437 @param This Protocol instance pointer.
438 @param Controller Handle of device to test.
439 @param RemainingDevicePath Optional parameter use to pick a specific child
442 @retval EFI_SUCCESS This driver supports this device.
443 @retval other This driver does not support this device.
448 GraphicsConsoleControllerDriverSupported (
449 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
450 IN EFI_HANDLE Controller
,
451 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
456 Start this driver on Controller by opening Graphics Output protocol or
457 UGA Draw protocol, and installing Simple Text Out protocol on Controller.
458 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
460 @param This Protocol instance pointer.
461 @param Controller Handle of device to bind driver to
462 @param RemainingDevicePath Optional parameter use to pick a specific child
465 @retval EFI_SUCCESS This driver is added to Controller.
466 @retval other This driver does not support this device.
471 GraphicsConsoleControllerDriverStart (
472 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
473 IN EFI_HANDLE Controller
,
474 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
478 Stop this driver on Controller by removing Simple Text Out protocol
479 and closing the Graphics Output Protocol or UGA Draw protocol on Controller.
480 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
483 @param This Protocol instance pointer.
484 @param Controller Handle of device to stop driver on
485 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
486 children is zero stop the entire bus driver.
487 @param ChildHandleBuffer List of Child Handles to Stop.
489 @retval EFI_SUCCESS This driver is removed Controller.
490 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
492 @retval other This driver was not removed from this device.
497 GraphicsConsoleControllerDriverStop (
498 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
499 IN EFI_HANDLE Controller
,
500 IN UINTN NumberOfChildren
,
501 IN EFI_HANDLE
*ChildHandleBuffer
506 Locate HII Database protocol and HII Font protocol.
508 @retval EFI_SUCCESS HII Database protocol and HII Font protocol
509 are located successfully.
510 @return other Failed to locate HII Database protocol or
515 EfiLocateHiiProtocol (
521 Gets Graphics Console devcie's foreground color and background color.
523 @param This Protocol instance pointer.
524 @param Foreground Returned text foreground color.
525 @param Background Returned text background color.
527 @retval EFI_SUCCESS It returned always.
532 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
533 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
534 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
538 Draw Unicode string on the Graphics Console device's screen.
540 @param This Protocol instance pointer.
541 @param UnicodeWeight One Unicode string to be displayed.
542 @param Count The count of Unicode string.
544 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
545 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
547 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
551 DrawUnicodeWeightAtCursorN (
552 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
553 IN CHAR16
*UnicodeWeight
,
558 Flush the cursor on the screen.
560 If CursorVisible is FALSE, nothing to do and return directly.
561 If CursorVisible is TRUE,
562 i) If the cursor shows on screen, it will be erased.
563 ii) If the cursor does not show on screen, it will be shown.
565 @param This Protocol instance pointer.
567 @retval EFI_SUCCESS The cursor is erased successfully.
572 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
576 Check if the current specific mode supported the user defined resolution
577 for the Graphics Console device based on Graphics Output Protocol.
579 If yes, set the graphic device's current mode to this specific mode.
581 @param GraphicsOutput Graphics Output Protocol instance pointer.
582 @param HorizontalResolution User defined horizontal resolution
583 @param VerticalResolution User defined vertical resolution.
584 @param CurrentModeNumber Current specific mode to be check.
586 @retval EFI_SUCCESS The mode is supported.
587 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
589 @retval other The specific mode does not support user defined
590 resolution or failed to set the current mode to the
591 specific mode on graphics device.
596 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
597 IN UINT32 HorizontalResolution
,
598 IN UINT32 VerticalResolution
,
599 OUT UINT32
*CurrentModeNumber