2 Header file for GraphicsConsole driver.
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. 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 <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 EFI_HII_HANDLE HiiHandle
;
83 } GRAPHICS_CONSOLE_DEV
;
85 #define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \
86 CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)
90 // EFI Component Name Functions
93 Retrieves a Unicode string that is the user readable name of the driver.
95 This function retrieves the user readable name of a driver in the form of a
96 Unicode string. If the driver specified by This has a user readable name in
97 the language specified by Language, then a pointer to the driver name is
98 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
99 by This does not support the language specified by Language,
100 then EFI_UNSUPPORTED is returned.
102 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
103 EFI_COMPONENT_NAME_PROTOCOL instance.
105 @param Language[in] A pointer to a Null-terminated ASCII string
106 array indicating the language. This is the
107 language of the driver name that the caller is
108 requesting, and it must match one of the
109 languages specified in SupportedLanguages. The
110 number of languages supported by a driver is up
111 to the driver writer. Language is specified
112 in RFC 3066 or ISO 639-2 language code format.
114 @param DriverName[out] A pointer to the Unicode string to return.
115 This Unicode string is the name of the
116 driver specified by This in the language
117 specified by Language.
119 @retval EFI_SUCCESS The Unicode string for the Driver specified by
120 This and the language specified by Language was
121 returned in DriverName.
123 @retval EFI_INVALID_PARAMETER Language is NULL.
125 @retval EFI_INVALID_PARAMETER DriverName is NULL.
127 @retval EFI_UNSUPPORTED The driver specified by This does not support
128 the language specified by Language.
133 GraphicsConsoleComponentNameGetDriverName (
134 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
136 OUT CHAR16
**DriverName
141 Retrieves a Unicode string that is the user readable name of the controller
142 that is being managed by a driver.
144 This function retrieves the user readable name of the controller specified by
145 ControllerHandle and ChildHandle in the form of a Unicode string. If the
146 driver specified by This has a user readable name in the language specified by
147 Language, then a pointer to the controller name is returned in ControllerName,
148 and EFI_SUCCESS is returned. If the driver specified by This is not currently
149 managing the controller specified by ControllerHandle and ChildHandle,
150 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
151 support the language specified by Language, then EFI_UNSUPPORTED is returned.
153 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
154 EFI_COMPONENT_NAME_PROTOCOL instance.
156 @param ControllerHandle[in] The handle of a controller that the driver
157 specified by This is managing. This handle
158 specifies the controller whose name is to be
161 @param ChildHandle[in] The handle of the child controller to retrieve
162 the name of. This is an optional parameter that
163 may be NULL. It will be NULL for device
164 drivers. It will also be NULL for a bus drivers
165 that wish to retrieve the name of the bus
166 controller. It will not be NULL for a bus
167 driver that wishes to retrieve the name of a
170 @param Language[in] A pointer to a Null-terminated ASCII string
171 array indicating the language. This is the
172 language of the driver name that the caller is
173 requesting, and it must match one of the
174 languages specified in SupportedLanguages. The
175 number of languages supported by a driver is up
176 to the driver writer. Language is specified in
177 RFC 3066 or ISO 639-2 language code format.
179 @param ControllerName[out] A pointer to the Unicode string to return.
180 This Unicode string is the name of the
181 controller specified by ControllerHandle and
182 ChildHandle in the language specified by
183 Language from the point of view of the driver
186 @retval EFI_SUCCESS The Unicode string for the user readable name in
187 the language specified by Language for the
188 driver specified by This was returned in
191 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
193 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
196 @retval EFI_INVALID_PARAMETER Language is NULL.
198 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
200 @retval EFI_UNSUPPORTED The driver specified by This is not currently
201 managing the controller specified by
202 ControllerHandle and ChildHandle.
204 @retval EFI_UNSUPPORTED The driver specified by This does not support
205 the language specified by Language.
210 GraphicsConsoleComponentNameGetControllerName (
211 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
212 IN EFI_HANDLE ControllerHandle
,
213 IN EFI_HANDLE ChildHandle OPTIONAL
,
215 OUT CHAR16
**ControllerName
220 Reset the text output device hardware and optionally run diagnostics.
222 Implements SIMPLE_TEXT_OUTPUT.Reset().
223 If ExtendeVerification is TRUE, then perform dependent Graphics Console
224 device reset, and set display mode to mode 0.
225 If ExtendedVerification is FALSE, only set display mode to mode 0.
227 @param This Protocol instance pointer.
228 @param ExtendedVerification Indicates that the driver may perform a more
229 exhaustive verification operation of the device
232 @retval EFI_SUCCESS The text output device was reset.
233 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
239 GraphicsConsoleConOutReset (
240 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
241 IN BOOLEAN ExtendedVerification
245 Write a Unicode string to the output device.
247 Implements SIMPLE_TEXT_OUTPUT.OutputString().
248 The Unicode string will be converted to Glyphs and will be
249 sent to the Graphics Console.
251 @param This Protocol instance pointer.
252 @param WString The NULL-terminated Unicode string to be displayed
253 on the output device(s). All output devices must
254 also support the Unicode drawing defined in this file.
256 @retval EFI_SUCCESS The string was output to the device.
257 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
259 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
261 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
262 characters in the Unicode string could not be
263 rendered and were skipped.
268 GraphicsConsoleConOutOutputString (
269 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
274 Verifies that all characters in a Unicode string can be output to the
277 Implements SIMPLE_TEXT_OUTPUT.TestString().
278 If one of the characters in the *Wstring is neither valid valid Unicode
279 drawing characters, not ASCII code, then this function will return
282 @param This Protocol instance pointer.
283 @param WString The NULL-terminated Unicode string to be examined for the output
286 @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
287 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be
288 rendered by one or more of the output devices mapped
294 GraphicsConsoleConOutTestString (
295 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
300 Returns information for an available text mode that the output device(s)
303 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
304 It returnes information for an available text mode that the Graphics Console supports.
305 In this driver,we only support text mode 80x25, which is defined as mode 0.
307 @param This Protocol instance pointer.
308 @param ModeNumber The mode number to return information on.
309 @param Columns The returned columns of the requested mode.
310 @param Rows The returned rows of the requested mode.
312 @retval EFI_SUCCESS The requested mode information is returned.
313 @retval EFI_UNSUPPORTED The mode number is not valid.
318 GraphicsConsoleConOutQueryMode (
319 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
327 Sets the output device(s) to a specified mode.
329 Implements SIMPLE_TEXT_OUTPUT.SetMode().
330 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
332 @param This Protocol instance pointer.
333 @param ModeNumber The text mode to set.
335 @retval EFI_SUCCESS The requested text mode is set.
336 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
337 Graphics Console device error.
338 @retval EFI_UNSUPPORTED The text mode number is not valid.
343 GraphicsConsoleConOutSetMode (
344 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
349 Sets the background and foreground colors for the OutputString () and
350 ClearScreen () functions.
352 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
354 @param This Protocol instance pointer.
355 @param Attribute The attribute to set. Bits 0..3 are the foreground
356 color, and bits 4..6 are the background color.
357 All other bits are undefined and must be zero.
359 @retval EFI_SUCCESS The requested attribute is set.
360 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
361 @retval EFI_UNSUPPORTED The attribute requested is not defined.
366 GraphicsConsoleConOutSetAttribute (
367 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
372 Clears the output device(s) display to the currently selected background
375 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
377 @param This Protocol instance pointer.
379 @retval EFI_SUCCESS The operation completed successfully.
380 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
381 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
386 GraphicsConsoleConOutClearScreen (
387 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
391 Sets the current coordinates of the cursor position.
393 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
395 @param This Protocol instance pointer.
396 @param Column The position to set the cursor to. Must be greater than or
397 equal to zero and less than the number of columns and rows
399 @param Row The position to set the cursor to. Must be greater than or
400 equal to zero and less than the number of columns and rows
403 @retval EFI_SUCCESS The operation completed successfully.
404 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
405 @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
406 cursor position is invalid for the current mode.
411 GraphicsConsoleConOutSetCursorPosition (
412 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
419 Makes the cursor visible or invisible.
421 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
423 @param This Protocol instance pointer.
424 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
425 the cursor is set to be invisible.
427 @retval EFI_SUCCESS The operation completed successfully.
432 GraphicsConsoleConOutEnableCursor (
433 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
438 Test to see if Graphics Console could be supported on the Controller.
440 Graphics Console could be supported if Graphics Output Protocol or UGA Draw
441 Protocol exists on the Controller. (UGA Draw Protocol could be skipped
442 if PcdUgaConsumeSupport is set to FALSE.)
444 @param This Protocol instance pointer.
445 @param Controller Handle of device to test.
446 @param RemainingDevicePath Optional parameter use to pick a specific child
449 @retval EFI_SUCCESS This driver supports this device.
450 @retval other This driver does not support this device.
455 GraphicsConsoleControllerDriverSupported (
456 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
457 IN EFI_HANDLE Controller
,
458 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
463 Start this driver on Controller by opening Graphics Output protocol or
464 UGA Draw protocol, and installing Simple Text Out protocol on Controller.
465 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
467 @param This Protocol instance pointer.
468 @param Controller Handle of device to bind driver to
469 @param RemainingDevicePath Optional parameter use to pick a specific child
472 @retval EFI_SUCCESS This driver is added to Controller.
473 @retval other This driver does not support this device.
478 GraphicsConsoleControllerDriverStart (
479 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
480 IN EFI_HANDLE Controller
,
481 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
485 Stop this driver on Controller by removing Simple Text Out protocol
486 and closing the Graphics Output Protocol or UGA Draw protocol on Controller.
487 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
490 @param This Protocol instance pointer.
491 @param Controller Handle of device to stop driver on
492 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
493 children is zero stop the entire bus driver.
494 @param ChildHandleBuffer List of Child Handles to Stop.
496 @retval EFI_SUCCESS This driver is removed Controller.
497 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
499 @retval other This driver was not removed from this device.
504 GraphicsConsoleControllerDriverStop (
505 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
506 IN EFI_HANDLE Controller
,
507 IN UINTN NumberOfChildren
,
508 IN EFI_HANDLE
*ChildHandleBuffer
513 Locate HII Database protocol and HII Font protocol.
515 @retval EFI_SUCCESS HII Database protocol and HII Font protocol
516 are located successfully.
517 @return other Failed to locate HII Database protocol or
522 EfiLocateHiiProtocol (
528 Gets Graphics Console devcie's foreground color and background color.
530 @param This Protocol instance pointer.
531 @param Foreground Returned text foreground color.
532 @param Background Returned text background color.
534 @retval EFI_SUCCESS It returned always.
539 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
540 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
541 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
545 Draw Unicode string on the Graphics Console device's screen.
547 @param This Protocol instance pointer.
548 @param UnicodeWeight One Unicode string to be displayed.
549 @param Count The count of Unicode string.
551 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
552 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
554 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
558 DrawUnicodeWeightAtCursorN (
559 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
560 IN CHAR16
*UnicodeWeight
,
565 Erase the cursor on the screen.
567 @param This Protocol instance pointer.
569 @retval EFI_SUCCESS The cursor is erased successfully.
574 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
578 Check if the current specific mode supported the user defined resolution
579 for the Graphics Console device based on Graphics Output Protocol.
581 If yes, set the graphic device's current mode to this specific mode.
583 @param GraphicsOutput Graphics Output Protocol instance pointer.
584 @param HorizontalResolution User defined horizontal resolution
585 @param VerticalResolution User defined vertical resolution.
586 @param CurrentModeNumber Current specific mode to be check.
588 @retval EFI_SUCCESS The mode is supported.
589 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
591 @retval other The specific mode does not support user defined
592 resolution or failed to set the current mode to the
593 specific mode on graphics device.
598 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
599 IN UINT32 HorizontalResolution
,
600 IN UINT32 VerticalResolution
,
601 OUT UINT32
*CurrentModeNumber