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
;
43 // EFI Component Name Functions
46 Retrieves a Unicode string that is the user readable name of the driver.
48 This function retrieves the user readable name of a driver in the form of a
49 Unicode string. If the driver specified by This has a user readable name in
50 the language specified by Language, then a pointer to the driver name is
51 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
52 by This does not support the language specified by Language,
53 then EFI_UNSUPPORTED is returned.
55 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
56 EFI_COMPONENT_NAME_PROTOCOL instance.
58 @param Language[in] A pointer to a Null-terminated ASCII string
59 array indicating the language. This is the
60 language of the driver name that the caller is
61 requesting, and it must match one of the
62 languages specified in SupportedLanguages. The
63 number of languages supported by a driver is up
64 to the driver writer. Language is specified
65 in RFC 3066 or ISO 639-2 language code format.
67 @param DriverName[out] A pointer to the Unicode string to return.
68 This Unicode string is the name of the
69 driver specified by This in the language
70 specified by Language.
72 @retval EFI_SUCCESS The Unicode string for the Driver specified by
73 This and the language specified by Language was
74 returned in DriverName.
76 @retval EFI_INVALID_PARAMETER Language is NULL.
78 @retval EFI_INVALID_PARAMETER DriverName is NULL.
80 @retval EFI_UNSUPPORTED The driver specified by This does not support
81 the language specified by Language.
86 GraphicsConsoleComponentNameGetDriverName (
87 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
89 OUT CHAR16
**DriverName
94 Retrieves a Unicode string that is the user readable name of the controller
95 that is being managed by a driver.
97 This function retrieves the user readable name of the controller specified by
98 ControllerHandle and ChildHandle in the form of a Unicode string. If the
99 driver specified by This has a user readable name in the language specified by
100 Language, then a pointer to the controller name is returned in ControllerName,
101 and EFI_SUCCESS is returned. If the driver specified by This is not currently
102 managing the controller specified by ControllerHandle and ChildHandle,
103 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
104 support the language specified by Language, then EFI_UNSUPPORTED is returned.
106 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
107 EFI_COMPONENT_NAME_PROTOCOL instance.
109 @param ControllerHandle[in] The handle of a controller that the driver
110 specified by This is managing. This handle
111 specifies the controller whose name is to be
114 @param ChildHandle[in] The handle of the child controller to retrieve
115 the name of. This is an optional parameter that
116 may be NULL. It will be NULL for device
117 drivers. It will also be NULL for a bus drivers
118 that wish to retrieve the name of the bus
119 controller. It will not be NULL for a bus
120 driver that wishes to retrieve the name of a
123 @param Language[in] A pointer to a Null-terminated ASCII string
124 array indicating the language. This is the
125 language of the driver name that the caller is
126 requesting, and it must match one of the
127 languages specified in SupportedLanguages. The
128 number of languages supported by a driver is up
129 to the driver writer. Language is specified in
130 RFC 3066 or ISO 639-2 language code format.
132 @param ControllerName[out] A pointer to the Unicode string to return.
133 This Unicode string is the name of the
134 controller specified by ControllerHandle and
135 ChildHandle in the language specified by
136 Language from the point of view of the driver
139 @retval EFI_SUCCESS The Unicode string for the user readable name in
140 the language specified by Language for the
141 driver specified by This was returned in
144 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
146 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
149 @retval EFI_INVALID_PARAMETER Language is NULL.
151 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
153 @retval EFI_UNSUPPORTED The driver specified by This is not currently
154 managing the controller specified by
155 ControllerHandle and ChildHandle.
157 @retval EFI_UNSUPPORTED The driver specified by This does not support
158 the language specified by Language.
163 GraphicsConsoleComponentNameGetControllerName (
164 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
165 IN EFI_HANDLE ControllerHandle
,
166 IN EFI_HANDLE ChildHandle OPTIONAL
,
168 OUT CHAR16
**ControllerName
173 // User can define valid graphic resolution here
174 // e.g. 640x480, 800x600, 1024x768...
176 #define CURRENT_HORIZONTAL_RESOLUTION 800
177 #define CURRENT_VERTICAL_RESOLUTION 600
180 EFI_NARROW_GLYPH NarrowGlyph
;
181 EFI_WIDE_GLYPH WideGlyph
;
184 extern EFI_NARROW_GLYPH UsStdNarrowGlyphData
[];
185 extern EFI_WIDE_GLYPH UsStdWideGlyphData
[];
190 #define GRAPHICS_CONSOLE_DEV_SIGNATURE EFI_SIGNATURE_32 ('g', 's', 't', 'o')
199 UINT32 GopModeNumber
;
200 } GRAPHICS_CONSOLE_MODE_DATA
;
202 #define GRAPHICS_MAX_MODE 4
206 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
207 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
208 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput
;
209 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode
;
210 GRAPHICS_CONSOLE_MODE_DATA ModeData
[GRAPHICS_MAX_MODE
];
211 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*LineBuffer
;
212 EFI_HII_HANDLE HiiHandle
;
213 } GRAPHICS_CONSOLE_DEV
;
215 #define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \
216 CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)
221 extern EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding
;
225 Returns available Unicode glyphs narrow fonts(8*19 pixels) size.
227 @return Narrow foun size.
231 ReturnNarrowFontSize (
236 Implements SIMPLE_TEXT_OUTPUT.Reset().
237 If ExtendeVerification is TRUE, then perform dependent Graphics Console
238 device reset, and set display mode to mode 0.
239 If ExtendedVerification is FALSE, only set display mode to mode 0.
241 @param This Indicates the calling context.
242 @param ExtendedVerification Indicates that the driver may perform a more
243 exhaustive verification operation of the device
247 @return The reset operation succeeds.
248 @return EFI_DEVICE_ERROR
249 @return The Graphics Console is not functioning correctly
254 GraphicsConsoleConOutReset (
255 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
256 IN BOOLEAN ExtendedVerification
260 Write a Unicode string to the output device.
262 Implements SIMPLE_TEXT_OUTPUT.OutputString().
263 The Unicode string will be converted to Glyphs and will be
264 sent to the Graphics Console.
266 @param This Protocol instance pointer.
267 @param WString The NULL-terminated Unicode string to be displayed
268 on the output device(s). All output devices must
269 also support the Unicode drawing defined in this file.
271 @retval EFI_SUCCESS The string was output to the device.
272 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
274 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
276 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
277 characters in the Unicode string could not be
278 rendered and were skipped.
283 GraphicsConsoleConOutOutputString (
284 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
289 Implements SIMPLE_TEXT_OUTPUT.TestString().
290 If one of the characters in the *Wstring is
291 neither valid valid Unicode drawing characters,
292 not ASCII code, then this function will return
295 @param This Indicates the calling context.
296 @param WString The Null-terminated Unicode string to be tested.
299 @return The Graphics Console is capable of rendering the output string.
300 @return EFI_UNSUPPORTED
301 @return Some of the characters in the Unicode string cannot be rendered.
306 GraphicsConsoleConOutTestString (
307 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
312 Returns information for an available text mode that the output device(s)
315 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
316 It returnes information for an available text mode that the Graphics Console supports.
317 In this driver,we only support text mode 80x25, which is defined as mode 0.
319 @param This Protocol instance pointer.
320 @param ModeNumber The mode number to return information on.
321 @param Columns The returned columns of the requested mode.
322 @param Rows The returned rows of the requested mode.
324 @retval EFI_SUCCESS The requested mode information is returned.
325 @retval EFI_UNSUPPORTED The mode number is not valid.
330 GraphicsConsoleConOutQueryMode (
331 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
339 Sets the output device(s) to a specified mode.
341 Implements SIMPLE_TEXT_OUTPUT.SetMode().
342 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
344 @param This Protocol instance pointer.
345 @param ModeNumber The text mode to set.
347 @retval EFI_SUCCESS The requested text mode is set.
348 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
349 Graphics Console device error.
350 @retval EFI_UNSUPPORTED The text mode number is not valid.
355 GraphicsConsoleConOutSetMode (
356 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
361 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
363 @param This Indicates the calling context.
364 @param Attribute The attribute to set. Only bit0..6 are valid, all
365 other bits are undefined and must be zero.
367 @return EFI_SUCCESS The requested attribute is set.
368 @return EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
369 @return EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.
374 GraphicsConsoleConOutSetAttribute (
375 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
380 Clears the output device(s) display to the currently selected background
383 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
385 @param This Protocol instance pointer.
387 @retval EFI_SUCCESS The operation completed successfully.
388 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
389 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
394 GraphicsConsoleConOutClearScreen (
395 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
399 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
401 @param This Indicates the calling context.
402 @param Column The row to set cursor to.
403 @param Row The column to set cursor to.
406 @return The operation completed successfully.
407 @return EFI_DEVICE_ERROR
408 @return The request fails due to Graphics Console device error.
409 @return EFI_UNSUPPORTED
410 @return The Graphics Console is not in a valid text mode, or the cursor position
411 @return is invalid for current mode.
416 GraphicsConsoleConOutSetCursorPosition (
417 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
424 Makes the cursor visible or invisible.
426 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
428 @param This Protocol instance pointer.
429 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
430 the cursor is set to be invisible.
432 @retval EFI_SUCCESS The operation completed successfully.
437 GraphicsConsoleConOutEnableCursor (
438 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
443 Test to see if Graphics Console could be supported on the ControllerHandle.
445 Graphics Console could be supported if Graphics Output Protocol or UGA Draw
446 Protocol exists on the ControllerHandle. (UGA Draw Protocol could be shipped
447 if PcdUgaConsumeSupport is set to FALSE.)
449 @param This Protocol instance pointer.
450 @param ControllerHandle Handle of device to test.
451 @param RemainingDevicePath Optional parameter use to pick a specific child
454 @retval EFI_SUCCESS This driver supports this device
455 @retval other This driver does not support this device
460 GraphicsConsoleControllerDriverSupported (
461 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
462 IN EFI_HANDLE Controller
,
463 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
467 Start this driver on ControllerHandle by opening Graphics Output protocol or
468 UGA Draw protocol, and installing Simple Text Out protocol on ControllerHandle.
469 (UGA Draw protocol could be shkipped if PcdUgaConsumeSupport is set to FALSE.)
471 @param This Protocol instance pointer.
472 @param ControllerHandle Handle of device to bind driver to
473 @param RemainingDevicePath Optional parameter use to pick a specific child
476 @retval EFI_SUCCESS This driver is added to ControllerHandle
477 @retval other This driver does not support this device
482 GraphicsConsoleControllerDriverStart (
483 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
484 IN EFI_HANDLE Controller
,
485 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
489 Stop this driver on ControllerHandle by removing Simple Text Out protocol
490 and closing the Graphics Output Protocol or UGA Draw protocol on ControllerHandle.
491 (UGA Draw protocol could be shkipped if PcdUgaConsumeSupport is set to FALSE.)
494 @param This Protocol instance pointer.
495 @param ControllerHandle Handle of device to stop driver on
496 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
497 children is zero stop the entire bus driver.
498 @param ChildHandleBuffer List of Child Handles to Stop.
500 @retval EFI_SUCCESS This driver is removed ControllerHandle.
501 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
503 @retval other This driver was not removed from this device.
508 GraphicsConsoleControllerDriverStop (
509 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
510 IN EFI_HANDLE Controller
,
511 IN UINTN NumberOfChildren
,
512 IN EFI_HANDLE
*ChildHandleBuffer
517 Locate HII Database protocol and HII Font protocol.
519 @retval EFI_SUCCESS HII Database protocol and HII Font protocol
520 are located successfully.
521 @return other Failed to locate HII Database protocol or
526 EfiLocateHiiProtocol (