]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h
Clean codes per ECC for GraphicsConsoleDxe 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 <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 UsStdNarrowGlyphData[];
185 extern EFI_WIDE_GLYPH UsStdWideGlyphData[];
186
187 //
188 // Device Structure
189 //
190 #define GRAPHICS_CONSOLE_DEV_SIGNATURE EFI_SIGNATURE_32 ('g', 's', 't', 'o')
191
192 typedef struct {
193 UINTN Columns;
194 UINTN Rows;
195 INTN DeltaX;
196 INTN DeltaY;
197 UINT32 GopWidth;
198 UINT32 GopHeight;
199 UINT32 GopModeNumber;
200 } GRAPHICS_CONSOLE_MODE_DATA;
201
202 #define GRAPHICS_MAX_MODE 4
203
204 typedef struct {
205 UINTN Signature;
206 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
207 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
208 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
209 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
210 GRAPHICS_CONSOLE_MODE_DATA ModeData[GRAPHICS_MAX_MODE];
211 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer;
212 EFI_HII_HANDLE HiiHandle;
213 } GRAPHICS_CONSOLE_DEV;
214
215 #define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \
216 CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)
217
218 //
219 // Global Variables
220 //
221 extern EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding;
222
223 //
224 // Prototypes
225 //
226 UINTN
227 ReturnNarrowFontSize (
228 VOID
229 );
230
231 /**
232 Implements SIMPLE_TEXT_OUTPUT.Reset().
233 If ExtendeVerification is TRUE, then perform dependent Graphics Console
234 device reset, and set display mode to mode 0.
235 If ExtendedVerification is FALSE, only set display mode to mode 0.
236
237 @param This Indicates the calling context.
238 @param ExtendedVerification Indicates that the driver may perform a more
239 exhaustive verification operation of the device
240 during reset.
241
242 @return EFI_SUCCESS
243 @return The reset operation succeeds.
244 @return EFI_DEVICE_ERROR
245 @return The Graphics Console is not functioning correctly
246
247 **/
248 EFI_STATUS
249 EFIAPI
250 GraphicsConsoleConOutReset (
251 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
252 IN BOOLEAN ExtendedVerification
253 );
254
255 /**
256 Implements SIMPLE_TEXT_OUTPUT.OutputString().
257 The Unicode string will be converted to Glyphs and will be
258 sent to the Graphics Console.
259
260 @param This Indicates the calling context.
261 @param WString The Null-terminated Unicode string to be displayed
262 on the Graphics Console.
263
264 @return EFI_SUCCESS
265 @return The string is output successfully.
266 @return EFI_DEVICE_ERROR
267 @return The Graphics Console failed to send the string out.
268 @return EFI_WARN_UNKNOWN_GLYPH
269 @return Indicates that some of the characters in the Unicode string could not
270 @return be rendered and are skipped.
271
272 **/
273 EFI_STATUS
274 EFIAPI
275 GraphicsConsoleConOutOutputString (
276 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
277 IN CHAR16 *WString
278 );
279
280 /**
281 Implements SIMPLE_TEXT_OUTPUT.TestString().
282 If one of the characters in the *Wstring is
283 neither valid valid Unicode drawing characters,
284 not ASCII code, then this function will return
285 EFI_UNSUPPORTED.
286
287 @param This Indicates the calling context.
288 @param WString The Null-terminated Unicode string to be tested.
289
290 @return EFI_SUCCESS
291 @return The Graphics Console is capable of rendering the output string.
292 @return EFI_UNSUPPORTED
293 @return Some of the characters in the Unicode string cannot be rendered.
294
295 **/
296 EFI_STATUS
297 EFIAPI
298 GraphicsConsoleConOutTestString (
299 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
300 IN CHAR16 *WString
301 );
302
303 /**
304 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
305 It returnes information for an available text mode
306 that the Graphics Console supports.
307 In this driver,we only support text mode 80x25, which is
308 defined as mode 0.
309
310 @param This Indicates the calling context.
311 @param ModeNumber The mode number to return information on.
312 @param Columns The returned columns of the requested mode.
313 @param Rows The returned rows of the requested mode.
314
315 @return EFI_SUCCESS
316 @return The requested mode information is returned.
317 @return EFI_UNSUPPORTED
318 @return The mode number is not valid.
319
320 **/
321 EFI_STATUS
322 EFIAPI
323 GraphicsConsoleConOutQueryMode (
324 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
325 IN UINTN ModeNumber,
326 OUT UINTN *Columns,
327 OUT UINTN *Rows
328 );
329
330 /**
331 Implements SIMPLE_TEXT_OUTPUT.SetMode().
332 Set the Graphics Console to a specified mode.
333 In this driver, we only support mode 0.
334
335 @param This Indicates the calling context.
336 @param ModeNumber The text mode to set.
337
338 @return EFI_SUCCESS
339 @return The requested text mode is set.
340 @return EFI_DEVICE_ERROR
341 @return The requested text mode cannot be set because of Graphics Console device error.
342 @return EFI_UNSUPPORTED
343 @return The text mode number is not valid.
344
345 **/
346 EFI_STATUS
347 EFIAPI
348 GraphicsConsoleConOutSetMode (
349 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
350 IN UINTN ModeNumber
351 );
352
353 /**
354 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
355
356 @param This Indicates the calling context.
357 @param Attribute The attribute to set. Only bit0..6 are valid, all
358 other bits are undefined and must be zero.
359
360 @return EFI_SUCCESS The requested attribute is set.
361 @return EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
362 @return EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.
363
364 **/
365 EFI_STATUS
366 EFIAPI
367 GraphicsConsoleConOutSetAttribute (
368 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
369 IN UINTN Attribute
370 );
371
372 /**
373 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
374 It clears the Graphics Console's display to the
375 currently selected background color.
376
377 @param This Indicates the calling context.
378
379 @return EFI_SUCCESS
380 @return The operation completed successfully.
381 @return EFI_DEVICE_ERROR
382 @return The Graphics Console cannot be cleared due to Graphics Console device error.
383 @return EFI_UNSUPPORTED
384 @return The Graphics Console is not in a valid text mode.
385
386 **/
387 EFI_STATUS
388 EFIAPI
389 GraphicsConsoleConOutClearScreen (
390 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
391 );
392
393 /**
394 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
395
396 @param This Indicates the calling context.
397 @param Column The row to set cursor to.
398 @param Row The column to set cursor to.
399
400 @return EFI_SUCCESS
401 @return The operation completed successfully.
402 @return EFI_DEVICE_ERROR
403 @return The request fails due to Graphics Console device error.
404 @return EFI_UNSUPPORTED
405 @return The Graphics Console is not in a valid text mode, or the cursor position
406 @return is invalid for current mode.
407
408 **/
409 EFI_STATUS
410 EFIAPI
411 GraphicsConsoleConOutSetCursorPosition (
412 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
413 IN UINTN Column,
414 IN UINTN Row
415 );
416
417 /**
418 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
419 In this driver, the cursor cannot be hidden.
420
421 @param This Indicates the calling context.
422 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
423 the cursor is set to be invisible.
424
425 @return EFI_SUCCESS
426 @return The request is valid.
427 @return EFI_UNSUPPORTED
428 @return The Graphics Console does not support a hidden cursor.
429
430 **/
431 EFI_STATUS
432 EFIAPI
433 GraphicsConsoleConOutEnableCursor (
434 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
435 IN BOOLEAN Visible
436 );
437
438 EFI_STATUS
439 EFIAPI
440 GraphicsConsoleControllerDriverSupported (
441 IN EFI_DRIVER_BINDING_PROTOCOL *This,
442 IN EFI_HANDLE Controller,
443 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
444 );
445
446 EFI_STATUS
447 EFIAPI
448 GraphicsConsoleControllerDriverStart (
449 IN EFI_DRIVER_BINDING_PROTOCOL *This,
450 IN EFI_HANDLE Controller,
451 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
452 );
453
454 EFI_STATUS
455 EFIAPI
456 GraphicsConsoleControllerDriverStop (
457 IN EFI_DRIVER_BINDING_PROTOCOL *This,
458 IN EFI_HANDLE Controller,
459 IN UINTN NumberOfChildren,
460 IN EFI_HANDLE *ChildHandleBuffer
461 );
462
463
464 EFI_STATUS
465 EfiLocateHiiProtocol (
466 VOID
467 )
468 ;
469
470
471 #endif