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