]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.h
Adjust the code so that global variable placed at beginning of file.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / Console / VgaClassDxe / VgaClass.h
1 /** @file
2 Internal include file of the VGA Class Driver.
3
4 Copyright (c) 2006 - 2009, Intel Corporation
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
16 #ifndef _VGA_CLASS_H__
17 #define _VGA_CLASS_H__
18
19 #include <PiDxe.h>
20 #include <FrameworkDxe.h>
21
22 #include <Protocol/SimpleTextOut.h>
23 #include <Protocol/PciIo.h>
24 #include <Protocol/VgaMiniPort.h>
25 #include <Protocol/DevicePath.h>
26
27 #include <Library/DebugLib.h>
28 #include <Library/UefiDriverEntryPoint.h>
29 #include <Library/UefiLib.h>
30 #include <Library/MemoryAllocationLib.h>
31 #include <Library/UefiBootServicesTableLib.h>
32 #include <Library/ReportStatusCodeLib.h>
33
34 #include <IndustryStandard/Pci22.h>
35
36 //
37 // Global Variables
38 //
39 extern EFI_DRIVER_BINDING_PROTOCOL gVgaClassDriverBinding;
40 extern EFI_COMPONENT_NAME_PROTOCOL gVgaClassComponentName;
41 extern EFI_COMPONENT_NAME2_PROTOCOL gVgaClassComponentName2;
42
43
44 //
45 // Structure for tuple containing mapping among uniocde, PC Ansi and ASCII code.
46 //
47 typedef struct {
48 CHAR16 Unicode;
49 CHAR8 PcAnsi;
50 CHAR8 Ascii;
51 } UNICODE_TO_CHAR;
52
53 //
54 // VGA specific registers
55 //
56 #define CRTC_CURSOR_START 0xA
57 #define CRTC_CURSOR_END 0xB
58
59 #define CRTC_CURSOR_LOCATION_HIGH 0xE
60 #define CRTC_CURSOR_LOCATION_LOW 0xF
61
62 #define EFI_MAX_ATTRIBUTE 0x7f
63
64 //
65 // VGA Class Device Structure
66 //
67 #define VGA_CLASS_DEV_SIGNATURE SIGNATURE_32 ('V', 'G', 'A', 'C')
68
69 typedef struct {
70 UINTN Signature;
71 EFI_HANDLE Handle;
72 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut;
73 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
74 EFI_VGA_MINI_PORT_PROTOCOL *VgaMiniPort;
75 EFI_PCI_IO_PROTOCOL *PciIo;
76 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
77 } VGA_CLASS_DEV;
78
79 #define VGA_CLASS_DEV_FROM_THIS(a) CR (a, VGA_CLASS_DEV, SimpleTextOut, VGA_CLASS_DEV_SIGNATURE)
80
81 //
82 // Driver Binding Protocol functions
83 //
84
85 /**
86 Tests to see if this driver supports a given controller.
87
88 This function implments EFI_DRIVER_BINDING_PROTOCOL.Supported().
89 It Checks if this driver supports the controller specified. Any Controller
90 with VgaMiniPort Protocol and Pci I/O protocol can be supported.
91
92 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
93 @param ControllerHandle Handle of device to test
94 @param RemainingDevicePath Optional parameter use to pick a specific child
95 device to start.
96
97 @retval EFI_SUCCESS This driver supports this device.
98 @retval EFI_ALREADY_STARTED This driver is already running on this device.
99 @retval EFI_UNSUPPORTED This driver does not support this device.
100
101 **/
102 EFI_STATUS
103 EFIAPI
104 VgaClassDriverBindingSupported (
105 IN EFI_DRIVER_BINDING_PROTOCOL *This,
106 IN EFI_HANDLE Controller,
107 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
108 );
109
110 /**
111 Starts the device controller.
112
113 This function implments EFI_DRIVER_BINDING_PROTOCOL.Start().
114 It starts the device specified by Controller with the driver based on PCI I/O Protocol
115 and VgaMiniPort Protocol. It creates context for device instance and install EFI_SIMPLE_TEXT_OUT_PROTOCOL.
116
117 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
118 @param ControllerHandle Handle of device to bind driver to
119 @param RemainingDevicePath Optional parameter use to pick a specific child
120 device to start.
121
122 @retval EFI_SUCCESS The device was started.
123 @retval other Fail to start the device.
124
125 **/
126 EFI_STATUS
127 EFIAPI
128 VgaClassDriverBindingStart (
129 IN EFI_DRIVER_BINDING_PROTOCOL *This,
130 IN EFI_HANDLE Controller,
131 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
132 );
133
134 /**
135 Starts the device controller.
136
137 This function implments EFI_DRIVER_BINDING_PROTOCOL.Stop().
138 It stops this driver on Controller. Support stoping any child handles
139 created by this driver.
140
141 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
142 @param ControllerHandle A handle to the device being stopped.
143 @param NumberOfChildren The number of child device handles in ChildHandleBuffer.
144 @param ChildHandleBuffer An array of child handles to be freed.
145
146 @retval EFI_SUCCESS This driver is removed ControllerHandle
147 @retval other This driver was not removed from this device
148
149 **/
150 EFI_STATUS
151 EFIAPI
152 VgaClassDriverBindingStop (
153 IN EFI_DRIVER_BINDING_PROTOCOL *This,
154 IN EFI_HANDLE Controller,
155 IN UINTN NumberOfChildren,
156 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
157 );
158
159 //
160 // EFI Component Name Functions
161 //
162
163 /**
164 Retrieves a Unicode string that is the user readable name of the driver.
165
166 This function retrieves the user readable name of a driver in the form of a
167 Unicode string. If the driver specified by This has a user readable name in
168 the language specified by Language, then a pointer to the driver name is
169 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
170 by This does not support the language specified by Language,
171 then EFI_UNSUPPORTED is returned.
172
173 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
174 EFI_COMPONENT_NAME_PROTOCOL instance.
175 @param Language A pointer to a Null-terminated ASCII string
176 array indicating the language. This is the
177 language of the driver name that the caller is
178 requesting, and it must match one of the
179 languages specified in SupportedLanguages. The
180 number of languages supported by a driver is up
181 to the driver writer. Language is specified
182 in RFC 3066 or ISO 639-2 language code format.
183 @param DriverName A pointer to the Unicode string to return.
184 This Unicode string is the name of the
185 driver specified by This in the language
186 specified by Language.
187
188 @retval EFI_SUCCESS The Unicode string for the Driver specified by
189 This and the language specified by Language was
190 returned in DriverName.
191 @retval EFI_INVALID_PARAMETER Language is NULL.
192 @retval EFI_INVALID_PARAMETER DriverName is NULL.
193 @retval EFI_UNSUPPORTED The driver specified by This does not support
194 the language specified by Language.
195
196 **/
197 EFI_STATUS
198 EFIAPI
199 VgaClassComponentNameGetDriverName (
200 IN EFI_COMPONENT_NAME_PROTOCOL *This,
201 IN CHAR8 *Language,
202 OUT CHAR16 **DriverName
203 );
204
205 /**
206 Retrieves a Unicode string that is the user readable name of the controller
207 that is being managed by a driver.
208
209 This function retrieves the user readable name of the controller specified by
210 ControllerHandle and ChildHandle in the form of a Unicode string. If the
211 driver specified by This has a user readable name in the language specified by
212 Language, then a pointer to the controller name is returned in ControllerName,
213 and EFI_SUCCESS is returned. If the driver specified by This is not currently
214 managing the controller specified by ControllerHandle and ChildHandle,
215 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
216 support the language specified by Language, then EFI_UNSUPPORTED is returned.
217
218 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
219 EFI_COMPONENT_NAME_PROTOCOL instance.
220 @param ControllerHandle The handle of a controller that the driver
221 specified by This is managing. This handle
222 specifies the controller whose name is to be
223 returned.
224 @param ChildHandle The handle of the child controller to retrieve
225 the name of. This is an optional parameter that
226 may be NULL. It will be NULL for device
227 drivers. It will also be NULL for a bus drivers
228 that wish to retrieve the name of the bus
229 controller. It will not be NULL for a bus
230 driver that wishes to retrieve the name of a
231 child controller.
232 @param Language A pointer to a Null-terminated ASCII string
233 array indicating the language. This is the
234 language of the driver name that the caller is
235 requesting, and it must match one of the
236 languages specified in SupportedLanguages. The
237 number of languages supported by a driver is up
238 to the driver writer. Language is specified in
239 RFC 3066 or ISO 639-2 language code format.
240 @param ControllerName A pointer to the Unicode string to return.
241 This Unicode string is the name of the
242 controller specified by ControllerHandle and
243 ChildHandle in the language specified by
244 Language from the point of view of the driver
245 specified by This.
246
247 @retval EFI_SUCCESS The Unicode string for the user readable name in
248 the language specified by Language for the
249 driver specified by This was returned in
250 DriverName.
251 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
252 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
253 EFI_HANDLE.
254 @retval EFI_INVALID_PARAMETER Language is NULL.
255 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
256 @retval EFI_UNSUPPORTED The driver specified by This is not currently
257 managing the controller specified by
258 ControllerHandle and ChildHandle.
259 @retval EFI_UNSUPPORTED The driver specified by This does not support
260 the language specified by Language.
261
262 **/
263 EFI_STATUS
264 EFIAPI
265 VgaClassComponentNameGetControllerName (
266 IN EFI_COMPONENT_NAME_PROTOCOL *This,
267 IN EFI_HANDLE ControllerHandle,
268 IN EFI_HANDLE ChildHandle OPTIONAL,
269 IN CHAR8 *Language,
270 OUT CHAR16 **ControllerName
271 );
272
273 //
274 // Simple Text Output Protocol functions
275 //
276 /**
277 Resets the text output device hardware.
278
279 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().
280 It resets the text output device hardware. The cursor position is set to (0, 0),
281 and the screen is cleared to the default background color for the output device.
282
283 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
284 @param ExtendedVerification Indicates that the driver may perform a more exhaustive
285 verification operation of the device during reset.
286
287 @retval EFI_SUCCESS The text output device was reset.
288 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and could not be reset.
289
290 **/
291 EFI_STATUS
292 EFIAPI
293 VgaClassReset (
294 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
295 IN BOOLEAN ExtendedVerification
296 );
297
298 /**
299 Writes a Unicode string to the output device.
300
301 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().
302 It writes a Unicode string to the output device. This is the most basic output mechanism
303 on an output device.
304
305 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
306 @param String The Null-terminated Unicode string to be displayed on the output device(s).
307
308 @retval EFI_SUCCESS The string was output to the device.
309 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output the text.
310 @retval EFI_UNSUPPORTED The output device\92s mode is not currently in a defined text mode.
311 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the characters in
312 the Unicode string could not be rendered and were skipped.
313 **/
314 EFI_STATUS
315 EFIAPI
316 VgaClassOutputString (
317 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
318 IN CHAR16 *String
319 );
320
321 /**
322 Verifies that all characters in a Unicode string can be output to the target device.
323
324 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().
325 It verifies that all characters in a Unicode string can be output to the target device.
326
327 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
328 @param String The Null-terminated Unicode string to be examined for the output device(s).
329
330 @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
331 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered by
332 one or more of the output devices mapped by the EFI handle.
333
334 **/
335 EFI_STATUS
336 EFIAPI
337 VgaClassTestString (
338 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
339 IN CHAR16 *String
340 );
341
342 /**
343 Clears the output device(s) display to the currently selected background color.
344
345 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().
346 The ClearScreen() function clears the output device(s) display to the currently
347 selected background color. The cursor position is set to (0, 0).
348
349 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
350
351 @retval EFI_SUCESS The operation completed successfully.
352 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
353 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
354
355 **/
356 EFI_STATUS
357 EFIAPI
358 VgaClassClearScreen (
359 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
360 );
361
362 /**
363 Sets the background and foreground colors for theOutputString() and ClearScreen() functions.
364
365 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().
366 It sets the background and foreground colors for the OutputString() and ClearScreen() functions.
367 The color mask can be set even when the device is in an invalid text mode.
368 Devices supporting a different number of text colors are required to emulate the above colors
369 to the best of the device\92s capabilities.
370
371 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
372 @param Attribute The attribute to set.
373 Bits 0..3 are the foreground color,
374 and bits 4..6 are the background color.
375
376 @retval EFI_SUCCESS The requested attributes were set.
377 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
378
379 **/
380 EFI_STATUS
381 EFIAPI
382 VgaClassSetAttribute (
383 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
384 IN UINTN Attribute
385 );
386
387 /**
388 Sets the current coordinates of the cursor position.
389
390 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().
391 It sets the current coordinates of the cursor position.
392 The upper left corner of the screen is defined as coordinate (0, 0).
393
394 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
395 @param Column Column of position to set the cursor to.
396 @param Row Row of position to set the cursor to.
397
398 @retval EFI_SUCCESS The operation completed successfully.
399 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
400 @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the cursor
401 position is invalid for the current mode.
402
403 **/
404 EFI_STATUS
405 EFIAPI
406 VgaClassSetCursorPosition (
407 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
408 IN UINTN Column,
409 IN UINTN Row
410 );
411
412 /**
413 Makes the cursor visible or invisible.
414
415 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.EnableCursor().
416 It makes the cursor visible or invisible.
417
418 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
419 @param Visible If TRUE, the cursor is set to be visible.
420 If FALSE, the cursor is set to be invisible.
421
422 @retval EFI_SUCESS The operation completed successfully.
423 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request or the
424 device does not support changing the cursor mode.
425 @retval EFI_UNSUPPORTED The output device does not support visibility control of the cursor.
426
427 **/
428 EFI_STATUS
429 EFIAPI
430 VgaClassEnableCursor (
431 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
432 IN BOOLEAN Visible
433 );
434
435 /**
436 Returns information for an available text mode that the output device(s) supports.
437
438 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
439 It returns information for an available text mode that the output device(s) supports.
440 It is required that all output devices support at least 80x25 text mode. This mode is defined to be mode 0.
441 If the output devices support 80x50, that is defined to be mode 1.
442
443 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
444 @param ModeNumber The mode number to return information on.
445 @param Columns Columen in current mode number
446 @param Rows Row in current mode number.
447
448 @retval EFI_SUCCESS The requested mode information was returned.
449 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
450 @retval EFI_UNSUPPORTED The mode number was not valid.
451
452 **/
453 EFI_STATUS
454 EFIAPI
455 VgaClassQueryMode (
456 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
457 IN UINTN ModeNumber,
458 OUT UINTN *Columns,
459 OUT UINTN *Rows
460 );
461
462 /**
463 Sets the output device(s) to a specified mode.
464
465 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
466 It sets the output device(s) to the requested mode.
467 On success the device is in the geometry for the requested mode,
468 and the device has been cleared to the current background color with the cursor at (0,0).
469
470 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
471 @param ModeNumber The text mode to set.
472
473 @retval EFI_SUCCESS The requested text mode was set.
474 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
475 @retval EFI_UNSUPPORTED The mode number was not valid.
476
477 **/
478 EFI_STATUS
479 EFIAPI
480 VgaClassSetMode (
481 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
482 IN UINTN ModeNumber
483 );
484
485 #endif