]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h
Check comments, format and fix some typo.
[mirror_edk2.git] / MdeModulePkg / Universal / Console / GraphicsConsoleDxe / GraphicsConsole.h
CommitLineData
fb0b259e 1/** @file\r
2 Header file for GraphicsConsole driver.\r
95276127 3\r
6dcf9abc 4Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
8541adab 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
95276127 12\r
fb0b259e 13**/\r
95276127 14\r
6dcf9abc 15#ifndef _GRAPHICS_CONSOLE_H_\r
16#define _GRAPHICS_CONSOLE_H_\r
95276127 17\r
60c93673 18#include <Uefi.h>\r
97a079ed
A
19#include <Protocol/SimpleTextOut.h>\r
20#include <Protocol/GraphicsOutput.h>\r
21#include <Protocol/UgaDraw.h>\r
22#include <Protocol/DevicePath.h>\r
23#include <Library/DebugLib.h>\r
24#include <Library/UefiDriverEntryPoint.h>\r
25#include <Library/UefiLib.h>\r
97a079ed
A
26#include <Library/BaseMemoryLib.h>\r
27#include <Library/MemoryAllocationLib.h>\r
28#include <Library/UefiBootServicesTableLib.h>\r
93e3992d 29#include <Library/HiiLib.h>\r
30#include <Library/BaseLib.h>\r
8541adab 31#include <Library/PcdLib.h>\r
93e3992d 32\r
33#include <MdeModuleHii.h>\r
34\r
35#include <Protocol/HiiFont.h>\r
36#include <Protocol/HiiDatabase.h>\r
97a079ed
A
37\r
38\r
5bca971e 39extern EFI_COMPONENT_NAME_PROTOCOL gGraphicsConsoleComponentName;\r
40extern EFI_COMPONENT_NAME2_PROTOCOL gGraphicsConsoleComponentName2;\r
878670ea 41extern EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding;\r
42extern EFI_NARROW_GLYPH gUsStdNarrowGlyphData[];\r
43\r
44\r
45//\r
46// User can define valid graphic resolution here\r
47// e.g. 640x480, 800x600, 1024x768...\r
48//\r
49#define CURRENT_HORIZONTAL_RESOLUTION 800\r
50#define CURRENT_VERTICAL_RESOLUTION 600\r
51\r
52typedef union {\r
53 EFI_NARROW_GLYPH NarrowGlyph;\r
54 EFI_WIDE_GLYPH WideGlyph;\r
55} GLYPH_UNION;\r
56\r
57//\r
58// Device Structure\r
59//\r
60#define GRAPHICS_CONSOLE_DEV_SIGNATURE SIGNATURE_32 ('g', 's', 't', 'o')\r
61\r
62typedef struct {\r
63 UINTN Columns;\r
64 UINTN Rows;\r
65 INTN DeltaX;\r
66 INTN DeltaY;\r
67 UINT32 GopWidth;\r
68 UINT32 GopHeight;\r
69 UINT32 GopModeNumber;\r
70} GRAPHICS_CONSOLE_MODE_DATA;\r
71\r
72#define GRAPHICS_MAX_MODE 4\r
73\r
74typedef struct {\r
75 UINTN Signature;\r
76 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
77 EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
78 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;\r
79 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;\r
80 GRAPHICS_CONSOLE_MODE_DATA ModeData[GRAPHICS_MAX_MODE];\r
81 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer;\r
82 EFI_HII_HANDLE HiiHandle;\r
83} GRAPHICS_CONSOLE_DEV;\r
84\r
85#define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \\r
86 CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)\r
87\r
95276127 88\r
89//\r
97a079ed 90// EFI Component Name Functions\r
95276127 91//\r
5bca971e 92/**\r
93 Retrieves a Unicode string that is the user readable name of the driver.\r
94\r
95 This function retrieves the user readable name of a driver in the form of a\r
96 Unicode string. If the driver specified by This has a user readable name in\r
97 the language specified by Language, then a pointer to the driver name is\r
98 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
99 by This does not support the language specified by Language,\r
100 then EFI_UNSUPPORTED is returned.\r
101\r
102 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
103 EFI_COMPONENT_NAME_PROTOCOL instance.\r
104\r
105 @param Language[in] A pointer to a Null-terminated ASCII string\r
106 array indicating the language. This is the\r
107 language of the driver name that the caller is\r
108 requesting, and it must match one of the\r
109 languages specified in SupportedLanguages. The\r
110 number of languages supported by a driver is up\r
111 to the driver writer. Language is specified\r
112 in RFC 3066 or ISO 639-2 language code format.\r
113\r
114 @param DriverName[out] A pointer to the Unicode string to return.\r
115 This Unicode string is the name of the\r
116 driver specified by This in the language\r
117 specified by Language.\r
118\r
119 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
120 This and the language specified by Language was\r
121 returned in DriverName.\r
122\r
123 @retval EFI_INVALID_PARAMETER Language is NULL.\r
124\r
125 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
126\r
127 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
128 the language specified by Language.\r
129\r
130**/\r
97a079ed
A
131EFI_STATUS\r
132EFIAPI\r
133GraphicsConsoleComponentNameGetDriverName (\r
134 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
135 IN CHAR8 *Language,\r
136 OUT CHAR16 **DriverName\r
137 );\r
138\r
5bca971e 139\r
140/**\r
141 Retrieves a Unicode string that is the user readable name of the controller\r
142 that is being managed by a driver.\r
143\r
144 This function retrieves the user readable name of the controller specified by\r
145 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
146 driver specified by This has a user readable name in the language specified by\r
147 Language, then a pointer to the controller name is returned in ControllerName,\r
148 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
149 managing the controller specified by ControllerHandle and ChildHandle,\r
150 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
151 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
152\r
153 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
154 EFI_COMPONENT_NAME_PROTOCOL instance.\r
155\r
156 @param ControllerHandle[in] The handle of a controller that the driver\r
157 specified by This is managing. This handle\r
158 specifies the controller whose name is to be\r
159 returned.\r
160\r
161 @param ChildHandle[in] The handle of the child controller to retrieve\r
162 the name of. This is an optional parameter that\r
163 may be NULL. It will be NULL for device\r
164 drivers. It will also be NULL for a bus drivers\r
165 that wish to retrieve the name of the bus\r
166 controller. It will not be NULL for a bus\r
167 driver that wishes to retrieve the name of a\r
168 child controller.\r
169\r
170 @param Language[in] A pointer to a Null-terminated ASCII string\r
171 array indicating the language. This is the\r
172 language of the driver name that the caller is\r
173 requesting, and it must match one of the\r
174 languages specified in SupportedLanguages. The\r
175 number of languages supported by a driver is up\r
176 to the driver writer. Language is specified in\r
177 RFC 3066 or ISO 639-2 language code format.\r
178\r
179 @param ControllerName[out] A pointer to the Unicode string to return.\r
180 This Unicode string is the name of the\r
181 controller specified by ControllerHandle and\r
182 ChildHandle in the language specified by\r
183 Language from the point of view of the driver\r
184 specified by This.\r
185\r
186 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
187 the language specified by Language for the\r
188 driver specified by This was returned in\r
189 DriverName.\r
190\r
191 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
192\r
193 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
194 EFI_HANDLE.\r
195\r
196 @retval EFI_INVALID_PARAMETER Language is NULL.\r
197\r
198 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
199\r
200 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
201 managing the controller specified by\r
202 ControllerHandle and ChildHandle.\r
203\r
204 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
205 the language specified by Language.\r
206\r
207**/\r
97a079ed
A
208EFI_STATUS\r
209EFIAPI\r
210GraphicsConsoleComponentNameGetControllerName (\r
211 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
212 IN EFI_HANDLE ControllerHandle,\r
213 IN EFI_HANDLE ChildHandle OPTIONAL,\r
214 IN CHAR8 *Language,\r
215 OUT CHAR16 **ControllerName\r
216 );\r
95276127 217\r
5bca971e 218\r
95276127 219\r
24248368 220\r
221/**\r
222 Returns available Unicode glyphs narrow fonts(8*19 pixels) size.\r
223\r
878670ea 224 @return Narrow font size.\r
24248368 225\r
226**/\r
878670ea 227UINT32\r
95276127 228ReturnNarrowFontSize (\r
229 VOID\r
230 );\r
231\r
6dcf9abc 232/**\r
7601dbe7 233 Reset the text output device hardware and optionally run diagnostics.\r
234 \r
6dcf9abc 235 Implements SIMPLE_TEXT_OUTPUT.Reset().\r
236 If ExtendeVerification is TRUE, then perform dependent Graphics Console\r
237 device reset, and set display mode to mode 0.\r
238 If ExtendedVerification is FALSE, only set display mode to mode 0.\r
239\r
7601dbe7 240 @param This Protocol instance pointer.\r
6dcf9abc 241 @param ExtendedVerification Indicates that the driver may perform a more\r
242 exhaustive verification operation of the device\r
243 during reset.\r
244\r
7601dbe7 245 @retval EFI_SUCCESS The text output device was reset.\r
246 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and\r
247 could not be reset.\r
95276127 248\r
6dcf9abc 249**/\r
95276127 250EFI_STATUS\r
251EFIAPI\r
252GraphicsConsoleConOutReset (\r
253 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
254 IN BOOLEAN ExtendedVerification\r
255 );\r
256\r
6dcf9abc 257/**\r
24248368 258 Write a Unicode string to the output device.\r
259\r
260 Implements SIMPLE_TEXT_OUTPUT.OutputString(). \r
6dcf9abc 261 The Unicode string will be converted to Glyphs and will be\r
262 sent to the Graphics Console.\r
263\r
24248368 264 @param This Protocol instance pointer.\r
265 @param WString The NULL-terminated Unicode string to be displayed\r
266 on the output device(s). All output devices must\r
267 also support the Unicode drawing defined in this file.\r
6dcf9abc 268\r
24248368 269 @retval EFI_SUCCESS The string was output to the device.\r
270 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output\r
271 the text.\r
272 @retval EFI_UNSUPPORTED The output device's mode is not currently in a\r
273 defined text mode.\r
274 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the\r
275 characters in the Unicode string could not be\r
276 rendered and were skipped.\r
6dcf9abc 277\r
278**/\r
95276127 279EFI_STATUS\r
280EFIAPI\r
281GraphicsConsoleConOutOutputString (\r
282 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
283 IN CHAR16 *WString\r
284 );\r
285\r
6dcf9abc 286/**\r
287 Implements SIMPLE_TEXT_OUTPUT.TestString().\r
288 If one of the characters in the *Wstring is\r
289 neither valid valid Unicode drawing characters,\r
290 not ASCII code, then this function will return\r
291 EFI_UNSUPPORTED.\r
292\r
293 @param This Indicates the calling context.\r
294 @param WString The Null-terminated Unicode string to be tested.\r
295\r
296 @return EFI_SUCCESS\r
297 @return The Graphics Console is capable of rendering the output string.\r
298 @return EFI_UNSUPPORTED\r
299 @return Some of the characters in the Unicode string cannot be rendered.\r
300\r
301**/\r
95276127 302EFI_STATUS\r
303EFIAPI\r
304GraphicsConsoleConOutTestString (\r
305 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
306 IN CHAR16 *WString\r
307 );\r
308\r
6dcf9abc 309/**\r
24248368 310 Returns information for an available text mode that the output device(s)\r
311 supports\r
312\r
6dcf9abc 313 Implements SIMPLE_TEXT_OUTPUT.QueryMode().\r
24248368 314 It returnes information for an available text mode that the Graphics Console supports.\r
315 In this driver,we only support text mode 80x25, which is defined as mode 0.\r
6dcf9abc 316\r
24248368 317 @param This Protocol instance pointer.\r
6dcf9abc 318 @param ModeNumber The mode number to return information on.\r
319 @param Columns The returned columns of the requested mode.\r
320 @param Rows The returned rows of the requested mode.\r
321\r
24248368 322 @retval EFI_SUCCESS The requested mode information is returned.\r
323 @retval EFI_UNSUPPORTED The mode number is not valid.\r
6dcf9abc 324\r
325**/\r
95276127 326EFI_STATUS\r
327EFIAPI\r
328GraphicsConsoleConOutQueryMode (\r
329 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
330 IN UINTN ModeNumber,\r
331 OUT UINTN *Columns,\r
332 OUT UINTN *Rows\r
333 );\r
334\r
24248368 335\r
6dcf9abc 336/**\r
24248368 337 Sets the output device(s) to a specified mode.\r
338 \r
6dcf9abc 339 Implements SIMPLE_TEXT_OUTPUT.SetMode().\r
24248368 340 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.\r
6dcf9abc 341\r
24248368 342 @param This Protocol instance pointer.\r
6dcf9abc 343 @param ModeNumber The text mode to set.\r
344\r
24248368 345 @retval EFI_SUCCESS The requested text mode is set.\r
346 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of \r
347 Graphics Console device error.\r
348 @retval EFI_UNSUPPORTED The text mode number is not valid.\r
6dcf9abc 349\r
350**/\r
95276127 351EFI_STATUS\r
352EFIAPI\r
353GraphicsConsoleConOutSetMode (\r
354 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
355 IN UINTN ModeNumber\r
356 );\r
357\r
6dcf9abc 358/**\r
359 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().\r
360\r
361 @param This Indicates the calling context.\r
362 @param Attribute The attribute to set. Only bit0..6 are valid, all\r
363 other bits are undefined and must be zero.\r
364\r
365 @return EFI_SUCCESS The requested attribute is set.\r
366 @return EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.\r
367 @return EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.\r
368\r
369**/\r
95276127 370EFI_STATUS\r
371EFIAPI\r
372GraphicsConsoleConOutSetAttribute (\r
373 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
374 IN UINTN Attribute\r
375 );\r
376\r
6dcf9abc 377/**\r
24248368 378 Clears the output device(s) display to the currently selected background \r
379 color.\r
380\r
6dcf9abc 381 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().\r
6dcf9abc 382\r
24248368 383 @param This Protocol instance pointer.\r
6dcf9abc 384\r
24248368 385 @retval EFI_SUCCESS The operation completed successfully.\r
386 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r
387 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.\r
6dcf9abc 388\r
389**/\r
95276127 390EFI_STATUS\r
391EFIAPI\r
392GraphicsConsoleConOutClearScreen (\r
393 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
394 );\r
395\r
6dcf9abc 396/**\r
397 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().\r
398\r
399 @param This Indicates the calling context.\r
400 @param Column The row to set cursor to.\r
401 @param Row The column to set cursor to.\r
402\r
403 @return EFI_SUCCESS\r
404 @return The operation completed successfully.\r
405 @return EFI_DEVICE_ERROR\r
406 @return The request fails due to Graphics Console device error.\r
407 @return EFI_UNSUPPORTED\r
408 @return The Graphics Console is not in a valid text mode, or the cursor position\r
409 @return is invalid for current mode.\r
410\r
411**/\r
95276127 412EFI_STATUS\r
413EFIAPI\r
414GraphicsConsoleConOutSetCursorPosition (\r
415 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
416 IN UINTN Column,\r
417 IN UINTN Row\r
418 );\r
419\r
24248368 420\r
6dcf9abc 421/**\r
24248368 422 Makes the cursor visible or invisible.\r
423\r
6dcf9abc 424 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().\r
6dcf9abc 425\r
24248368 426 @param This Protocol instance pointer.\r
6dcf9abc 427 @param Visible If TRUE, the cursor is set to be visible, If FALSE,\r
428 the cursor is set to be invisible.\r
429\r
24248368 430 @retval EFI_SUCCESS The operation completed successfully.\r
6dcf9abc 431\r
432**/\r
95276127 433EFI_STATUS\r
434EFIAPI\r
435GraphicsConsoleConOutEnableCursor (\r
436 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
437 IN BOOLEAN Visible\r
438 );\r
439\r
24248368 440/**\r
8595bdaf 441 Test to see if Graphics Console could be supported on the Controller.\r
24248368 442\r
443 Graphics Console could be supported if Graphics Output Protocol or UGA Draw\r
8595bdaf 444 Protocol exists on the Controller. (UGA Draw Protocol could be skipped\r
24248368 445 if PcdUgaConsumeSupport is set to FALSE.)\r
446\r
447 @param This Protocol instance pointer.\r
8595bdaf 448 @param Controller Handle of device to test.\r
24248368 449 @param RemainingDevicePath Optional parameter use to pick a specific child\r
450 device to start.\r
451\r
8595bdaf 452 @retval EFI_SUCCESS This driver supports this device.\r
453 @retval other This driver does not support this device.\r
24248368 454\r
455**/\r
95276127 456EFI_STATUS\r
457EFIAPI\r
458GraphicsConsoleControllerDriverSupported (\r
459 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
460 IN EFI_HANDLE Controller,\r
461 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
462 );\r
463\r
8595bdaf 464\r
24248368 465/**\r
8595bdaf 466 Start this driver on Controller by opening Graphics Output protocol or \r
467 UGA Draw protocol, and installing Simple Text Out protocol on Controller.\r
878670ea 468 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)\r
24248368 469 \r
470 @param This Protocol instance pointer.\r
8595bdaf 471 @param Controller Handle of device to bind driver to\r
24248368 472 @param RemainingDevicePath Optional parameter use to pick a specific child\r
473 device to start.\r
474\r
8595bdaf 475 @retval EFI_SUCCESS This driver is added to Controller.\r
476 @retval other This driver does not support this device.\r
24248368 477\r
478**/\r
95276127 479EFI_STATUS\r
480EFIAPI\r
481GraphicsConsoleControllerDriverStart (\r
482 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
483 IN EFI_HANDLE Controller,\r
484 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
485 );\r
486\r
24248368 487/**\r
8595bdaf 488 Stop this driver on Controller by removing Simple Text Out protocol \r
489 and closing the Graphics Output Protocol or UGA Draw protocol on Controller.\r
878670ea 490 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)\r
24248368 491 \r
492\r
493 @param This Protocol instance pointer.\r
8595bdaf 494 @param Controller Handle of device to stop driver on\r
24248368 495 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
496 children is zero stop the entire bus driver.\r
497 @param ChildHandleBuffer List of Child Handles to Stop.\r
498\r
8595bdaf 499 @retval EFI_SUCCESS This driver is removed Controller.\r
24248368 500 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the \r
8595bdaf 501 Controller.\r
24248368 502 @retval other This driver was not removed from this device.\r
503\r
504**/\r
95276127 505EFI_STATUS\r
506EFIAPI\r
507GraphicsConsoleControllerDriverStop (\r
508 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
509 IN EFI_HANDLE Controller,\r
510 IN UINTN NumberOfChildren,\r
511 IN EFI_HANDLE *ChildHandleBuffer\r
512 );\r
513\r
6dcf9abc 514\r
24248368 515/**\r
516 Locate HII Database protocol and HII Font protocol.\r
517\r
518 @retval EFI_SUCCESS HII Database protocol and HII Font protocol \r
519 are located successfully.\r
520 @return other Failed to locate HII Database protocol or \r
521 HII Font protocol.\r
522\r
523**/\r
93e3992d 524EFI_STATUS\r
525EfiLocateHiiProtocol (\r
526 VOID\r
ed66e1bc 527 );\r
93e3992d 528\r
529\r
95276127 530#endif\r