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