]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h
Fix the comments to follow UEFI Spec regarding how to check an EFI_HANDLE is valid...
[mirror_edk2.git] / MdeModulePkg / Universal / Console / GraphicsConsoleDxe / GraphicsConsole.h
1 /** @file
2 Header file for GraphicsConsole driver.
3
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
9
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.
12
13 **/
14
15 #ifndef _GRAPHICS_CONSOLE_H_
16 #define _GRAPHICS_CONSOLE_H_
17
18 #include <Uefi.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>
32
33 #include <Guid/MdeModuleHii.h>
34
35 #include <Protocol/HiiFont.h>
36 #include <Protocol/HiiDatabase.h>
37
38
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[];
43
44 extern UINT32 mNarrowFontSize;
45 //
46 // User can define valid graphic resolution here
47 // e.g. 640x480, 800x600, 1024x768...
48 //
49 #define CURRENT_HORIZONTAL_RESOLUTION 800
50 #define CURRENT_VERTICAL_RESOLUTION 600
51
52 typedef union {
53 EFI_NARROW_GLYPH NarrowGlyph;
54 EFI_WIDE_GLYPH WideGlyph;
55 } GLYPH_UNION;
56
57 //
58 // Device Structure
59 //
60 #define GRAPHICS_CONSOLE_DEV_SIGNATURE SIGNATURE_32 ('g', 's', 't', 'o')
61
62 typedef struct {
63 UINTN Columns;
64 UINTN Rows;
65 INTN DeltaX;
66 INTN DeltaY;
67 UINT32 GopWidth;
68 UINT32 GopHeight;
69 UINT32 GopModeNumber;
70 } GRAPHICS_CONSOLE_MODE_DATA;
71
72 #define GRAPHICS_MAX_MODE 5
73
74 typedef struct {
75 UINTN Signature;
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;
83
84 #define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \
85 CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)
86
87
88 //
89 // EFI Component Name Functions
90 //
91 /**
92 Retrieves a Unicode string that is the user readable name of the driver.
93
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.
100
101 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
102 EFI_COMPONENT_NAME_PROTOCOL instance.
103
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.
112
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.
117
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.
121
122 @retval EFI_INVALID_PARAMETER Language is NULL.
123
124 @retval EFI_INVALID_PARAMETER DriverName is NULL.
125
126 @retval EFI_UNSUPPORTED The driver specified by This does not support
127 the language specified by Language.
128
129 **/
130 EFI_STATUS
131 EFIAPI
132 GraphicsConsoleComponentNameGetDriverName (
133 IN EFI_COMPONENT_NAME_PROTOCOL *This,
134 IN CHAR8 *Language,
135 OUT CHAR16 **DriverName
136 );
137
138
139 /**
140 Retrieves a Unicode string that is the user readable name of the controller
141 that is being managed by a driver.
142
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.
151
152 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
153 EFI_COMPONENT_NAME_PROTOCOL instance.
154
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
158 returned.
159
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
167 child controller.
168
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.
177
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
183 specified by This.
184
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
188 DriverName.
189
190 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
191
192 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
193 EFI_HANDLE.
194
195 @retval EFI_INVALID_PARAMETER Language is NULL.
196
197 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
198
199 @retval EFI_UNSUPPORTED The driver specified by This is not currently
200 managing the controller specified by
201 ControllerHandle and ChildHandle.
202
203 @retval EFI_UNSUPPORTED The driver specified by This does not support
204 the language specified by Language.
205
206 **/
207 EFI_STATUS
208 EFIAPI
209 GraphicsConsoleComponentNameGetControllerName (
210 IN EFI_COMPONENT_NAME_PROTOCOL *This,
211 IN EFI_HANDLE ControllerHandle,
212 IN EFI_HANDLE ChildHandle OPTIONAL,
213 IN CHAR8 *Language,
214 OUT CHAR16 **ControllerName
215 );
216
217
218 /**
219 Reset the text output device hardware and optionally run diagnostics.
220
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.
225
226 @param This Protocol instance pointer.
227 @param ExtendedVerification Indicates that the driver may perform a more
228 exhaustive verification operation of the device
229 during reset.
230
231 @retval EFI_SUCCESS The text output device was reset.
232 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
233 could not be reset.
234
235 **/
236 EFI_STATUS
237 EFIAPI
238 GraphicsConsoleConOutReset (
239 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
240 IN BOOLEAN ExtendedVerification
241 );
242
243 /**
244 Write a Unicode string to the output device.
245
246 Implements SIMPLE_TEXT_OUTPUT.OutputString().
247 The Unicode string will be converted to Glyphs and will be
248 sent to the Graphics Console.
249
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.
254
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
257 the text.
258 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
259 defined text mode.
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.
263
264 **/
265 EFI_STATUS
266 EFIAPI
267 GraphicsConsoleConOutOutputString (
268 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
269 IN CHAR16 *WString
270 );
271
272 /**
273 Verifies that all characters in a Unicode string can be output to the
274 target device.
275
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
279 EFI_UNSUPPORTED
280
281 @param This Protocol instance pointer.
282 @param WString The NULL-terminated Unicode string to be examined for the output
283 device(s).
284
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
288 by the EFI handle.
289
290 **/
291 EFI_STATUS
292 EFIAPI
293 GraphicsConsoleConOutTestString (
294 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
295 IN CHAR16 *WString
296 );
297
298 /**
299 Returns information for an available text mode that the output device(s)
300 supports
301
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.
305
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.
310
311 @retval EFI_SUCCESS The requested mode information is returned.
312 @retval EFI_UNSUPPORTED The mode number is not valid.
313
314 **/
315 EFI_STATUS
316 EFIAPI
317 GraphicsConsoleConOutQueryMode (
318 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
319 IN UINTN ModeNumber,
320 OUT UINTN *Columns,
321 OUT UINTN *Rows
322 );
323
324
325 /**
326 Sets the output device(s) to a specified mode.
327
328 Implements SIMPLE_TEXT_OUTPUT.SetMode().
329 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
330
331 @param This Protocol instance pointer.
332 @param ModeNumber The text mode to set.
333
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.
338
339 **/
340 EFI_STATUS
341 EFIAPI
342 GraphicsConsoleConOutSetMode (
343 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
344 IN UINTN ModeNumber
345 );
346
347 /**
348 Sets the background and foreground colors for the OutputString () and
349 ClearScreen () functions.
350
351 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
352
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.
357
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.
361
362 **/
363 EFI_STATUS
364 EFIAPI
365 GraphicsConsoleConOutSetAttribute (
366 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
367 IN UINTN Attribute
368 );
369
370 /**
371 Clears the output device(s) display to the currently selected background
372 color.
373
374 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
375
376 @param This Protocol instance pointer.
377
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.
381
382 **/
383 EFI_STATUS
384 EFIAPI
385 GraphicsConsoleConOutClearScreen (
386 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
387 );
388
389 /**
390 Sets the current coordinates of the cursor position.
391
392 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
393
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
397 by QueryMode ().
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
400 by QueryMode ().
401
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.
406
407 **/
408 EFI_STATUS
409 EFIAPI
410 GraphicsConsoleConOutSetCursorPosition (
411 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
412 IN UINTN Column,
413 IN UINTN Row
414 );
415
416
417 /**
418 Makes the cursor visible or invisible.
419
420 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
421
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.
425
426 @retval EFI_SUCCESS The operation completed successfully.
427
428 **/
429 EFI_STATUS
430 EFIAPI
431 GraphicsConsoleConOutEnableCursor (
432 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
433 IN BOOLEAN Visible
434 );
435
436 /**
437 Test to see if Graphics Console could be supported on the Controller.
438
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.)
442
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
446 device to start.
447
448 @retval EFI_SUCCESS This driver supports this device.
449 @retval other This driver does not support this device.
450
451 **/
452 EFI_STATUS
453 EFIAPI
454 GraphicsConsoleControllerDriverSupported (
455 IN EFI_DRIVER_BINDING_PROTOCOL *This,
456 IN EFI_HANDLE Controller,
457 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
458 );
459
460
461 /**
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.)
465
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
469 device to start.
470
471 @retval EFI_SUCCESS This driver is added to Controller.
472 @retval other This driver does not support this device.
473
474 **/
475 EFI_STATUS
476 EFIAPI
477 GraphicsConsoleControllerDriverStart (
478 IN EFI_DRIVER_BINDING_PROTOCOL *This,
479 IN EFI_HANDLE Controller,
480 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
481 );
482
483 /**
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.)
487
488
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.
494
495 @retval EFI_SUCCESS This driver is removed Controller.
496 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
497 Controller.
498 @retval other This driver was not removed from this device.
499
500 **/
501 EFI_STATUS
502 EFIAPI
503 GraphicsConsoleControllerDriverStop (
504 IN EFI_DRIVER_BINDING_PROTOCOL *This,
505 IN EFI_HANDLE Controller,
506 IN UINTN NumberOfChildren,
507 IN EFI_HANDLE *ChildHandleBuffer
508 );
509
510
511 /**
512 Locate HII Database protocol and HII Font protocol.
513
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
517 HII Font protocol.
518
519 **/
520 EFI_STATUS
521 EfiLocateHiiProtocol (
522 VOID
523 );
524
525
526 /**
527 Gets Graphics Console devcie's foreground color and background color.
528
529 @param This Protocol instance pointer.
530 @param Foreground Returned text foreground color.
531 @param Background Returned text background color.
532
533 @retval EFI_SUCCESS It returned always.
534
535 **/
536 EFI_STATUS
537 GetTextColors (
538 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
539 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
540 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background
541 );
542
543 /**
544 Draw Unicode string on the Graphics Console device's screen.
545
546 @param This Protocol instance pointer.
547 @param UnicodeWeight One Unicode string to be displayed.
548 @param Count The count of Unicode string.
549
550 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
551 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
552 protocol exist.
553 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
554
555 **/
556 EFI_STATUS
557 DrawUnicodeWeightAtCursorN (
558 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
559 IN CHAR16 *UnicodeWeight,
560 IN UINTN Count
561 );
562
563 /**
564 Flush the cursor on the screen.
565
566 If CursorVisible is FALSE, nothing to do and return directly.
567 If CursorVisible is TRUE,
568 i) If the cursor shows on screen, it will be erased.
569 ii) If the cursor does not show on screen, it will be shown.
570
571 @param This Protocol instance pointer.
572
573 @retval EFI_SUCCESS The cursor is erased successfully.
574
575 **/
576 EFI_STATUS
577 FlushCursor (
578 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
579 );
580
581 /**
582 Check if the current specific mode supported the user defined resolution
583 for the Graphics Console device based on Graphics Output Protocol.
584
585 If yes, set the graphic device's current mode to this specific mode.
586
587 @param GraphicsOutput Graphics Output Protocol instance pointer.
588 @param HorizontalResolution User defined horizontal resolution
589 @param VerticalResolution User defined vertical resolution.
590 @param CurrentModeNumber Current specific mode to be check.
591
592 @retval EFI_SUCCESS The mode is supported.
593 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
594 device supported.
595 @retval other The specific mode does not support user defined
596 resolution or failed to set the current mode to the
597 specific mode on graphics device.
598
599 **/
600 EFI_STATUS
601 CheckModeSupported (
602 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
603 IN UINT32 HorizontalResolution,
604 IN UINT32 VerticalResolution,
605 OUT UINT32 *CurrentModeNumber
606 );
607
608 #endif