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