]>
Commit | Line | Data |
---|---|---|
55a1bb43 | 1 | /** @file\r |
2 | Internal include file of the VGA Class Driver.\r | |
e081218d | 3 | \r |
55a1bb43 | 4 | Copyright (c) 2006 - 2009, Intel Corporation \r |
3db51098 | 5 | All rights reserved. This program and the accompanying materials \r |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT 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 |
19 | #include <PiDxe.h>\r | |
20 | #include <FrameworkDxe.h>\r | |
ed7748fe | 21 | \r |
e081218d | 22 | #include <Protocol/SimpleTextOut.h>\r |
23 | #include <Protocol/PciIo.h>\r | |
24 | #include <Protocol/VgaMiniPort.h>\r | |
25 | #include <Protocol/DevicePath.h>\r | |
ed7748fe | 26 | \r |
e081218d | 27 | #include <Library/DebugLib.h>\r |
28 | #include <Library/UefiDriverEntryPoint.h>\r | |
e081218d | 29 | #include <Library/UefiLib.h>\r |
e081218d | 30 | #include <Library/MemoryAllocationLib.h>\r |
31 | #include <Library/UefiBootServicesTableLib.h>\r | |
32 | #include <Library/ReportStatusCodeLib.h>\r | |
33 | \r | |
e081218d | 34 | #include <IndustryStandard/Pci22.h>\r |
55a1bb43 | 35 | \r |
9f6531d1 | 36 | //\r |
37 | // Global Variables\r | |
38 | //\r | |
39 | extern EFI_DRIVER_BINDING_PROTOCOL gVgaClassDriverBinding;\r | |
40 | extern EFI_COMPONENT_NAME_PROTOCOL gVgaClassComponentName;\r | |
41 | extern EFI_COMPONENT_NAME2_PROTOCOL gVgaClassComponentName2;\r | |
42 | \r | |
43 | \r | |
55a1bb43 | 44 | //\r |
45 | // Structure for tuple containing mapping among uniocde, PC Ansi and ASCII code.\r | |
46 | //\r | |
47 | typedef struct {\r | |
48 | CHAR16 Unicode;\r | |
49 | CHAR8 PcAnsi;\r | |
50 | CHAR8 Ascii;\r | |
51 | } UNICODE_TO_CHAR;\r | |
e081218d | 52 | \r |
53 | //\r | |
54 | // VGA specific registers\r | |
55 | //\r | |
56 | #define CRTC_CURSOR_START 0xA\r | |
57 | #define CRTC_CURSOR_END 0xB\r | |
58 | \r | |
59 | #define CRTC_CURSOR_LOCATION_HIGH 0xE\r | |
60 | #define CRTC_CURSOR_LOCATION_LOW 0xF\r | |
61 | \r | |
62 | #define EFI_MAX_ATTRIBUTE 0x7f\r | |
63 | \r | |
64 | //\r | |
65 | // VGA Class Device Structure\r | |
66 | //\r | |
f02bd376 | 67 | #define VGA_CLASS_DEV_SIGNATURE SIGNATURE_32 ('V', 'G', 'A', 'C')\r |
e081218d | 68 | \r |
69 | typedef struct {\r | |
55a1bb43 | 70 | UINTN Signature;\r |
71 | EFI_HANDLE Handle;\r | |
e081218d | 72 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut;\r |
55a1bb43 | 73 | EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;\r |
74 | EFI_VGA_MINI_PORT_PROTOCOL *VgaMiniPort;\r | |
75 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
76 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
e081218d | 77 | } VGA_CLASS_DEV;\r |
78 | \r | |
79 | #define VGA_CLASS_DEV_FROM_THIS(a) CR (a, VGA_CLASS_DEV, SimpleTextOut, VGA_CLASS_DEV_SIGNATURE)\r | |
80 | \r | |
e081218d | 81 | //\r |
82 | // Driver Binding Protocol functions\r | |
83 | //\r | |
e081218d | 84 | \r |
55a1bb43 | 85 | /**\r |
86 | Tests to see if this driver supports a given controller.\r | |
e081218d | 87 | \r |
55a1bb43 | 88 | This function implments EFI_DRIVER_BINDING_PROTOCOL.Supported().\r |
89 | It Checks if this driver supports the controller specified. Any Controller\r | |
90 | with VgaMiniPort Protocol and Pci I/O protocol can be supported.\r | |
e081218d | 91 | \r |
55a1bb43 | 92 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
93 | @param ControllerHandle Handle of device to test\r | |
94 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
95 | device to start.\r | |
e081218d | 96 | \r |
55a1bb43 | 97 | @retval EFI_SUCCESS This driver supports this device.\r |
98 | @retval EFI_ALREADY_STARTED This driver is already running on this device.\r | |
99 | @retval EFI_UNSUPPORTED This driver does not support this device.\r | |
e081218d | 100 | \r |
bcd70414 | 101 | **/\r |
e081218d | 102 | EFI_STATUS\r |
103 | EFIAPI\r | |
55a1bb43 | 104 | VgaClassDriverBindingSupported (\r |
105 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
106 | IN EFI_HANDLE Controller,\r | |
107 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
108 | );\r | |
109 | \r | |
bcd70414 | 110 | /**\r |
55a1bb43 | 111 | Starts the device controller.\r |
112 | \r | |
113 | This function implments EFI_DRIVER_BINDING_PROTOCOL.Start().\r | |
114 | It starts the device specified by Controller with the driver based on PCI I/O Protocol\r | |
115 | and VgaMiniPort Protocol. It creates context for device instance and install EFI_SIMPLE_TEXT_OUT_PROTOCOL.\r | |
e081218d | 116 | \r |
55a1bb43 | 117 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
118 | @param ControllerHandle Handle of device to bind driver to\r | |
119 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
120 | device to start.\r | |
e081218d | 121 | \r |
55a1bb43 | 122 | @retval EFI_SUCCESS The device was started.\r |
123 | @retval other Fail to start the device.\r | |
e081218d | 124 | \r |
55a1bb43 | 125 | **/\r |
126 | EFI_STATUS\r | |
127 | EFIAPI\r | |
128 | VgaClassDriverBindingStart (\r | |
129 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
130 | IN EFI_HANDLE Controller,\r | |
131 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
132 | );\r | |
e081218d | 133 | \r |
55a1bb43 | 134 | /**\r |
135 | Starts the device controller.\r | |
136 | \r | |
137 | This function implments EFI_DRIVER_BINDING_PROTOCOL.Stop().\r | |
138 | It stops this driver on Controller. Support stoping any child handles\r | |
139 | created by this driver.\r | |
e081218d | 140 | \r |
55a1bb43 | 141 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
142 | @param ControllerHandle A handle to the device being stopped.\r | |
143 | @param NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
144 | @param ChildHandleBuffer An array of child handles to be freed.\r | |
e081218d | 145 | \r |
55a1bb43 | 146 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r |
147 | @retval other This driver was not removed from this device\r | |
e081218d | 148 | \r |
bcd70414 | 149 | **/\r |
e081218d | 150 | EFI_STATUS\r |
151 | EFIAPI\r | |
152 | VgaClassDriverBindingStop (\r | |
55a1bb43 | 153 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
154 | IN EFI_HANDLE Controller,\r | |
155 | IN UINTN NumberOfChildren,\r | |
156 | IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r | |
157 | );\r | |
e081218d | 158 | \r |
55a1bb43 | 159 | //\r |
160 | // EFI Component Name Functions\r | |
161 | //\r | |
e081218d | 162 | \r |
55a1bb43 | 163 | /**\r |
164 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
165 | \r | |
166 | This function retrieves the user readable name of a driver in the form of a\r | |
167 | Unicode string. If the driver specified by This has a user readable name in\r | |
168 | the language specified by Language, then a pointer to the driver name is\r | |
169 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
170 | by This does not support the language specified by Language,\r | |
171 | then EFI_UNSUPPORTED is returned.\r | |
172 | \r | |
173 | @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
174 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
175 | @param Language A pointer to a Null-terminated ASCII string\r | |
176 | array indicating the language. This is the\r | |
177 | language of the driver name that the caller is\r | |
178 | requesting, and it must match one of the\r | |
179 | languages specified in SupportedLanguages. The\r | |
180 | number of languages supported by a driver is up\r | |
181 | to the driver writer. Language is specified\r | |
182 | in RFC 3066 or ISO 639-2 language code format.\r | |
183 | @param DriverName A pointer to the Unicode string to return.\r | |
184 | This Unicode string is the name of the\r | |
185 | driver specified by This in the language\r | |
186 | specified by Language.\r | |
187 | \r | |
188 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
189 | This and the language specified by Language was\r | |
190 | returned in DriverName.\r | |
191 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
192 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
193 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
194 | the language specified by Language.\r | |
e081218d | 195 | \r |
55a1bb43 | 196 | **/\r |
197 | EFI_STATUS\r | |
198 | EFIAPI\r | |
199 | VgaClassComponentNameGetDriverName (\r | |
200 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
201 | IN CHAR8 *Language,\r | |
202 | OUT CHAR16 **DriverName\r | |
203 | );\r | |
e081218d | 204 | \r |
55a1bb43 | 205 | /**\r |
206 | Retrieves a Unicode string that is the user readable name of the controller\r | |
207 | that is being managed by a driver.\r | |
208 | \r | |
209 | This function retrieves the user readable name of the controller specified by\r | |
210 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
211 | driver specified by This has a user readable name in the language specified by\r | |
212 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
213 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
214 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
215 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
216 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
217 | \r | |
218 | @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
219 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
220 | @param ControllerHandle The handle of a controller that the driver\r | |
221 | specified by This is managing. This handle\r | |
222 | specifies the controller whose name is to be\r | |
223 | returned.\r | |
224 | @param ChildHandle The handle of the child controller to retrieve\r | |
225 | the name of. This is an optional parameter that\r | |
226 | may be NULL. It will be NULL for device\r | |
227 | drivers. It will also be NULL for a bus drivers\r | |
228 | that wish to retrieve the name of the bus\r | |
229 | controller. It will not be NULL for a bus\r | |
230 | driver that wishes to retrieve the name of a\r | |
231 | child controller.\r | |
232 | @param Language A pointer to a Null-terminated ASCII string\r | |
233 | array indicating the language. This is the\r | |
234 | language of the driver name that the caller is\r | |
235 | requesting, and it must match one of the\r | |
236 | languages specified in SupportedLanguages. The\r | |
237 | number of languages supported by a driver is up\r | |
238 | to the driver writer. Language is specified in\r | |
239 | RFC 3066 or ISO 639-2 language code format.\r | |
240 | @param ControllerName A pointer to the Unicode string to return.\r | |
241 | This Unicode string is the name of the\r | |
242 | controller specified by ControllerHandle and\r | |
243 | ChildHandle in the language specified by\r | |
244 | Language from the point of view of the driver\r | |
245 | specified by This.\r | |
246 | \r | |
247 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
248 | the language specified by Language for the\r | |
249 | driver specified by This was returned in\r | |
250 | DriverName.\r | |
251 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
252 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
253 | EFI_HANDLE.\r | |
254 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
255 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
256 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
257 | managing the controller specified by\r | |
258 | ControllerHandle and ChildHandle.\r | |
259 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
260 | the language specified by Language.\r | |
e081218d | 261 | \r |
bcd70414 | 262 | **/\r |
55a1bb43 | 263 | EFI_STATUS\r |
264 | EFIAPI\r | |
265 | VgaClassComponentNameGetControllerName (\r | |
266 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
267 | IN EFI_HANDLE ControllerHandle,\r | |
268 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
269 | IN CHAR8 *Language,\r | |
270 | OUT CHAR16 **ControllerName\r | |
271 | );\r | |
e081218d | 272 | \r |
273 | //\r | |
274 | // Simple Text Output Protocol functions\r | |
275 | //\r | |
bcd70414 | 276 | /**\r |
55a1bb43 | 277 | Resets the text output device hardware.\r |
e081218d | 278 | \r |
55a1bb43 | 279 | This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().\r |
280 | It resets the text output device hardware. The cursor position is set to (0, 0),\r | |
281 | and the screen is cleared to the default background color for the output device.\r | |
282 | \r | |
283 | @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r | |
284 | @param ExtendedVerification Indicates that the driver may perform a more exhaustive\r | |
285 | verification operation of the device during reset.\r | |
e081218d | 286 | \r |
55a1bb43 | 287 | @retval EFI_SUCCESS The text output device was reset.\r |
288 | @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and could not be reset.\r | |
e081218d | 289 | \r |
bcd70414 | 290 | **/\r |
55a1bb43 | 291 | EFI_STATUS\r |
292 | EFIAPI\r | |
293 | VgaClassReset (\r | |
294 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
295 | IN BOOLEAN ExtendedVerification\r | |
296 | );\r | |
e081218d | 297 | \r |
55a1bb43 | 298 | /**\r |
299 | Writes a Unicode string to the output device.\r | |
300 | \r | |
301 | This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().\r | |
302 | It writes a Unicode string to the output device. This is the most basic output mechanism\r | |
303 | on an output device.\r | |
304 | \r | |
305 | @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r | |
306 | @param String The Null-terminated Unicode string to be displayed on the output device(s).\r | |
307 | \r | |
308 | @retval EFI_SUCCESS The string was output to the device.\r | |
309 | @retval EFI_DEVICE_ERROR The device reported an error while attempting to output the text.\r | |
310 |