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