]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h
Remove hard code video resolution in C code and use PCD PcdVideoHorizontalResolution...
[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 typedef union {
47 EFI_NARROW_GLYPH NarrowGlyph;
48 EFI_WIDE_GLYPH WideGlyph;
49 } GLYPH_UNION;
50
51 //
52 // Device Structure
53 //
54 #define GRAPHICS_CONSOLE_DEV_SIGNATURE SIGNATURE_32 ('g', 's', 't', 'o')
55
56 typedef struct {
57 UINTN Columns;
58 UINTN Rows;
59 INTN DeltaX;
60 INTN DeltaY;
61 UINT32 GopWidth;
62 UINT32 GopHeight;
63 UINT32 GopModeNumber;
64 } GRAPHICS_CONSOLE_MODE_DATA;
65
66 #define GRAPHICS_MAX_MODE 5
67
68 typedef struct {
69 UINTN Signature;
70 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
71 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
72 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
73 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
74 GRAPHICS_CONSOLE_MODE_DATA ModeData[GRAPHICS_MAX_MODE];
75 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer;
76 } GRAPHICS_CONSOLE_DEV;
77
78 #define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \
79 CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)
80
81
82 //
83 // EFI Component Name Functions
84 //
85 /**
86 Retrieves a Unicode string that is the user readable name of the driver.
87
88 This function retrieves the user readable name of a driver in the form of a
89 Unicode string. If the driver specified by This has a user readable name in
90 the language specified by Language, then a pointer to the driver name is
91 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
92 by This does not support the language specified by Language,
93 then EFI_UNSUPPORTED is returned.
94
95 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
96 EFI_COMPONENT_NAME_PROTOCOL instance.
97
98 @param Language[in] A pointer to a Null-terminated ASCII string
99 array indicating the language. This is the
100 language of the driver name that the caller is
101 requesting, and it must match one of the
102 languages specified in SupportedLanguages. The
103 number of languages supported by a driver is up
104 to the driver writer. Language is specified
105 in RFC 4646 or ISO 639-2 language code format.
106
107 @param DriverName[out] A pointer to the Unicode string to return.
108 This Unicode string is the name of the
109 driver specified by This in the language
110 specified by Language.
111
112 @retval EFI_SUCCESS The Unicode string for the Driver specified by
113 This and the language specified by Language was
114 returned in DriverName.
115
116 @retval EFI_INVALID_PARAMETER Language is NULL.
117
118 @retval EFI_INVALID_PARAMETER DriverName is NULL.
119
120 @retval EFI_UNSUPPORTED The driver specified by This does not support
121 the language specified by Language.
122
123 **/
124 EFI_STATUS
125 EFIAPI
126 GraphicsConsoleComponentNameGetDriverName (
127 IN EFI_COMPONENT_NAME_PROTOCOL *This,
128 IN CHAR8 *Language,
129 OUT CHAR16 **DriverName
130 );
131
132
133 /**
134 Retrieves a Unicode string that is the user readable name of the controller
135 that is being managed by a driver.
136
137 This function retrieves the user readable name of the controller specified by
138 ControllerHandle and ChildHandle in the form of a Unicode string. If the
139 driver specified by This has a user readable name in the language specified by
140 Language, then a pointer to the controller name is returned in ControllerName,
141 and EFI_SUCCESS is returned. If the driver specified by This is not currently
142 managing the controller specified by ControllerHandle and ChildHandle,
143 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
144 support the language specified by Language, then EFI_UNSUPPORTED is returned.
145
146 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
147 EFI_COMPONENT_NAME_PROTOCOL instance.
148
149 @param ControllerHandle[in] The handle of a controller that the driver
150 specified by This is managing. This handle
151 specifies the controller whose name is to be
152 returned.
153
154 @param ChildHandle[in] The handle of the child controller to retrieve
155 the name of. This is an optional parameter that
156 may be NULL. It will be NULL for device
157 drivers. It will also be NULL for a bus drivers
158 that wish to retrieve the name of the bus
159 controller. It will not be NULL for a bus
160 driver that wishes to retrieve the name of a
161 child controller.
162
163 @param Language[in] A pointer to a Null-terminated ASCII string
164 array indicating the language. This is the
165 language of the driver name that the caller is
166 requesting, and it must match one of the
167 languages specified in SupportedLanguages. The
168 number of languages supported by a driver is up
169 to the driver writer. Language is specified in
170 RFC 4646 or ISO 639-2 language code format.
171
172 @param ControllerName[out] A pointer to the Unicode string to return.
173 This Unicode string is the name of the
174 controller specified by ControllerHandle and
175 ChildHandle in the language specified by
176 Language from the point of view of the driver
177 specified by This.
178
179 @retval EFI_SUCCESS The Unicode string for the user readable name in
180 the language specified by Language for the
181 driver specified by This was returned in
182 DriverName.
183
184 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
185
186 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
187 EFI_HANDLE.
188
189 @retval EFI_INVALID_PARAMETER Language is NULL.
190
191 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
192
193 @retval EFI_UNSUPPORTED The driver specified by This is not currently
194 managing the controller specified by
195 ControllerHandle and ChildHandle.
196
197 @retval EFI_UNSUPPORTED The driver specified by This does not support
198 the language specified by Language.
199
200 **/
201 EFI_STATUS
202 EFIAPI
203 GraphicsConsoleComponentNameGetControllerName (
204 IN EFI_COMPONENT_NAME_PROTOCOL *This,
205 IN EFI_HANDLE ControllerHandle,
206 IN EFI_HANDLE ChildHandle OPTIONAL,
207 IN CHAR8 *Language,
208 OUT CHAR16 **ControllerName
209 );
210
211
212 /**
213 Reset the text output device hardware and optionally run diagnostics.
214
215 Implements SIMPLE_TEXT_OUTPUT.Reset().
216 If ExtendeVerification is TRUE, then perform dependent Graphics Console
217 device reset, and set display mode to mode 0.
218 If ExtendedVerification is FALSE, only set display mode to mode 0.
219
220 @param This Protocol instance pointer.
221 @param ExtendedVerification Indicates that the driver may perform a more
222 exhaustive verification operation of the device
223 during reset.
224
225 @retval EFI_SUCCESS The text output device was reset.
226 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
227 could not be reset.
228
229 **/
230 EFI_STATUS
231 EFIAPI
232 GraphicsConsoleConOutReset (
233 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
234 IN BOOLEAN ExtendedVerification
235 );
236
237 /**
238 Write a Unicode string to the output device.
239
240 Implements SIMPLE_TEXT_OUTPUT.OutputString().
241 The Unicode string will be converted to Glyphs and will be
242 sent to the Graphics Console.
243
244 @param This Protocol instance pointer.
245 @param WString The NULL-terminated Unicode string to be displayed
246 on the output device(s). All output devices must
247 also support the Unicode drawing defined in this file.
248
249 @retval EFI_SUCCESS The string was output to the device.
250 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
251 the text.
252 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
253 defined text mode.
254 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
255 characters in the Unicode string could not be
256 rendered and were skipped.
257
258 **/
259 EFI_STATUS
260 EFIAPI
261 GraphicsConsoleConOutOutputString (
262 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
263 IN CHAR16 *WString
264 );
265
266 /**
267 Verifies that all characters in a Unicode string can be output to the
268 target device.
269
270 Implements SIMPLE_TEXT_OUTPUT.TestString().
271 If one of the characters in the *Wstring is neither valid valid Unicode
272 drawing characters, not ASCII code, then this function will return
273 EFI_UNSUPPORTED
274
275 @param This Protocol instance pointer.
276 @param WString The NULL-terminated Unicode string to be examined for the output
277 device(s).
278
279 @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
280 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be
281 rendered by one or more of the output devices mapped
282 by the EFI handle.
283
284 **/
285 EFI_STATUS
286 EFIAPI
287 GraphicsConsoleConOutTestString (
288 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
289 IN CHAR16 *WString
290 );
291
292 /**
293 Returns information for an available text mode that the output device(s)
294 supports
295
296 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
297 It returnes information for an available text mode that the Graphics Console supports.
298 In this driver,we only support text mode 80x25, which is defined as mode 0.
299
300 @param This Protocol instance pointer.
301 @param ModeNumber The mode number to return information on.
302 @param Columns The returned columns of the requested mode.
303 @param Rows The returned rows of the requested mode.
304
305 @retval EFI_SUCCESS The requested mode information is returned.
306 @retval EFI_UNSUPPORTED The mode number is not valid.
307
308 **/
309 EFI_STATUS
310 EFIAPI
311 GraphicsConsoleConOutQueryMode (
312 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
313 IN UINTN ModeNumber,
314 OUT UINTN *Columns,
315 OUT UINTN *Rows
316 );
317
318
319 /**
320 Sets the output device(s) to a specified mode.
321
322 Implements SIMPLE_TEXT_OUTPUT.SetMode().
323 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
324
325 @param This Protocol instance pointer.
326 @param ModeNumber The text mode to set.
327
328 @retval EFI_SUCCESS The requested text mode is set.
329 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
330 Graphics Console device error.
331 @retval EFI_UNSUPPORTED The text mode number is not valid.
332
333 **/
334 EFI_STATUS
335 EFIAPI
336 GraphicsConsoleConOutSetMode (
337 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
338 IN UINTN ModeNumber
339 );
340
341 /**
342 Sets the background and foreground colors for the OutputString () and
343 ClearScreen () functions.
344
345 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
346
347 @param This Protocol instance pointer.
348 @param Attribute The attribute to set. Bits 0..3 are the foreground
349 color, and bits 4..6 are the background color.
350 All other bits are undefined and must be zero.
351
352 @retval EFI_SUCCESS The requested attribute is set.
353 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
354 @retval EFI_UNSUPPORTED The attribute requested is not defined.
355
356 **/
357 EFI_STATUS
358 EFIAPI
359 GraphicsConsoleConOutSetAttribute (
360 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
361 IN UINTN Attribute
362 );
363
364 /**
365 Clears the output device(s) display to the currently selected background
366 color.
367
368 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
369
370 @param This Protocol instance pointer.
371
372 @retval EFI_SUCCESS The operation completed successfully.
373 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
374 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
375
376 **/
377 EFI_STATUS
378 EFIAPI
379 GraphicsConsoleConOutClearScreen (
380 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
381 );
382
383 /**
384 Sets the current coordinates of the cursor position.
385
386 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
387
388 @param This Protocol instance pointer.
389 @param Column The position to set the cursor to. Must be greater than or
390 equal to zero and less than the number of columns and rows
391 by QueryMode ().
392 @param Row The position to set the cursor to. Must be greater than or
393 equal to zero and less than the number of columns and rows
394 by QueryMode ().
395
396 @retval EFI_SUCCESS The operation completed successfully.
397 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
398 @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
399 cursor position is invalid for the current mode.
400
401 **/
402 EFI_STATUS
403 EFIAPI
404 GraphicsConsoleConOutSetCursorPosition (
405 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
406 IN UINTN Column,
407 IN UINTN Row
408 );
409
410
411 /**
412 Makes the cursor visible or invisible.
413
414 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
415
416 @param This Protocol instance pointer.
417 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
418 the cursor is set to be invisible.
419
420 @retval EFI_SUCCESS The operation completed successfully.
421
422 **/
423 EFI_STATUS
424 EFIAPI
425 GraphicsConsoleConOutEnableCursor (
426 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
427 IN BOOLEAN Visible
428 );
429
430 /**
431 Test to see if Graphics Console could be supported on the Controller.
432
433 Graphics Console could be supported if Graphics Output Protocol or UGA Draw
434 Protocol exists on the Controller. (UGA Draw Protocol could be skipped
435 if PcdUgaConsumeSupport is set to FALSE.)
436
437 @param This Protocol instance pointer.
438 @param Controller Handle of device to test.
439 @param RemainingDevicePath Optional parameter use to pick a specific child
440 device to start.
441
442 @retval EFI_SUCCESS This driver supports this device.
443 @retval other This driver does not support this device.
444
445 **/
446 EFI_STATUS
447 EFIAPI
448 GraphicsConsoleControllerDriverSupported (
449 IN EFI_DRIVER_BINDING_PROTOCOL *This,
450 IN EFI_HANDLE Controller,
451 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
452 );
453
454
455 /**
456 Start this driver on Controller by opening Graphics Output protocol or
457 UGA Draw protocol, and installing Simple Text Out protocol on Controller.
458 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
459
460 @param This Protocol instance pointer.
461 @param Controller Handle of device to bind driver to
462 @param RemainingDevicePath Optional parameter use to pick a specific child
463 device to start.
464
465 @retval EFI_SUCCESS This driver is added to Controller.
466 @retval other This driver does not support this device.
467
468 **/
469 EFI_STATUS
470 EFIAPI
471 GraphicsConsoleControllerDriverStart (
472 IN EFI_DRIVER_BINDING_PROTOCOL *This,
473 IN EFI_HANDLE Controller,
474 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
475 );
476
477 /**
478 Stop this driver on Controller by removing Simple Text Out protocol
479 and closing the Graphics Output Protocol or UGA Draw protocol on Controller.
480 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
481
482
483 @param This Protocol instance pointer.
484 @param Controller Handle of device to stop driver on
485 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
486 children is zero stop the entire bus driver.
487 @param ChildHandleBuffer List of Child Handles to Stop.
488
489 @retval EFI_SUCCESS This driver is removed Controller.
490 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
491 Controller.
492 @retval other This driver was not removed from this device.
493
494 **/
495 EFI_STATUS
496 EFIAPI
497 GraphicsConsoleControllerDriverStop (
498 IN EFI_DRIVER_BINDING_PROTOCOL *This,
499 IN EFI_HANDLE Controller,
500 IN UINTN NumberOfChildren,
501 IN EFI_HANDLE *ChildHandleBuffer
502 );
503
504
505 /**
506 Locate HII Database protocol and HII Font protocol.
507
508 @retval EFI_SUCCESS HII Database protocol and HII Font protocol
509 are located successfully.
510 @return other Failed to locate HII Database protocol or
511 HII Font protocol.
512
513 **/
514 EFI_STATUS
515 EfiLocateHiiProtocol (
516 VOID
517 );
518
519
520 /**
521 Gets Graphics Console devcie's foreground color and background color.
522
523 @param This Protocol instance pointer.
524 @param Foreground Returned text foreground color.
525 @param Background Returned text background color.
526
527 @retval EFI_SUCCESS It returned always.
528
529 **/
530 EFI_STATUS
531 GetTextColors (
532 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
533 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
534 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background
535 );
536
537 /**
538 Draw Unicode string on the Graphics Console device's screen.
539
540 @param This Protocol instance pointer.
541 @param UnicodeWeight One Unicode string to be displayed.
542 @param Count The count of Unicode string.
543
544 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
545 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
546 protocol exist.
547 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
548
549 **/
550 EFI_STATUS
551 DrawUnicodeWeightAtCursorN (
552 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
553 IN CHAR16 *UnicodeWeight,
554 IN UINTN Count
555 );
556
557 /**
558 Flush the cursor on the screen.
559
560 If CursorVisible is FALSE, nothing to do and return directly.
561 If CursorVisible is TRUE,
562 i) If the cursor shows on screen, it will be erased.
563 ii) If the cursor does not show on screen, it will be shown.
564
565 @param This Protocol instance pointer.
566
567 @retval EFI_SUCCESS The cursor is erased successfully.
568
569 **/
570 EFI_STATUS
571 FlushCursor (
572 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
573 );
574
575 /**
576 Check if the current specific mode supported the user defined resolution
577 for the Graphics Console device based on Graphics Output Protocol.
578
579 If yes, set the graphic device's current mode to this specific mode.
580
581 @param GraphicsOutput Graphics Output Protocol instance pointer.
582 @param HorizontalResolution User defined horizontal resolution
583 @param VerticalResolution User defined vertical resolution.
584 @param CurrentModeNumber Current specific mode to be check.
585
586 @retval EFI_SUCCESS The mode is supported.
587 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
588 device supported.
589 @retval other The specific mode does not support user defined
590 resolution or failed to set the current mode to the
591 specific mode on graphics device.
592
593 **/
594 EFI_STATUS
595 CheckModeSupported (
596 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
597 IN UINT32 HorizontalResolution,
598 IN UINT32 VerticalResolution,
599 OUT UINT32 *CurrentModeNumber
600 );
601
602 #endif