]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h
1. Use Mde library for Debug Port Module
[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
233 Implements SIMPLE_TEXT_OUTPUT.Reset().\r
234 If ExtendeVerification is TRUE, then perform dependent Graphics Console\r
235 device reset, and set display mode to mode 0.\r
236 If ExtendedVerification is FALSE, only set display mode to mode 0.\r
237\r
238 @param This Indicates the calling context.\r
239 @param ExtendedVerification Indicates that the driver may perform a more\r
240 exhaustive verification operation of the device\r
241 during reset.\r
242\r
243 @return EFI_SUCCESS\r
244 @return The reset operation succeeds.\r
245 @return EFI_DEVICE_ERROR\r
246 @return The Graphics Console is not functioning correctly\r
95276127 247\r
6dcf9abc 248**/\r
95276127 249EFI_STATUS\r
250EFIAPI\r
251GraphicsConsoleConOutReset (\r
252 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
253 IN BOOLEAN ExtendedVerification\r
254 );\r
255\r
6dcf9abc 256/**\r
24248368 257 Write a Unicode string to the output device.\r
258\r
259 Implements SIMPLE_TEXT_OUTPUT.OutputString(). \r
6dcf9abc 260 The Unicode string will be converted to Glyphs and will be\r
261 sent to the Graphics Console.\r
262\r
24248368 263 @param This Protocol instance pointer.\r
264 @param WString The NULL-terminated Unicode string to be displayed\r
265 on the output device(s). All output devices must\r
266 also support the Unicode drawing defined in this file.\r
6dcf9abc 267\r
24248368 268 @retval EFI_SUCCESS The string was output to the device.\r
269 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output\r
270 the text.\r
271 @retval EFI_UNSUPPORTED The output device's mode is not currently in a\r
272 defined text mode.\r
273 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the\r
274 characters in the Unicode string could not be\r
275 rendered and were skipped.\r
6dcf9abc 276\r
277**/\r
95276127 278EFI_STATUS\r
279EFIAPI\r
280GraphicsConsoleConOutOutputString (\r
281 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
282 IN CHAR16 *WString\r
283 );\r
284\r
6dcf9abc 285/**\r
286 Implements SIMPLE_TEXT_OUTPUT.TestString().\r
287 If one of the characters in the *Wstring is\r
288 neither valid valid Unicode drawing characters,\r
289 not ASCII code, then this function will return\r
290 EFI_UNSUPPORTED.\r
291\r
292 @param This Indicates the calling context.\r
293 @param WString The Null-terminated Unicode string to be tested.\r
294\r
295 @return EFI_SUCCESS\r
296 @return The Graphics Console is capable of rendering the output string.\r
297 @return EFI_UNSUPPORTED\r
298 @return Some of the characters in the Unicode string cannot be rendered.\r
299\r
300**/\r
95276127 301EFI_STATUS\r
302EFIAPI\r
303GraphicsConsoleConOutTestString (\r
304 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
305 IN CHAR16 *WString\r
306 );\r
307\r
6dcf9abc 308/**\r
24248368 309 Returns information for an available text mode that the output device(s)\r
310 supports\r
311\r
6dcf9abc 312 Implements SIMPLE_TEXT_OUTPUT.QueryMode().\r
24248368 313 It returnes information for an available text mode that the Graphics Console supports.\r
314 In this driver,we only support text mode 80x25, which is defined as mode 0.\r
6dcf9abc 315\r
24248368 316 @param This Protocol instance pointer.\r
6dcf9abc 317 @param ModeNumber The mode number to return information on.\r
318 @param Columns The returned columns of the requested mode.\r
319 @param Rows The returned rows of the requested mode.\r
320\r
24248368 321 @retval EFI_SUCCESS The requested mode information is returned.\r
322 @retval EFI_UNSUPPORTED The mode number is not valid.\r
6dcf9abc 323\r
324**/\r
95276127 325EFI_STATUS\r
326EFIAPI\r
327GraphicsConsoleConOutQueryMode (\r
328 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
329 IN UINTN ModeNumber,\r
330 OUT UINTN *Columns,\r
331 OUT UINTN *Rows\r
332 );\r
333\r
24248368 334\r
6dcf9abc 335/**\r
24248368 336 Sets the output device(s) to a specified mode.\r
337 \r
6dcf9abc 338 Implements SIMPLE_TEXT_OUTPUT.SetMode().\r
24248368 339 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.\r
6dcf9abc 340\r
24248368 341 @param This Protocol instance pointer.\r
6dcf9abc 342 @param ModeNumber The text mode to set.\r
343\r
24248368 344 @retval EFI_SUCCESS The requested text mode is set.\r
345 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of \r
346 Graphics Console device error.\r
347 @retval EFI_UNSUPPORTED The text mode number is not valid.\r
6dcf9abc 348\r
349**/\r
95276127 350EFI_STATUS\r
351EFIAPI\r
352GraphicsConsoleConOutSetMode (\r
353 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
354 IN UINTN ModeNumber\r
355 );\r
356\r
6dcf9abc 357/**\r
358 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().\r
359\r
360 @param This Indicates the calling context.\r
361 @param Attribute The attribute to set. Only bit0..6 are valid, all\r
362 other bits are undefined and must be zero.\r
363\r
364 @return EFI_SUCCESS The requested attribute is set.\r
365 @return EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.\r
366 @return EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.\r
367\r
368**/\r
95276127 369EFI_STATUS\r
370EFIAPI\r
371GraphicsConsoleConOutSetAttribute (\r
372 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
373 IN UINTN Attribute\r
374 );\r
375\r
6dcf9abc 376/**\r
24248368 377 Clears the output device(s) display to the currently selected background \r
378 color.\r
379\r
6dcf9abc 380 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().\r
6dcf9abc 381\r
24248368 382 @param This Protocol instance pointer.\r
6dcf9abc 383\r
24248368 384 @retval EFI_SUCCESS The operation completed successfully.\r
385 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r
386 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.\r
6dcf9abc 387\r
388**/\r
95276127 389EFI_STATUS\r
390EFIAPI\r
391GraphicsConsoleConOutClearScreen (\r
392 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
393 );\r
394\r
6dcf9abc 395/**\r
396 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().\r
397\r
398 @param This Indicates the calling context.\r
399 @param Column The row to set cursor to.\r
400 @param Row The column to set cursor to.\r
401\r
402 @return EFI_SUCCESS\r
403 @return The operation completed successfully.\r
404 @return EFI_DEVICE_ERROR\r
405 @return The request fails due to Graphics Console device error.\r
406 @return EFI_UNSUPPORTED\r
407 @return The Graphics Console is not in a valid text mode, or the cursor position\r
408 @return is invalid for current mode.\r
409\r
410**/\r
95276127 411EFI_STATUS\r
412EFIAPI\r
413GraphicsConsoleConOutSetCursorPosition (\r
414 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
415 IN UINTN Column,\r
416 IN UINTN Row\r
417 );\r
418\r
24248368 419\r
6dcf9abc 420/**\r
24248368 421 Makes the cursor visible or invisible.\r
422\r
6dcf9abc 423 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().\r
6dcf9abc 424\r
24248368 425 @param This Protocol instance pointer.\r
6dcf9abc 426 @param Visible If TRUE, the cursor is set to be visible, If FALSE,\r
427 the cursor is set to be invisible.\r
428\r
24248368 429 @retval EFI_SUCCESS The operation completed successfully.\r
6dcf9abc 430\r
431**/\r
95276127 432EFI_STATUS\r
433EFIAPI\r
434GraphicsConsoleConOutEnableCursor (\r
435 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
436 IN BOOLEAN Visible\r
437 );\r
438\r
24248368 439/**\r
8595bdaf 440 Test to see if Graphics Console could be supported on the Controller.\r
24248368 441\r
442 Graphics Console could be supported if Graphics Output Protocol or UGA Draw\r
8595bdaf 443 Protocol exists on the Controller. (UGA Draw Protocol could be skipped\r
24248368 444 if PcdUgaConsumeSupport is set to FALSE.)\r
445\r
446 @param This Protocol instance pointer.\r
8595bdaf 447 @param Controller Handle of device to test.\r
24248368 448 @param RemainingDevicePath Optional parameter use to pick a specific child\r
449 device to start.\r
450\r
8595bdaf 451 @retval EFI_SUCCESS This driver supports this device.\r
452 @retval other This driver does not support this device.\r
24248368 453\r
454**/\r
95276127 455EFI_STATUS\r
456EFIAPI\r
457GraphicsConsoleControllerDriverSupported (\r
458 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
459 IN EFI_HANDLE Controller,\r
460 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
461 );\r
462\r
8595bdaf 463\r
24248368 464/**\r
8595bdaf 465 Start this driver on Controller by opening Graphics Output protocol or \r
466 UGA Draw protocol, and installing Simple Text Out protocol on Controller.\r
878670ea 467 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)\r
24248368 468 \r
469 @param This Protocol instance pointer.\r
8595bdaf 470 @param Controller Handle of device to bind driver to\r
24248368 471 @param RemainingDevicePath Optional parameter use to pick a specific child\r
472 device to start.\r
473\r
8595bdaf 474 @retval EFI_SUCCESS This driver is added to Controller.\r
475 @retval other This driver does not support this device.\r
24248368 476\r
477**/\r
95276127 478EFI_STATUS\r
479EFIAPI\r
480GraphicsConsoleControllerDriverStart (\r
481 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
482 IN EFI_HANDLE Controller,\r
483 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
484 );\r
485\r
24248368 486/**\r
8595bdaf 487 Stop this driver on Controller by removing Simple Text Out protocol \r
488 and closing the Graphics Output Protocol or UGA Draw protocol on Controller.\r
878670ea 489 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)\r
24248368 490 \r
491\r
492 @param This Protocol instance pointer.\r
8595bdaf 493 @param Controller Handle of device to stop driver on\r
24248368 494 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
495 children is zero stop the entire bus driver.\r
496 @param ChildHandleBuffer List of Child Handles to Stop.\r
497\r
8595bdaf 498 @retval EFI_SUCCESS This driver is removed Controller.\r
24248368 499 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the \r
8595bdaf 500 Controller.\r
24248368 501 @retval other This driver was not removed from this device.\r
502\r
503**/\r
95276127 504EFI_STATUS\r
505EFIAPI\r
506GraphicsConsoleControllerDriverStop (\r
507 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
508 IN EFI_HANDLE Controller,\r
509 IN UINTN NumberOfChildren,\r
510 IN EFI_HANDLE *ChildHandleBuffer\r
511 );\r
512\r
6dcf9abc 513\r
24248368 514/**\r
515 Locate HII Database protocol and HII Font protocol.\r
516\r
517 @retval EFI_SUCCESS HII Database protocol and HII Font protocol \r
518 are located successfully.\r
519 @return other Failed to locate HII Database protocol or \r
520 HII Font protocol.\r
521\r
522**/\r
93e3992d 523EFI_STATUS\r
524EfiLocateHiiProtocol (\r
525 VOID\r
ed66e1bc 526 );\r
93e3992d 527\r
528\r
95276127 529#endif\r