2 Header file for GraphicsConsole driver.
4 Copyright (c) 2006 - 2009, 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
;
46 // User can define valid graphic resolution here
47 // e.g. 640x480, 800x600, 1024x768...
49 #define CURRENT_HORIZONTAL_RESOLUTION 800
50 #define CURRENT_VERTICAL_RESOLUTION 600
53 EFI_NARROW_GLYPH NarrowGlyph
;
54 EFI_WIDE_GLYPH WideGlyph
;
60 #define GRAPHICS_CONSOLE_DEV_SIGNATURE SIGNATURE_32 ('g', 's', 't', 'o')
70 } GRAPHICS_CONSOLE_MODE_DATA
;
72 #define GRAPHICS_MAX_MODE 4
76 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
77 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
78 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput
;
79 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode
;
80 GRAPHICS_CONSOLE_MODE_DATA ModeData
[GRAPHICS_MAX_MODE
];
81 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*LineBuffer
;
82 } GRAPHICS_CONSOLE_DEV
;
84 #define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \
85 CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)
89 // EFI Component Name Functions
92 Retrieves a Unicode string that is the user readable name of the driver.
94 This function retrieves the user readable name of a driver in the form of a
95 Unicode string. If the driver specified by This has a user readable name in
96 the language specified by Language, then a pointer to the driver name is
97 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
98 by This does not support the language specified by Language,
99 then EFI_UNSUPPORTED is returned.
101 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
102 EFI_COMPONENT_NAME_PROTOCOL instance.
104 @param Language[in] A pointer to a Null-terminated ASCII string
105 array indicating the language. This is the
106 language of the driver name that the caller is
107 requesting, and it must match one of the
108 languages specified in SupportedLanguages. The
109 number of languages supported by a driver is up
110 to the driver writer. Language is specified
111 in RFC 4646 or ISO 639-2 language code format.
113 @param DriverName[out] A pointer to the Unicode string to return.
114 This Unicode string is the name of the
115 driver specified by This in the language
116 specified by Language.
118 @retval EFI_SUCCESS The Unicode string for the Driver specified by
119 This and the language specified by Language was
120 returned in DriverName.
122 @retval EFI_INVALID_PARAMETER Language is NULL.
124 @retval EFI_INVALID_PARAMETER DriverName is NULL.
126 @retval EFI_UNSUPPORTED The driver specified by This does not support
127 the language specified by Language.
132 GraphicsConsoleComponentNameGetDriverName (
133 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
135 OUT CHAR16
**DriverName
140 Retrieves a Unicode string that is the user readable name of the controller
141 that is being managed by a driver.
143 This function retrieves the user readable name of the controller specified by
144 ControllerHandle and ChildHandle in the form of a Unicode string. If the
145 driver specified by This has a user readable name in the language specified by
146 Language, then a pointer to the controller name is returned in ControllerName,
147 and EFI_SUCCESS is returned. If the driver specified by This is not currently
148 managing the controller specified by ControllerHandle and ChildHandle,
149 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
150 support the language specified by Language, then EFI_UNSUPPORTED is returned.
152 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
153 EFI_COMPONENT_NAME_PROTOCOL instance.
155 @param ControllerHandle[in] The handle of a controller that the driver
156 specified by This is managing. This handle
157 specifies the controller whose name is to be
160 @param ChildHandle[in] The handle of the child controller to retrieve
161 the name of. This is an optional parameter that
162 may be NULL. It will be NULL for device
163 drivers. It will also be NULL for a bus drivers
164 that wish to retrieve the name of the bus
165 controller. It will not be NULL for a bus
166 driver that wishes to retrieve the name of a
169 @param Language[in] A pointer to a Null-terminated ASCII string
170 array indicating the language. This is the
171 language of the driver name that the caller is
172 requesting, and it must match one of the
173 languages specified in SupportedLanguages. The
174 number of languages supported by a driver is up
175 to the driver writer. Language is specified in
176 RFC 4646 or ISO 639-2 language code format.
178 @param ControllerName[out] A pointer to the Unicode string to return.
179 This Unicode string is the name of the
180 controller specified by ControllerHandle and
181 ChildHandle in the language specified by
182 Language from the point of view of the driver
185 @retval EFI_SUCCESS The Unicode string for the user readable name in
186 the language specified by Language for the
187 driver specified by This was returned in
190 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
192 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
195 @retval EFI_INVALID_PARAMETER Language is NULL.
197 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
199 @retval EFI_UNSUPPORTED The driver specified by This is not currently
200 managing the controller specified by
201 ControllerHandle and ChildHandle.
203 @retval EFI_UNSUPPORTED The driver specified by This does not support
204 the language specified by Language.
209 GraphicsConsoleComponentNameGetControllerName (
210 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
211 IN EFI_HANDLE ControllerHandle
,
212 IN EFI_HANDLE ChildHandle OPTIONAL
,
214 OUT CHAR16
**ControllerName
219 Reset the text output device hardware and optionally run diagnostics.
221 Implements SIMPLE_TEXT_OUTPUT.Reset().
222 If ExtendeVerification is TRUE, then perform dependent Graphics Console
223 device reset, and set display mode to mode 0.
224 If ExtendedVerification is FALSE, only set display mode to mode 0.
226 @param This Protocol instance pointer.
227 @param ExtendedVerification Indicates that the driver may perform a more
228 exhaustive verification operation of the device
231 @retval EFI_SUCCESS The text output device was reset.
232 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
238 GraphicsConsoleConOutReset (
239 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
240 IN BOOLEAN ExtendedVerification
244 Write a Unicode string to the output device.
246 Implements SIMPLE_TEXT_OUTPUT.OutputString().
247 The Unicode string will be converted to Glyphs and will be
248 sent to the Graphics Console.
250 @param This Protocol instance pointer.
251 @param WString The NULL-terminated Unicode string to be displayed
252 on the output device(s). All output devices must
253 also support the Unicode drawing defined in this file.
255 @retval EFI_SUCCESS The string was output to the device.
256 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
258 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
260 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
261 characters in the Unicode string could not be
262 rendered and were skipped.
267 GraphicsConsoleConOutOutputString (
268 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
273 Verifies that all characters in a Unicode string can be output to the
276 Implements SIMPLE_TEXT_OUTPUT.TestString().
277 If one of the characters in the *Wstring is neither valid valid Unicode
278 drawing characters, not ASCII code, then this function will return
281 @param This Protocol instance pointer.
282 @param WString The NULL-terminated Unicode string to be examined for the output
285 @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
286 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be
287 rendered by one or more of the output devices mapped
293 GraphicsConsoleConOutTestString (
294 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
299 Returns information for an available text mode that the output device(s)
302 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
303 It returnes information for an available text mode that the Graphics Console supports.
304 In this driver,we only support text mode 80x25, which is defined as mode 0.
306 @param This Protocol instance pointer.
307 @param ModeNumber The mode number to return information on.
308 @param Columns The returned columns of the requested mode.
309 @param Rows The returned rows of the requested mode.
311 @retval EFI_SUCCESS The requested mode information is returned.
312 @retval EFI_UNSUPPORTED The mode number is not valid.
317 GraphicsConsoleConOutQueryMode (
318 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
326 Sets the output device(s) to a specified mode.
328 Implements SIMPLE_TEXT_OUTPUT.SetMode().
329 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
331 @param This Protocol instance pointer.
332 @param ModeNumber The text mode to set.
334 @retval EFI_SUCCESS The requested text mode is set.
335 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
336 Graphics Console device error.
337 @retval EFI_UNSUPPORTED The text mode number is not valid.
342 GraphicsConsoleConOutSetMode (
343 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
348 Sets the background and foreground colors for the OutputString () and
349 ClearScreen () functions.
351 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
353 @param This Protocol instance pointer.
354 @param Attribute The attribute to set. Bits 0..3 are the foreground
355 color, and bits 4..6 are the background color.
356 All other bits are undefined and must be zero.
358 @retval EFI_SUCCESS The requested attribute is set.
359 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
360 @retval EFI_UNSUPPORTED The attribute requested is not defined.
365 GraphicsConsoleConOutSetAttribute (
366 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
371 Clears the output device(s) display to the currently selected background
374 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
376 @param This Protocol instance pointer.
378 @retval EFI_SUCCESS The operation completed successfully.
379 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
380 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
385 GraphicsConsoleConOutClearScreen (
386 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
390 Sets the current coordinates of the cursor position.
392 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
394 @param This Protocol instance pointer.
395 @param Column The position to set the cursor to. Must be greater than or
396 equal to zero and less than the number of columns and rows
398 @param Row The position to set the cursor to. Must be greater than or
399 equal to zero and less than the number of columns and rows
402 @retval EFI_SUCCESS The operation completed successfully.
403 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
404 @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
405 cursor position is invalid for the current mode.
410 GraphicsConsoleConOutSetCursorPosition (
411 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
418 Makes the cursor visible or invisible.
420 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
422 @param This Protocol instance pointer.
423 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
424 the cursor is set to be invisible.
426 @retval EFI_SUCCESS The operation completed successfully.
431 GraphicsConsoleConOutEnableCursor (
432 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
437 Test to see if Graphics Console could be supported on the Controller.
439 Graphics Console could be supported if Graphics Output Protocol or UGA Draw
440 Protocol exists on the Controller. (UGA Draw Protocol could be skipped
441 if PcdUgaConsumeSupport is set to FALSE.)
443 @param This Protocol instance pointer.
444 @param Controller Handle of device to test.
445 @param RemainingDevicePath Optional parameter use to pick a specific child
448 @retval EFI_SUCCESS This driver supports this device.
449 @retval other This driver does not support this device.
454 GraphicsConsoleControllerDriverSupported (
455 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
456 IN EFI_HANDLE Controller
,
457 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
462 Start this driver on Controller by opening Graphics Output protocol or
463 UGA Draw protocol, and installing Simple Text Out protocol on Controller.
464 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
466 @param This Protocol instance pointer.
467 @param Controller Handle of device to bind driver to
468 @param RemainingDevicePath Optional parameter use to pick a specific child
471 @retval EFI_SUCCESS This driver is added to Controller.
472 @retval other This driver does not support this device.
477 GraphicsConsoleControllerDriverStart (
478 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
479 IN EFI_HANDLE Controller
,
480 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
484 Stop this driver on Controller by removing Simple Text Out protocol
485 and closing the Graphics Output Protocol or UGA Draw protocol on Controller.
486 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
489 @param This Protocol instance pointer.
490 @param Controller Handle of device to stop driver on
491 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
492 children is zero stop the entire bus driver.
493 @param ChildHandleBuffer List of Child Handles to Stop.
495 @retval EFI_SUCCESS This driver is removed Controller.
496 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
498 @retval other This driver was not removed from this device.
503 GraphicsConsoleControllerDriverStop (
504 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
505 IN EFI_HANDLE Controller
,
506 IN UINTN NumberOfChildren
,
507 IN EFI_HANDLE
*ChildHandleBuffer
512 Locate HII Database protocol and HII Font protocol.
514 @retval EFI_SUCCESS HII Database protocol and HII Font protocol
515 are located successfully.
516 @return other Failed to locate HII Database protocol or
521 EfiLocateHiiProtocol (
527 Gets Graphics Console devcie's foreground color and background color.
529 @param This Protocol instance pointer.
530 @param Foreground Returned text foreground color.
531 @param Background Returned text background color.
533 @retval EFI_SUCCESS It returned always.
538 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
539 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
540 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
544 Draw Unicode string on the Graphics Console device's screen.
546 @param This Protocol instance pointer.
547 @param UnicodeWeight One Unicode string to be displayed.
548 @param Count The count of Unicode string.
550 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
551 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
553 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
557 DrawUnicodeWeightAtCursorN (
558 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
559 IN CHAR16
*UnicodeWeight
,
564 Erase the cursor on the screen.
566 @param This Protocol instance pointer.
568 @retval EFI_SUCCESS The cursor is erased successfully.
573 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
577 Check if the current specific mode supported the user defined resolution
578 for the Graphics Console device based on Graphics Output Protocol.
580 If yes, set the graphic device's current mode to this specific mode.
582 @param GraphicsOutput Graphics Output Protocol instance pointer.
583 @param HorizontalResolution User defined horizontal resolution
584 @param VerticalResolution User defined vertical resolution.
585 @param CurrentModeNumber Current specific mode to be check.
587 @retval EFI_SUCCESS The mode is supported.
588 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
590 @retval other The specific mode does not support user defined
591 resolution or failed to set the current mode to the
592 specific mode on graphics device.
597 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
598 IN UINT32 HorizontalResolution
,
599 IN UINT32 VerticalResolution
,
600 OUT UINT32
*CurrentModeNumber