2 Internal include file of the VGA Class Driver.
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
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.
16 #ifndef _VGA_CLASS_H__
17 #define _VGA_CLASS_H__
20 #include <FrameworkDxe.h>
22 #include <Protocol/SimpleTextOut.h>
23 #include <Protocol/PciIo.h>
24 #include <Protocol/VgaMiniPort.h>
25 #include <Protocol/DevicePath.h>
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>
34 #include <IndustryStandard/Pci22.h>
39 extern EFI_DRIVER_BINDING_PROTOCOL gVgaClassDriverBinding
;
40 extern EFI_COMPONENT_NAME_PROTOCOL gVgaClassComponentName
;
41 extern EFI_COMPONENT_NAME2_PROTOCOL gVgaClassComponentName2
;
45 // Structure for tuple containing mapping among uniocde, PC Ansi and ASCII code.
54 // VGA specific registers
56 #define CRTC_CURSOR_START 0xA
57 #define CRTC_CURSOR_END 0xB
59 #define CRTC_CURSOR_LOCATION_HIGH 0xE
60 #define CRTC_CURSOR_LOCATION_LOW 0xF
62 #define EFI_MAX_ATTRIBUTE 0x7f
65 // VGA Class Device Structure
67 #define VGA_CLASS_DEV_SIGNATURE SIGNATURE_32 ('V', 'G', 'A', 'C')
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
;
79 #define VGA_CLASS_DEV_FROM_THIS(a) CR (a, VGA_CLASS_DEV, SimpleTextOut, VGA_CLASS_DEV_SIGNATURE)
82 // Driver Binding Protocol functions
86 Tests to see if this driver supports a given controller.
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.
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
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.
104 VgaClassDriverBindingSupported (
105 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
106 IN EFI_HANDLE Controller
,
107 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
111 Starts the device controller.
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.
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
122 @retval EFI_SUCCESS The device was started.
123 @retval other Fail to start the device.
128 VgaClassDriverBindingStart (
129 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
130 IN EFI_HANDLE Controller
,
131 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
135 Starts the device controller.
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.
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.
146 @retval EFI_SUCCESS This driver is removed ControllerHandle
147 @retval other This driver was not removed from this device
152 VgaClassDriverBindingStop (
153 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
154 IN EFI_HANDLE Controller
,
155 IN UINTN NumberOfChildren
,
156 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
160 // EFI Component Name Functions
164 Retrieves a Unicode string that is the user readable name of the driver.
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.
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.
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.
199 VgaClassComponentNameGetDriverName (
200 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
202 OUT CHAR16
**DriverName
206 Retrieves a Unicode string that is the user readable name of the controller
207 that is being managed by a driver.
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.
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
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
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
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
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
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.
265 VgaClassComponentNameGetControllerName (
266 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
267 IN EFI_HANDLE ControllerHandle
,
268 IN EFI_HANDLE ChildHandle OPTIONAL
,
270 OUT CHAR16
**ControllerName
274 // Simple Text Output Protocol functions
277 Resets the text output device hardware.
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.
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.
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.
294 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
295 IN BOOLEAN ExtendedVerification
299 Writes a Unicode string to the output device.
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
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).
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.
316 VgaClassOutputString (
317 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
322 Verifies that all characters in a Unicode string can be output to the target device.
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.
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).
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.
338 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
343 Clears the output device(s) display to the currently selected background color.
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).
349 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
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.
358 VgaClassClearScreen (
359 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
363 Sets the background and foreground colors for theOutputString() and ClearScreen() functions.
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.
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.
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.
382 VgaClassSetAttribute (
383 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
388 Sets the current coordinates of the cursor position.
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).
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.
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.
406 VgaClassSetCursorPosition (
407 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
413 Makes the cursor visible or invisible.
415 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.EnableCursor().
416 It makes the cursor visible or invisible.
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.
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.
430 VgaClassEnableCursor (
431 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
436 Returns information for an available text mode that the output device(s) supports.
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.
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.
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.
456 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
463 Sets the output device(s) to a specified mode.
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).
470 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
471 @param ModeNumber The text mode to set.
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.
481 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,