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