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
;
68 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
69 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
70 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput
;
71 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode
;
72 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
73 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*LineBuffer
;
74 } GRAPHICS_CONSOLE_DEV
;
76 #define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \
77 CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)
81 // EFI Component Name Functions
84 Retrieves a Unicode string that is the user readable name of the driver.
86 This function retrieves the user readable name of a driver in the form of a
87 Unicode string. If the driver specified by This has a user readable name in
88 the language specified by Language, then a pointer to the driver name is
89 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
90 by This does not support the language specified by Language,
91 then EFI_UNSUPPORTED is returned.
93 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
94 EFI_COMPONENT_NAME_PROTOCOL instance.
96 @param Language[in] A pointer to a Null-terminated ASCII string
97 array indicating the language. This is the
98 language of the driver name that the caller is
99 requesting, and it must match one of the
100 languages specified in SupportedLanguages. The
101 number of languages supported by a driver is up
102 to the driver writer. Language is specified
103 in RFC 4646 or ISO 639-2 language code format.
105 @param DriverName[out] A pointer to the Unicode string to return.
106 This Unicode string is the name of the
107 driver specified by This in the language
108 specified by Language.
110 @retval EFI_SUCCESS The Unicode string for the Driver specified by
111 This and the language specified by Language was
112 returned in DriverName.
114 @retval EFI_INVALID_PARAMETER Language is NULL.
116 @retval EFI_INVALID_PARAMETER DriverName is NULL.
118 @retval EFI_UNSUPPORTED The driver specified by This does not support
119 the language specified by Language.
124 GraphicsConsoleComponentNameGetDriverName (
125 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
127 OUT CHAR16
**DriverName
132 Retrieves a Unicode string that is the user readable name of the controller
133 that is being managed by a driver.
135 This function retrieves the user readable name of the controller specified by
136 ControllerHandle and ChildHandle in the form of a Unicode string. If the
137 driver specified by This has a user readable name in the language specified by
138 Language, then a pointer to the controller name is returned in ControllerName,
139 and EFI_SUCCESS is returned. If the driver specified by This is not currently
140 managing the controller specified by ControllerHandle and ChildHandle,
141 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
142 support the language specified by Language, then EFI_UNSUPPORTED is returned.
144 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
145 EFI_COMPONENT_NAME_PROTOCOL instance.
147 @param ControllerHandle[in] The handle of a controller that the driver
148 specified by This is managing. This handle
149 specifies the controller whose name is to be
152 @param ChildHandle[in] The handle of the child controller to retrieve
153 the name of. This is an optional parameter that
154 may be NULL. It will be NULL for device
155 drivers. It will also be NULL for a bus drivers
156 that wish to retrieve the name of the bus
157 controller. It will not be NULL for a bus
158 driver that wishes to retrieve the name of a
161 @param Language[in] A pointer to a Null-terminated ASCII string
162 array indicating the language. This is the
163 language of the driver name that the caller is
164 requesting, and it must match one of the
165 languages specified in SupportedLanguages. The
166 number of languages supported by a driver is up
167 to the driver writer. Language is specified in
168 RFC 4646 or ISO 639-2 language code format.
170 @param ControllerName[out] A pointer to the Unicode string to return.
171 This Unicode string is the name of the
172 controller specified by ControllerHandle and
173 ChildHandle in the language specified by
174 Language from the point of view of the driver
177 @retval EFI_SUCCESS The Unicode string for the user readable name in
178 the language specified by Language for the
179 driver specified by This was returned in
182 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
184 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
187 @retval EFI_INVALID_PARAMETER Language is NULL.
189 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
191 @retval EFI_UNSUPPORTED The driver specified by This is not currently
192 managing the controller specified by
193 ControllerHandle and ChildHandle.
195 @retval EFI_UNSUPPORTED The driver specified by This does not support
196 the language specified by Language.
201 GraphicsConsoleComponentNameGetControllerName (
202 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
203 IN EFI_HANDLE ControllerHandle
,
204 IN EFI_HANDLE ChildHandle OPTIONAL
,
206 OUT CHAR16
**ControllerName
211 Reset the text output device hardware and optionally run diagnostics.
213 Implements SIMPLE_TEXT_OUTPUT.Reset().
214 If ExtendeVerification is TRUE, then perform dependent Graphics Console
215 device reset, and set display mode to mode 0.
216 If ExtendedVerification is FALSE, only set display mode to mode 0.
218 @param This Protocol instance pointer.
219 @param ExtendedVerification Indicates that the driver may perform a more
220 exhaustive verification operation of the device
223 @retval EFI_SUCCESS The text output device was reset.
224 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
230 GraphicsConsoleConOutReset (
231 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
232 IN BOOLEAN ExtendedVerification
236 Write a Unicode string to the output device.
238 Implements SIMPLE_TEXT_OUTPUT.OutputString().
239 The Unicode string will be converted to Glyphs and will be
240 sent to the Graphics Console.
242 @param This Protocol instance pointer.
243 @param WString The NULL-terminated Unicode string to be displayed
244 on the output device(s). All output devices must
245 also support the Unicode drawing defined in this file.
247 @retval EFI_SUCCESS The string was output to the device.
248 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
250 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
252 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
253 characters in the Unicode string could not be
254 rendered and were skipped.
259 GraphicsConsoleConOutOutputString (
260 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
265 Verifies that all characters in a Unicode string can be output to the
268 Implements SIMPLE_TEXT_OUTPUT.TestString().
269 If one of the characters in the *Wstring is neither valid valid Unicode
270 drawing characters, not ASCII code, then this function will return
273 @param This Protocol instance pointer.
274 @param WString The NULL-terminated Unicode string to be examined for the output
277 @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
278 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be
279 rendered by one or more of the output devices mapped
285 GraphicsConsoleConOutTestString (
286 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
291 Returns information for an available text mode that the output device(s)
294 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
295 It returnes information for an available text mode that the Graphics Console supports.
296 In this driver,we only support text mode 80x25, which is defined as mode 0.
298 @param This Protocol instance pointer.
299 @param ModeNumber The mode number to return information on.
300 @param Columns The returned columns of the requested mode.
301 @param Rows The returned rows of the requested mode.
303 @retval EFI_SUCCESS The requested mode information is returned.
304 @retval EFI_UNSUPPORTED The mode number is not valid.
309 GraphicsConsoleConOutQueryMode (
310 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
318 Sets the output device(s) to a specified mode.
320 Implements SIMPLE_TEXT_OUTPUT.SetMode().
321 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
323 @param This Protocol instance pointer.
324 @param ModeNumber The text mode to set.
326 @retval EFI_SUCCESS The requested text mode is set.
327 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
328 Graphics Console device error.
329 @retval EFI_UNSUPPORTED The text mode number is not valid.
334 GraphicsConsoleConOutSetMode (
335 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
340 Sets the background and foreground colors for the OutputString () and
341 ClearScreen () functions.
343 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
345 @param This Protocol instance pointer.
346 @param Attribute The attribute to set. Bits 0..3 are the foreground
347 color, and bits 4..6 are the background color.
348 All other bits are undefined and must be zero.
350 @retval EFI_SUCCESS The requested attribute is set.
351 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
352 @retval EFI_UNSUPPORTED The attribute requested is not defined.
357 GraphicsConsoleConOutSetAttribute (
358 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
363 Clears the output device(s) display to the currently selected background
366 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
368 @param This Protocol instance pointer.
370 @retval EFI_SUCCESS The operation completed successfully.
371 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
372 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
377 GraphicsConsoleConOutClearScreen (
378 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
382 Sets the current coordinates of the cursor position.
384 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
386 @param This Protocol instance pointer.
387 @param Column The position to set the cursor to. Must be greater than or
388 equal to zero and less than the number of columns and rows
390 @param Row The position to set the cursor to. Must be greater than or
391 equal to zero and less than the number of columns and rows
394 @retval EFI_SUCCESS The operation completed successfully.
395 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
396 @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
397 cursor position is invalid for the current mode.
402 GraphicsConsoleConOutSetCursorPosition (
403 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
410 Makes the cursor visible or invisible.
412 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
414 @param This Protocol instance pointer.
415 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
416 the cursor is set to be invisible.
418 @retval EFI_SUCCESS The operation completed successfully.
423 GraphicsConsoleConOutEnableCursor (
424 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
429 Test to see if Graphics Console could be supported on the Controller.
431 Graphics Console could be supported if Graphics Output Protocol or UGA Draw
432 Protocol exists on the Controller. (UGA Draw Protocol could be skipped
433 if PcdUgaConsumeSupport is set to FALSE.)
435 @param This Protocol instance pointer.
436 @param Controller Handle of device to test.
437 @param RemainingDevicePath Optional parameter use to pick a specific child
440 @retval EFI_SUCCESS This driver supports this device.
441 @retval other This driver does not support this device.
446 GraphicsConsoleControllerDriverSupported (
447 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
448 IN EFI_HANDLE Controller
,
449 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
454 Start this driver on Controller by opening Graphics Output protocol or
455 UGA Draw protocol, and installing Simple Text Out protocol on Controller.
456 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
458 @param This Protocol instance pointer.
459 @param Controller Handle of device to bind driver to
460 @param RemainingDevicePath Optional parameter use to pick a specific child
463 @retval EFI_SUCCESS This driver is added to Controller.
464 @retval other This driver does not support this device.
469 GraphicsConsoleControllerDriverStart (
470 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
471 IN EFI_HANDLE Controller
,
472 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
476 Stop this driver on Controller by removing Simple Text Out protocol
477 and closing the Graphics Output Protocol or UGA Draw protocol on Controller.
478 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
481 @param This Protocol instance pointer.
482 @param Controller Handle of device to stop driver on
483 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
484 children is zero stop the entire bus driver.
485 @param ChildHandleBuffer List of Child Handles to Stop.
487 @retval EFI_SUCCESS This driver is removed Controller.
488 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
490 @retval other This driver was not removed from this device.
495 GraphicsConsoleControllerDriverStop (
496 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
497 IN EFI_HANDLE Controller
,
498 IN UINTN NumberOfChildren
,
499 IN EFI_HANDLE
*ChildHandleBuffer
504 Locate HII Database protocol and HII Font protocol.
506 @retval EFI_SUCCESS HII Database protocol and HII Font protocol
507 are located successfully.
508 @return other Failed to locate HII Database protocol or
513 EfiLocateHiiProtocol (
519 Gets Graphics Console devcie's foreground color and background color.
521 @param This Protocol instance pointer.
522 @param Foreground Returned text foreground color.
523 @param Background Returned text background color.
525 @retval EFI_SUCCESS It returned always.
530 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
531 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
532 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
536 Draw Unicode string on the Graphics Console device's screen.
538 @param This Protocol instance pointer.
539 @param UnicodeWeight One Unicode string to be displayed.
540 @param Count The count of Unicode string.
542 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
543 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
545 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
549 DrawUnicodeWeightAtCursorN (
550 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
551 IN CHAR16
*UnicodeWeight
,
556 Flush the cursor on the screen.
558 If CursorVisible is FALSE, nothing to do and return directly.
559 If CursorVisible is TRUE,
560 i) If the cursor shows on screen, it will be erased.
561 ii) If the cursor does not show on screen, it will be shown.
563 @param This Protocol instance pointer.
565 @retval EFI_SUCCESS The cursor is erased successfully.
570 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
574 Check if the current specific mode supported the user defined resolution
575 for the Graphics Console device based on Graphics Output Protocol.
577 If yes, set the graphic device's current mode to this specific mode.
579 @param GraphicsOutput Graphics Output Protocol instance pointer.
580 @param HorizontalResolution User defined horizontal resolution
581 @param VerticalResolution User defined vertical resolution.
582 @param CurrentModeNumber Current specific mode to be check.
584 @retval EFI_SUCCESS The mode is supported.
585 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
587 @retval other The specific mode does not support user defined
588 resolution or failed to set the current mode to the
589 specific mode on graphics device.
594 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
595 IN UINT32 HorizontalResolution
,
596 IN UINT32 VerticalResolution
,
597 OUT UINT32
*CurrentModeNumber