]>
Commit | Line | Data |
---|---|---|
55a1bb43 | 1 | /** @file\r |
2 | VGA Class Driver that managers VGA devices and produces Simple Text Output Protocol.\r | |
3db51098 | 3 | \r |
0a6f4824 | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
c0a00b14 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
3db51098 | 6 | \r |
7 | **/\r | |
e081218d | 8 | \r |
9 | #include "VgaClass.h"\r | |
10 | \r | |
11 | //\r | |
12 | // EFI Driver Binding Protocol for the VGA Class Driver\r | |
13 | //\r | |
14 | EFI_DRIVER_BINDING_PROTOCOL gVgaClassDriverBinding = {\r | |
15 | VgaClassDriverBindingSupported,\r | |
16 | VgaClassDriverBindingStart,\r | |
17 | VgaClassDriverBindingStop,\r | |
18 | 0xa,\r | |
19 | NULL,\r | |
20 | NULL\r | |
21 | };\r | |
22 | \r | |
e081218d | 23 | //\r |
24 | // Local variables\r | |
25 | //\r | |
819d1488 | 26 | CHAR16 CrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };\r |
e081218d | 27 | \r |
e081218d | 28 | //\r |
29 | // This list is used to define the valid extend chars.\r | |
30 | // It also provides a mapping from Unicode to PCANSI or\r | |
31 | // ASCII. The ASCII mapping we just made up.\r | |
32 | //\r | |
33 | //\r | |
819d1488 | 34 | UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {\r |
e081218d | 35 | {\r |
36 | BOXDRAW_HORIZONTAL,\r | |
37 | 0xc4,\r | |
38 | L'-'\r | |
39 | },\r | |
40 | {\r | |
41 | BOXDRAW_VERTICAL,\r | |
42 | 0xb3,\r | |
43 | L'|'\r | |
44 | },\r | |
45 | {\r | |
46 | BOXDRAW_DOWN_RIGHT,\r | |
47 | 0xda,\r | |
48 | L'/'\r | |
49 | },\r | |
50 | {\r | |
51 | BOXDRAW_DOWN_LEFT,\r | |
52 | 0xbf,\r | |
53 | L'\\'\r | |
54 | },\r | |
55 | {\r | |
56 | BOXDRAW_UP_RIGHT,\r | |
57 | 0xc0,\r | |
58 | L'\\'\r | |
59 | },\r | |
60 | {\r | |
61 | BOXDRAW_UP_LEFT,\r | |
62 | 0xd9,\r | |
63 | L'/'\r | |
64 | },\r | |
65 | {\r | |
66 | BOXDRAW_VERTICAL_RIGHT,\r | |
67 | 0xc3,\r | |
68 | L'|'\r | |
69 | },\r | |
70 | {\r | |
71 | BOXDRAW_VERTICAL_LEFT,\r | |
72 | 0xb4,\r | |
73 | L'|'\r | |
74 | },\r | |
75 | {\r | |
76 | BOXDRAW_DOWN_HORIZONTAL,\r | |
77 | 0xc2,\r | |
78 | L'+'\r | |
79 | },\r | |
80 | {\r | |
81 | BOXDRAW_UP_HORIZONTAL,\r | |
82 | 0xc1,\r | |
83 | L'+'\r | |
84 | },\r | |
85 | {\r | |
86 | BOXDRAW_VERTICAL_HORIZONTAL,\r | |
87 | 0xc5,\r | |
88 | L'+'\r | |
89 | },\r | |
90 | {\r | |
91 | BOXDRAW_DOUBLE_HORIZONTAL,\r | |
92 | 0xcd,\r | |
93 | L'-'\r | |
94 | },\r | |
95 | {\r | |
96 | BOXDRAW_DOUBLE_VERTICAL,\r | |
97 | 0xba,\r | |
98 | L'|'\r | |
99 | },\r | |
100 | {\r | |
101 | BOXDRAW_DOWN_RIGHT_DOUBLE,\r | |
102 | 0xd5,\r | |
103 | L'/'\r | |
104 | },\r | |
105 | {\r | |
106 | BOXDRAW_DOWN_DOUBLE_RIGHT,\r | |
107 | 0xd6,\r | |
108 | L'/'\r | |
109 | },\r | |
110 | {\r | |
111 | BOXDRAW_DOUBLE_DOWN_RIGHT,\r | |
112 | 0xc9,\r | |
113 | L'/'\r | |
114 | },\r | |
115 | {\r | |
116 | BOXDRAW_DOWN_LEFT_DOUBLE,\r | |
117 | 0xb8,\r | |
118 | L'\\'\r | |
119 | },\r | |
120 | {\r | |
121 | BOXDRAW_DOWN_DOUBLE_LEFT,\r | |
122 | 0xb7,\r | |
123 | L'\\'\r | |
124 | },\r | |
125 | {\r | |
126 | BOXDRAW_DOUBLE_DOWN_LEFT,\r | |
127 | 0xbb,\r | |
128 | L'\\'\r | |
129 | },\r | |
130 | {\r | |
131 | BOXDRAW_UP_RIGHT_DOUBLE,\r | |
132 | 0xd4,\r | |
133 | L'\\'\r | |
134 | },\r | |
135 | {\r | |
136 | BOXDRAW_UP_DOUBLE_RIGHT,\r | |
137 | 0xd3,\r | |
138 | L'\\'\r | |
139 | },\r | |
140 | {\r | |
141 | BOXDRAW_DOUBLE_UP_RIGHT,\r | |
142 | 0xc8,\r | |
143 | L'\\'\r | |
144 | },\r | |
145 | {\r | |
146 | BOXDRAW_UP_LEFT_DOUBLE,\r | |
147 | 0xbe,\r | |
148 | L'/'\r | |
149 | },\r | |
150 | {\r | |
151 | BOXDRAW_UP_DOUBLE_LEFT,\r | |
152 | 0xbd,\r | |
153 | L'/'\r | |
154 | },\r | |
155 | {\r | |
156 | BOXDRAW_DOUBLE_UP_LEFT,\r | |
157 | 0xbc,\r | |
158 | L'/'\r | |
159 | },\r | |
160 | {\r | |
161 | BOXDRAW_VERTICAL_RIGHT_DOUBLE,\r | |
162 | 0xc6,\r | |
163 | L'|'\r | |
164 | },\r | |
165 | {\r | |
166 | BOXDRAW_VERTICAL_DOUBLE_RIGHT,\r | |
167 | 0xc7,\r | |
168 | L'|'\r | |
169 | },\r | |
170 | {\r | |
171 | BOXDRAW_DOUBLE_VERTICAL_RIGHT,\r | |
172 | 0xcc,\r | |
173 | L'|'\r | |
174 | },\r | |
175 | {\r | |
176 | BOXDRAW_VERTICAL_LEFT_DOUBLE,\r | |
177 | 0xb5,\r | |
178 | L'|'\r | |
179 | },\r | |
180 | {\r | |
181 | BOXDRAW_VERTICAL_DOUBLE_LEFT,\r | |
182 | 0xb6,\r | |
183 | L'|'\r | |
184 | },\r | |
185 | {\r | |
186 | BOXDRAW_DOUBLE_VERTICAL_LEFT,\r | |
187 | 0xb9,\r | |
188 | L'|'\r | |
189 | },\r | |
190 | {\r | |
191 | BOXDRAW_DOWN_HORIZONTAL_DOUBLE,\r | |
192 | 0xd1,\r | |
193 | L'+'\r | |
194 | },\r | |
195 | {\r | |
196 | BOXDRAW_DOWN_DOUBLE_HORIZONTAL,\r | |
197 | 0xd2,\r | |
198 | L'+'\r | |
199 | },\r | |
200 | {\r | |
201 | BOXDRAW_DOUBLE_DOWN_HORIZONTAL,\r | |
202 | 0xcb,\r | |
203 | L'+'\r | |
204 | },\r | |
205 | {\r | |
206 | BOXDRAW_UP_HORIZONTAL_DOUBLE,\r | |
207 | 0xcf,\r | |
208 | L'+'\r | |
209 | },\r | |
210 | {\r | |
211 | BOXDRAW_UP_DOUBLE_HORIZONTAL,\r | |
212 | 0xd0,\r | |
213 | L'+'\r | |
214 | },\r | |
215 | {\r | |
216 | BOXDRAW_DOUBLE_UP_HORIZONTAL,\r | |
217 | 0xca,\r | |
218 | L'+'\r | |
219 | },\r | |
220 | {\r | |
221 | BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE,\r | |
222 | 0xd8,\r | |
223 | L'+'\r | |
224 | },\r | |
225 | {\r | |
226 | BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL,\r | |
227 | 0xd7,\r | |
228 | L'+'\r | |
229 | },\r | |
230 | {\r | |
231 | BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL,\r | |
232 | 0xce,\r | |
233 | L'+'\r | |
234 | },\r | |
235 | \r | |
236 | {\r | |
237 | BLOCKELEMENT_FULL_BLOCK,\r | |
238 | 0xdb,\r | |
239 | L'*'\r | |
240 | },\r | |
241 | {\r | |
242 | BLOCKELEMENT_LIGHT_SHADE,\r | |
243 | 0xb0,\r | |
244 | L'+'\r | |
245 | },\r | |
246 | \r | |
247 | {\r | |
248 | GEOMETRICSHAPE_UP_TRIANGLE,\r | |
249 | 0x1e,\r | |
250 | L'^'\r | |
251 | },\r | |
252 | {\r | |
253 | GEOMETRICSHAPE_RIGHT_TRIANGLE,\r | |
254 | 0x10,\r | |
255 | L'>'\r | |
256 | },\r | |
257 | {\r | |
258 | GEOMETRICSHAPE_DOWN_TRIANGLE,\r | |
259 | 0x1f,\r | |
260 | L'v'\r | |
261 | },\r | |
262 | {\r | |
263 | GEOMETRICSHAPE_LEFT_TRIANGLE,\r | |
264 | 0x11,\r | |
265 | L'<'\r | |
266 | },\r | |
267 | \r | |
268 | {\r | |
269 | ARROW_LEFT,\r | |
270 | 0x3c,\r | |
271 | L'<'\r | |
272 | },\r | |
273 | \r | |
274 | {\r | |
275 | ARROW_UP,\r | |
276 | 0x18,\r | |
277 | L'^'\r | |
278 | },\r | |
279 | \r | |
280 | {\r | |
281 | ARROW_RIGHT,\r | |
282 | 0x3e,\r | |
283 | L'>'\r | |
284 | },\r | |
285 | \r | |
286 | {\r | |
287 | ARROW_DOWN,\r | |
288 | 0x19,\r | |
289 | L'v'\r | |
290 | },\r | |
291 | \r | |
292 | {\r | |
293 | 0x0000,\r | |
294 | 0x00,\r | |
295 | 0x00\r | |
296 | }\r | |
297 | };\r | |
298 | \r | |
55a1bb43 | 299 | /**\r |
300 | Entrypoint of this VGA Class Driver.\r | |
301 | \r | |
302 | This function is the entrypoint of this VGA Class Driver. It installs Driver Binding\r | |
303 | Protocols together with Component Name Protocols.\r | |
304 | \r | |
305 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
306 | @param SystemTable A pointer to the EFI System Table.\r | |
0a6f4824 | 307 | \r |
55a1bb43 | 308 | @retval EFI_SUCCESS The entry point is executed successfully.\r |
309 | \r | |
310 | **/\r | |
311 | EFI_STATUS\r | |
312 | EFIAPI\r | |
313 | InitializeVgaClass(\r | |
314 | IN EFI_HANDLE ImageHandle,\r | |
315 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
316 | )\r | |
317 | {\r | |
318 | EFI_STATUS Status;\r | |
319 | \r | |
320 | //\r | |
321 | // Install driver model protocol(s).\r | |
322 | //\r | |
323 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
324 | ImageHandle,\r | |
325 | SystemTable,\r | |
326 | &gVgaClassDriverBinding,\r | |
327 | ImageHandle,\r | |
328 | &gVgaClassComponentName,\r | |
329 | &gVgaClassComponentName2\r | |
330 | );\r | |
331 | ASSERT_EFI_ERROR (Status);\r | |
332 | \r | |
333 | return EFI_SUCCESS;\r | |
334 | }\r | |
335 | \r | |
336 | /**\r | |
337 | Internal worker function to program CRTC register via PCI I/O Protocol.\r | |
0a6f4824 | 338 | \r |
55a1bb43 | 339 | @param VgaClassDev device instance object\r |
340 | @param Address Address of register to write\r | |
341 | @param Data Data to write to register.\r | |
342 | \r | |
343 | **/\r | |
344 | VOID\r | |
345 | WriteCrtc (\r | |
346 | IN VGA_CLASS_DEV *VgaClassDev,\r | |
347 | IN UINT16 Address,\r | |
348 | IN UINT8 Data\r | |
349 | )\r | |
350 | {\r | |
351 | VgaClassDev->PciIo->Io.Write (\r | |
352 | VgaClassDev->PciIo,\r | |
353 | EfiPciIoWidthUint8,\r | |
354 | VgaClassDev->VgaMiniPort->CrtcAddressRegisterBar,\r | |
355 | VgaClassDev->VgaMiniPort->CrtcAddressRegisterOffset,\r | |
356 | 1,\r | |
357 | &Address\r | |
358 | );\r | |
359 | \r | |
360 | VgaClassDev->PciIo->Io.Write (\r | |
361 | VgaClassDev->PciIo,\r | |
362 | EfiPciIoWidthUint8,\r | |
363 | VgaClassDev->VgaMiniPort->CrtcDataRegisterBar,\r | |
364 | VgaClassDev->VgaMiniPort->CrtcDataRegisterOffset,\r | |
365 | 1,\r | |
366 | &Data\r | |
367 | );\r | |
368 | }\r | |
369 | \r | |
370 | /**\r | |
371 | Internal worker function to set cursor's position to VgaClass device\r | |
0a6f4824 | 372 | \r |
55a1bb43 | 373 | @param VgaClassDev Private data structure for device instance.\r |
374 | @param Column Colomn of position to set cursor to.\r | |
375 | @param Row Row of position to set cursor to.\r | |
376 | @param MaxColumn Max value of column.\r | |
0a6f4824 | 377 | \r |
55a1bb43 | 378 | **/\r |
e081218d | 379 | VOID\r |
380 | SetVideoCursorPosition (\r | |
381 | IN VGA_CLASS_DEV *VgaClassDev,\r | |
382 | IN UINTN Column,\r | |
383 | IN UINTN Row,\r | |
384 | IN UINTN MaxColumn\r | |
55a1bb43 | 385 | )\r |
386 | {\r | |
387 | Column = Column & 0xff;\r | |
388 | Row = Row & 0xff;\r | |
389 | MaxColumn = MaxColumn & 0xff;\r | |
e081218d | 390 | \r |
55a1bb43 | 391 | WriteCrtc (\r |
392 | VgaClassDev,\r | |
393 | CRTC_CURSOR_LOCATION_HIGH,\r | |
394 | (UINT8) ((Row * MaxColumn + Column) >> 8)\r | |
395 | );\r | |
396 | WriteCrtc (\r | |
397 | VgaClassDev,\r | |
398 | CRTC_CURSOR_LOCATION_LOW,\r | |
399 | (UINT8) ((Row * MaxColumn + Column) & 0xff)\r | |
400 | );\r | |
401 | }\r | |
402 | \r | |
403 | /**\r | |
404 | Internal worker function to detect if a Unicode char is for Box Drawing text graphics.\r | |
e081218d | 405 | \r |
55a1bb43 | 406 | @param Graphic Unicode char to test.\r |
407 | @param PcAnsi Pointer to PCANSI equivalent of Graphic for output.\r | |
408 | If NULL, then PCANSI value is not returned.\r | |
409 | @param Ascii Pointer to ASCII equivalent of Graphic for output.\r | |
410 | If NULL, then ASCII value is not returned.\r | |
411 | \r | |
412 | @retval TRUE Gpaphic is a supported Unicode Box Drawing character.\r | |
413 | @retval FALSE Gpaphic is not a supported Unicode Box Drawing character.\r | |
414 | \r | |
415 | **/\r | |
e081218d | 416 | BOOLEAN\r |
417 | LibIsValidTextGraphics (\r | |
418 | IN CHAR16 Graphic,\r | |
419 | OUT CHAR8 *PcAnsi, OPTIONAL\r | |
420 | OUT CHAR8 *Ascii OPTIONAL\r | |
55a1bb43 | 421 | )\r |
422 | {\r | |
423 | UNICODE_TO_CHAR *Table;\r | |
424 | \r | |
425 | //\r | |
426 | // Unicode drawing code charts are all in the 0x25xx range, arrows are 0x21xx.\r | |
427 | // So first filter out values not in these 2 ranges.\r | |
428 | //\r | |
429 | if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {\r | |
430 | return FALSE;\r | |
431 | }\r | |
432 | \r | |
433 | //\r | |
434 | // Search UnicodeToPcAnsiOrAscii table for matching entry.\r | |
435 | //\r | |
436 | for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) {\r | |
437 | if (Graphic == Table->Unicode) {\r | |
438 | if (PcAnsi != NULL) {\r | |
439 | *PcAnsi = Table->PcAnsi;\r | |
440 | }\r | |
441 | \r | |
442 | if (Ascii != NULL) {\r | |
443 | *Ascii = Table->Ascii;\r | |
444 | }\r | |
445 | \r | |
446 | return TRUE;\r | |
447 | }\r | |
448 | }\r | |
449 | \r | |
450 | //\r | |
451 | // If value is not found in UnicodeToPcAnsiOrAscii table, then return FALSE.\r | |
452 | //\r | |
453 | return FALSE;\r | |
454 | }\r | |
455 | \r | |
456 | /**\r | |
457 | Internal worker function to check whether input value is an ASCII char.\r | |
0a6f4824 | 458 | \r |
55a1bb43 | 459 | @param Char Character to check.\r |
460 | \r | |
461 | @retval TRUE Input value is an ASCII char.\r | |
462 | @retval FALSE Input value is not an ASCII char.\r | |
e081218d | 463 | \r |
55a1bb43 | 464 | **/\r |
e081218d | 465 | BOOLEAN\r |
466 | IsValidAscii (\r | |
55a1bb43 | 467 | IN CHAR16 Char\r |
468 | )\r | |
469 | {\r | |
470 | if ((Char >= 0x20) && (Char <= 0x7f)) {\r | |
471 | return TRUE;\r | |
472 | }\r | |
e081218d | 473 | \r |
55a1bb43 | 474 | return FALSE;\r |
475 | }\r | |
476 | \r | |
477 | /**\r | |
478 | Internal worker function to check whether input value is a unicode control char.\r | |
0a6f4824 | 479 | \r |
55a1bb43 | 480 | @param Char Character to check.\r |
481 | \r | |
482 | @retval TRUE Input value is a unicode control char.\r | |
483 | @retval FALSE Input value is not a unicode control char.\r | |
484 | \r | |
485 | **/\r | |
e081218d | 486 | BOOLEAN\r |
487 | IsValidEfiCntlChar (\r | |
55a1bb43 | 488 | IN CHAR16 Char\r |
489 | )\r | |
490 | {\r | |
491 | if (Char == CHAR_NULL || Char == CHAR_BACKSPACE || Char == CHAR_LINEFEED || Char == CHAR_CARRIAGE_RETURN) {\r | |
492 | return TRUE;\r | |
493 | }\r | |
494 | \r | |
495 | return FALSE;\r | |
496 | }\r | |
e081218d | 497 | \r |
a73d0c74 | 498 | /**\r |
55a1bb43 | 499 | Tests to see if this driver supports a given controller.\r |
a73d0c74 | 500 | \r |
55a1bb43 | 501 | This function implments EFI_DRIVER_BINDING_PROTOCOL.Supported().\r |
502 | It Checks if this driver supports the controller specified. Any Controller\r | |
503 | with VgaMiniPort Protocol and Pci I/O protocol can be supported.\r | |
504 | \r | |
505 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
a73d0c74 | 506 | @param ControllerHandle Handle of device to test\r |
507 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
508 | device to start.\r | |
509 | \r | |
55a1bb43 | 510 | @retval EFI_SUCCESS This driver supports this device.\r |
511 | @retval EFI_ALREADY_STARTED This driver is already running on this device.\r | |
512 | @retval EFI_UNSUPPORTED This driver does not support this device.\r | |
a73d0c74 | 513 | \r |
514 | **/\r | |
e081218d | 515 | EFI_STATUS\r |
516 | EFIAPI\r | |
517 | VgaClassDriverBindingSupported (\r | |
518 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
519 | IN EFI_HANDLE Controller,\r | |
55a1bb43 | 520 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r |
e081218d | 521 | )\r |
e081218d | 522 | {\r |
523 | EFI_STATUS Status;\r | |
e081218d | 524 | \r |
525 | //\r | |
55a1bb43 | 526 | // Checks if Abstraction(s) needed to perform the supported test\r |
e081218d | 527 | //\r |
528 | Status = gBS->OpenProtocol (\r | |
529 | Controller,\r | |
530 | &gEfiVgaMiniPortProtocolGuid,\r | |
55a1bb43 | 531 | NULL,\r |
e081218d | 532 | This->DriverBindingHandle,\r |
533 | Controller,\r | |
534 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r | |
535 | );\r | |
536 | if (EFI_ERROR (Status)) {\r | |
537 | return Status;\r | |
538 | }\r | |
539 | //\r | |
540 | // Open the IO Abstraction(s) needed to perform the supported test\r | |
541 | //\r | |
542 | Status = gBS->OpenProtocol (\r | |
543 | Controller,\r | |
544 | &gEfiPciIoProtocolGuid,\r | |
545 | NULL,\r | |
546 | This->DriverBindingHandle,\r | |
547 | Controller,\r | |
548 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r | |
549 | );\r | |
550 | if (EFI_ERROR (Status)) {\r | |
551 | return Status;\r | |
552 | }\r | |
553 | \r | |
554 | return Status;\r | |
555 | }\r | |
556 | \r | |
a73d0c74 | 557 | /**\r |
55a1bb43 | 558 | Starts the device controller.\r |
a73d0c74 | 559 | \r |
55a1bb43 | 560 | This function implments EFI_DRIVER_BINDING_PROTOCOL.Start().\r |
561 | It starts the device specified by Controller with the driver based on PCI I/O Protocol\r | |
562 | and VgaMiniPort Protocol. It creates context for device instance and install EFI_SIMPLE_TEXT_OUT_PROTOCOL.\r | |
563 | \r | |
564 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
a73d0c74 | 565 | @param ControllerHandle Handle of device to bind driver to\r |
566 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
567 | device to start.\r | |
568 | \r | |
55a1bb43 | 569 | @retval EFI_SUCCESS The device was started.\r |
570 | @retval other Fail to start the device.\r | |
a73d0c74 | 571 | \r |
572 | **/\r | |
e081218d | 573 | EFI_STATUS\r |
574 | EFIAPI\r | |
575 | VgaClassDriverBindingStart (\r | |
576 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
577 | IN EFI_HANDLE Controller,\r | |
55a1bb43 | 578 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r |
e081218d | 579 | )\r |
e081218d | 580 | {\r |
581 | EFI_STATUS Status;\r | |
582 | EFI_VGA_MINI_PORT_PROTOCOL *VgaMiniPort;\r | |
583 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
584 | VGA_CLASS_DEV *VgaClassPrivate;\r | |
585 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
586 | \r | |
587 | Status = gBS->HandleProtocol (\r | |
588 | Controller,\r | |
589 | &gEfiDevicePathProtocolGuid,\r | |
590 | (VOID **) &DevicePath\r | |
591 | );\r | |
592 | if (EFI_ERROR (Status)) {\r | |
593 | return Status;\r | |
594 | }\r | |
595 | //\r | |
596 | // Report that VGA Class driver is being enabled\r | |
597 | //\r | |
598 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r | |
599 | EFI_PROGRESS_CODE,\r | |
600 | EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_ENABLE,\r | |
601 | DevicePath\r | |
602 | );\r | |
603 | \r | |
604 | //\r | |
55a1bb43 | 605 | // Open the PCI I/O Protocol\r |
e081218d | 606 | //\r |
607 | Status = gBS->OpenProtocol (\r | |
608 | Controller,\r | |
609 | &gEfiPciIoProtocolGuid,\r | |
610 | (VOID **) &PciIo,\r | |
611 | This->DriverBindingHandle,\r | |
612 | Controller,\r | |
613 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
614 | );\r | |
615 | if (EFI_ERROR (Status)) {\r | |
616 | return Status;\r | |
617 | }\r | |
55a1bb43 | 618 | //\r |
619 | // Open the VGA Mini Port Protocol\r | |
620 | //\r | |
e081218d | 621 | Status = gBS->OpenProtocol (\r |
622 | Controller,\r | |
623 | &gEfiVgaMiniPortProtocolGuid,\r | |
624 | (VOID **) &VgaMiniPort,\r | |
625 | This->DriverBindingHandle,\r | |
626 | Controller,\r | |
627 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
628 | );\r | |
629 | if (EFI_ERROR (Status)) {\r | |
630 | return Status;\r | |
631 | }\r | |
632 | //\r | |
633 | // Allocate the private device structure\r | |
634 | //\r | |
55a1bb43 | 635 | VgaClassPrivate = AllocateZeroPool (sizeof (VGA_CLASS_DEV));\r |
636 | ASSERT (VgaClassPrivate != NULL);\r | |
e081218d | 637 | \r |
638 | //\r | |
639 | // Initialize the private device structure\r | |
640 | //\r | |
55a1bb43 | 641 | VgaClassPrivate->Signature = VGA_CLASS_DEV_SIGNATURE;\r |
642 | VgaClassPrivate->Handle = Controller;\r | |
e081218d | 643 | VgaClassPrivate->VgaMiniPort = VgaMiniPort;\r |
55a1bb43 | 644 | VgaClassPrivate->PciIo = PciIo;\r |
e081218d | 645 | \r |
55a1bb43 | 646 | VgaClassPrivate->SimpleTextOut.Reset = VgaClassReset;\r |
647 | VgaClassPrivate->SimpleTextOut.OutputString = VgaClassOutputString;\r | |
648 | VgaClassPrivate->SimpleTextOut.TestString = VgaClassTestString;\r | |
649 | VgaClassPrivate->SimpleTextOut.ClearScreen = VgaClassClearScreen;\r | |
650 | VgaClassPrivate->SimpleTextOut.SetAttribute = VgaClassSetAttribute;\r | |
e081218d | 651 | VgaClassPrivate->SimpleTextOut.SetCursorPosition = VgaClassSetCursorPosition;\r |
55a1bb43 | 652 | VgaClassPrivate->SimpleTextOut.EnableCursor = VgaClassEnableCursor;\r |
653 | VgaClassPrivate->SimpleTextOut.QueryMode = VgaClassQueryMode;\r | |
654 | VgaClassPrivate->SimpleTextOut.SetMode = VgaClassSetMode;\r | |
e081218d | 655 | \r |
55a1bb43 | 656 | VgaClassPrivate->SimpleTextOut.Mode = &VgaClassPrivate->SimpleTextOutputMode;\r |
657 | VgaClassPrivate->SimpleTextOutputMode.MaxMode = VgaMiniPort->MaxMode;\r | |
658 | VgaClassPrivate->DevicePath = DevicePath;\r | |
e081218d | 659 | \r |
55a1bb43 | 660 | //\r |
661 | // Initialize the VGA device.\r | |
662 | //\r | |
e081218d | 663 | Status = VgaClassPrivate->SimpleTextOut.SetAttribute (\r |
664 | &VgaClassPrivate->SimpleTextOut,\r | |
55a1bb43 | 665 | EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK)\r |
e081218d | 666 | );\r |
667 | if (EFI_ERROR (Status)) {\r | |
668 | goto ErrorExit;\r | |
669 | }\r | |
670 | \r | |
671 | Status = VgaClassPrivate->SimpleTextOut.Reset (\r | |
672 | &VgaClassPrivate->SimpleTextOut,\r | |
673 | FALSE\r | |
674 | );\r | |
675 | if (EFI_ERROR (Status)) {\r | |
676 | goto ErrorExit;\r | |
677 | }\r | |
678 | \r | |
679 | Status = VgaClassPrivate->SimpleTextOut.EnableCursor (\r | |
680 | &VgaClassPrivate->SimpleTextOut,\r | |
681 | TRUE\r | |
682 | );\r | |
683 | if (EFI_ERROR (Status)) {\r | |
684 | goto ErrorExit;\r | |
685 | }\r | |
686 | \r | |
687 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
688 | &Controller,\r | |
689 | &gEfiSimpleTextOutProtocolGuid,\r | |
690 | &VgaClassPrivate->SimpleTextOut,\r | |
691 | NULL\r | |
692 | );\r | |
693 | \r | |
694 | return Status;\r | |
695 | \r | |
696 | ErrorExit:\r | |
697 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r | |
698 | EFI_ERROR_CODE | EFI_ERROR_MINOR,\r | |
699 | EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_CONTROLLER_ERROR,\r | |
700 | DevicePath\r | |
701 | );\r | |
702 | \r | |
703 | return Status;\r | |
704 | \r | |
705 | }\r | |
706 | \r | |
a73d0c74 | 707 | /**\r |
55a1bb43 | 708 | Starts the device controller.\r |
0a6f4824 | 709 | \r |
55a1bb43 | 710 | This function implments EFI_DRIVER_BINDING_PROTOCOL.Stop().\r |
70d3fe9d | 711 | It stops this driver on Controller. Support stopping any child handles\r |
a73d0c74 | 712 | created by this driver.\r |
713 | \r | |
55a1bb43 | 714 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
715 | @param ControllerHandle A handle to the device being stopped.\r | |
716 | @param NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
717 | @param ChildHandleBuffer An array of child handles to be freed.\r | |
a73d0c74 | 718 | \r |
719 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r | |
720 | @retval other This driver was not removed from this device\r | |
721 | \r | |
722 | **/\r | |
e081218d | 723 | EFI_STATUS\r |
724 | EFIAPI\r | |
725 | VgaClassDriverBindingStop (\r | |
726 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
727 | IN EFI_HANDLE Controller,\r | |
728 | IN UINTN NumberOfChildren,\r | |
55a1bb43 | 729 | IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r |
e081218d | 730 | )\r |
e081218d | 731 | {\r |
732 | EFI_STATUS Status;\r | |
733 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;\r | |
734 | VGA_CLASS_DEV *VgaClassPrivate;\r | |
735 | \r | |
736 | Status = gBS->OpenProtocol (\r | |
737 | Controller,\r | |
738 | &gEfiSimpleTextOutProtocolGuid,\r | |
739 | (VOID **) &SimpleTextOut,\r | |
740 | This->DriverBindingHandle,\r | |
741 | Controller,\r | |
742 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
743 | );\r | |
744 | if (EFI_ERROR (Status)) {\r | |
745 | return Status;\r | |
746 | }\r | |
747 | \r | |
748 | VgaClassPrivate = VGA_CLASS_DEV_FROM_THIS (SimpleTextOut);\r | |
749 | \r | |
750 | //\r | |
751 | // Report that VGA Class driver is being disabled\r | |
752 | //\r | |
753 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r | |
754 | EFI_PROGRESS_CODE,\r | |
755 | EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_DISABLE,\r | |
756 | VgaClassPrivate->DevicePath\r | |
757 | );\r | |
758 | \r | |
759 | Status = gBS->UninstallProtocolInterface (\r | |
760 | Controller,\r | |
761 | &gEfiSimpleTextOutProtocolGuid,\r | |
762 | &VgaClassPrivate->SimpleTextOut\r | |
763 | );\r | |
764 | if (EFI_ERROR (Status)) {\r | |
765 | return Status;\r | |
766 | }\r | |
767 | //\r | |
768 | // Release PCI I/O and VGA Mini Port Protocols on the controller handle.\r | |
769 | //\r | |
770 | gBS->CloseProtocol (\r | |
55a1bb43 | 771 | Controller,\r |
772 | &gEfiPciIoProtocolGuid,\r | |
773 | This->DriverBindingHandle,\r | |
774 | Controller\r | |
775 | );\r | |
e081218d | 776 | \r |
777 | gBS->CloseProtocol (\r | |
55a1bb43 | 778 | Controller,\r |
779 | &gEfiVgaMiniPortProtocolGuid,\r | |
780 | This->DriverBindingHandle,\r | |
781 | Controller\r | |
782 | );\r | |
e081218d | 783 | \r |
55a1bb43 | 784 | FreePool (VgaClassPrivate);\r |
e081218d | 785 | \r |
786 | return EFI_SUCCESS;\r | |
787 | }\r | |
a73d0c74 | 788 | \r |
789 | /**\r | |
55a1bb43 | 790 | Resets the text output device hardware.\r |
791 | \r | |
792 | This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().\r | |
793 | It resets the text output device hardware. The cursor position is set to (0, 0),\r | |
794 | and the screen is cleared to the default background color for the output device.\r | |
0a6f4824 | 795 | \r |
55a1bb43 | 796 | @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r |
797 | @param ExtendedVerification Indicates that the driver may perform a more exhaustive\r | |
798 | verification operation of the device during reset.\r | |
799 | \r | |
800 | @retval EFI_SUCCESS The text output device was reset.\r | |
801 | @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and could not be reset.\r | |
802 | \r | |
a73d0c74 | 803 | **/\r |
e081218d | 804 | EFI_STATUS\r |
805 | EFIAPI\r | |
806 | VgaClassReset (\r | |
55a1bb43 | 807 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r |
e081218d | 808 | IN BOOLEAN ExtendedVerification\r |
809 | )\r | |
e081218d | 810 | {\r |
811 | EFI_STATUS Status;\r | |
812 | VGA_CLASS_DEV *VgaClassPrivate;\r | |
813 | \r | |
814 | VgaClassPrivate = VGA_CLASS_DEV_FROM_THIS (This);\r | |
815 | \r | |
816 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r | |
817 | EFI_PROGRESS_CODE,\r | |
818 | EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_RESET,\r | |
819 | VgaClassPrivate->DevicePath\r | |
820 | );\r | |
821 | \r | |
822 | This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));\r | |
823 | \r | |
824 | Status = This->SetMode (This, 0);\r | |
825 | if (EFI_ERROR (Status)) {\r | |
826 | return Status;\r | |
827 | }\r | |
828 | \r | |
829 | return This->ClearScreen (This);\r | |
830 | }\r | |
831 | \r | |
a73d0c74 | 832 | /**\r |
55a1bb43 | 833 | Writes a Unicode string to the output device.\r |
0a6f4824 | 834 | \r |
55a1bb43 | 835 | This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().\r |
836 | It writes a Unicode string to the output device. This is the most basic output mechanism\r | |
837 | on an output device.\r | |
838 | \r | |
839 | @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r | |
840 | @param String The Null-terminated Unicode string to be displayed on the output device(s).\r | |
841 | \r | |
842 | @retval EFI_SUCCESS The string was output to the device.\r | |
843 | @retval EFI_DEVICE_ERROR The device reported an error while attempting to output the text.\r | |
1910fbaf | 844 | @retval EFI_UNSUPPORTED The output device's mode is not currently in a defined text mode.\r |
55a1bb43 | 845 | @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the characters in\r |
846 | the Unicode string could not be rendered and were skipped.\r | |
847 | \r | |
a73d0c74 | 848 | **/\r |
e081218d | 849 | EFI_STATUS\r |
850 | EFIAPI\r | |
851 | VgaClassOutputString (\r | |
55a1bb43 | 852 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r |
853 | IN CHAR16 *String\r | |
e081218d | 854 | )\r |
e081218d | 855 | {\r |
856 | EFI_STATUS Status;\r | |
857 | VGA_CLASS_DEV *VgaClassDev;\r | |
858 | EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;\r | |
859 | UINTN MaxColumn;\r | |
860 | UINTN MaxRow;\r | |
861 | UINT32 VideoChar;\r | |
862 | CHAR8 GraphicChar;\r | |
863 | \r | |
864 | VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r | |
e081218d | 865 | Mode = This->Mode;\r |
866 | \r | |
867 | Status = This->QueryMode (\r | |
55a1bb43 | 868 | This,\r |
869 | Mode->Mode,\r | |
870 | &MaxColumn,\r | |
871 | &MaxRow\r | |
872 | );\r | |
e081218d | 873 | if (EFI_ERROR (Status)) {\r |
874 | return Status;\r | |
875 | }\r | |
876 | \r | |
55a1bb43 | 877 | //\r |
878 | // Parse each character of the string to output\r | |
879 | //\r | |
880 | for (; *String != CHAR_NULL; String++) {\r | |
e081218d | 881 | \r |
55a1bb43 | 882 | switch (*String) {\r |
e081218d | 883 | case CHAR_BACKSPACE:\r |
884 | if (Mode->CursorColumn > 0) {\r | |
885 | Mode->CursorColumn--;\r | |
886 | }\r | |
887 | break;\r | |
888 | \r | |
889 | case CHAR_LINEFEED:\r | |
890 | if (Mode->CursorRow == (INT32) (MaxRow - 1)) {\r | |
891 | //\r | |
892 | // Scroll the screen by copying the contents\r | |
893 | // of the VGA display up one line\r | |
894 | //\r | |
895 | VgaClassDev->PciIo->CopyMem (\r | |
896 | VgaClassDev->PciIo,\r | |
897 | EfiPciIoWidthUint32,\r | |
898 | VgaClassDev->VgaMiniPort->VgaMemoryBar,\r | |
899 | VgaClassDev->VgaMiniPort->VgaMemoryOffset,\r | |
900 | VgaClassDev->VgaMiniPort->VgaMemoryBar,\r | |
901 | VgaClassDev->VgaMiniPort->VgaMemoryOffset + MaxColumn * 2,\r | |
902 | ((MaxRow - 1) * MaxColumn) >> 1\r | |
903 | );\r | |
904 | \r | |
905 | //\r | |
906 | // Print Blank Line of spaces with the current color attributes\r | |
907 | //\r | |
908 | VideoChar = (Mode->Attribute << 8) | ' ';\r | |
909 | VideoChar = (VideoChar << 16) | VideoChar;\r | |
910 | VgaClassDev->PciIo->Mem.Write (\r | |
911 | VgaClassDev->PciIo,\r | |
912 | EfiPciIoWidthFillUint32,\r | |
913 | VgaClassDev->VgaMiniPort->VgaMemoryBar,\r | |
914 | VgaClassDev->VgaMiniPort->VgaMemoryOffset + (MaxRow - 1) * MaxColumn * 2,\r | |
915 | MaxColumn >> 1,\r | |
916 | &VideoChar\r | |
917 | );\r | |
918 | }\r | |
919 | \r | |
920 | if (Mode->CursorRow < (INT32) (MaxRow - 1)) {\r | |
921 | Mode->CursorRow++;\r | |
922 | }\r | |
923 | break;\r | |
924 | \r | |
925 | case CHAR_CARRIAGE_RETURN:\r | |
926 | Mode->CursorColumn = 0;\r | |
927 | break;\r | |
928 | \r | |
929 | default:\r | |
55a1bb43 | 930 | if (!LibIsValidTextGraphics (*String, &GraphicChar, NULL)) {\r |
e081218d | 931 | //\r |
55a1bb43 | 932 | // If this character is not ,Box Drawing text graphics, then convert it to ASCII.\r |
e081218d | 933 | //\r |
55a1bb43 | 934 | GraphicChar = (CHAR8) *String;\r |
e081218d | 935 | if (!IsValidAscii (GraphicChar)) {\r |
936 | //\r | |
55a1bb43 | 937 | // If not valid ASCII char, convert it to "?"\r |
e081218d | 938 | //\r |
939 | GraphicChar = '?';\r | |
940 | }\r | |
941 | }\r | |
942 | \r | |
943 | VideoChar = (Mode->Attribute << 8) | GraphicChar;\r | |
944 | VgaClassDev->PciIo->Mem.Write (\r | |
945 | VgaClassDev->PciIo,\r | |
946 | EfiPciIoWidthUint16,\r | |
947 | VgaClassDev->VgaMiniPort->VgaMemoryBar,\r | |
948 | VgaClassDev->VgaMiniPort->VgaMemoryOffset + ((Mode->CursorRow * MaxColumn + Mode->CursorColumn) * 2),\r | |
949 | 1,\r | |
950 | &VideoChar\r | |
951 | );\r | |
952 | \r | |
953 | if (Mode->CursorColumn >= (INT32) (MaxColumn - 1)) {\r | |
954 | This->OutputString (This, CrLfString);\r | |
955 | } else {\r | |
956 | Mode->CursorColumn++;\r | |
957 | }\r | |
958 | break;\r | |
959 | }\r | |
960 | }\r | |
961 | \r | |
962 | SetVideoCursorPosition (\r | |
963 | VgaClassDev,\r | |
964 | (UINTN) Mode->CursorColumn,\r | |
965 | (UINTN) Mode->CursorRow,\r | |
966 | MaxColumn\r | |
967 | );\r | |
968 | \r | |
969 | return EFI_SUCCESS;\r | |
970 | }\r | |
971 | \r | |
a73d0c74 | 972 | /**\r |
55a1bb43 | 973 | Verifies that all characters in a Unicode string can be output to the target device.\r |
0a6f4824 | 974 | \r |
55a1bb43 | 975 | This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().\r |
976 | It verifies that all characters in a Unicode string can be output to the target device.\r | |
977 | \r | |
978 | @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r | |
979 | @param String The Null-terminated Unicode string to be examined for the output device(s).\r | |
980 | \r | |
981 | @retval EFI_SUCCESS The device(s) are capable of rendering the output string.\r | |
982 | @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered by\r | |
983 | one or more of the output devices mapped by the EFI handle.\r | |
984 | \r | |
a73d0c74 | 985 | **/\r |
e081218d | 986 | EFI_STATUS\r |
987 | EFIAPI\r | |
988 | VgaClassTestString (\r | |
55a1bb43 | 989 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r |
990 | IN CHAR16 *String\r | |
e081218d | 991 | )\r |
e081218d | 992 | {\r |
55a1bb43 | 993 | while (*String != CHAR_NULL) {\r |
994 | if (!(IsValidAscii (*String) || IsValidEfiCntlChar (*String) || LibIsValidTextGraphics (*String, NULL, NULL))) {\r | |
e081218d | 995 | return EFI_UNSUPPORTED;\r |
996 | }\r | |
997 | \r | |
55a1bb43 | 998 | String++;\r |
e081218d | 999 | }\r |
1000 | \r | |
1001 | return EFI_SUCCESS;\r | |
1002 | }\r | |
1003 | \r | |
a73d0c74 | 1004 | /**\r |
55a1bb43 | 1005 | Clears the output device(s) display to the currently selected background color.\r |
0a6f4824 | 1006 | \r |
55a1bb43 | 1007 | This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().\r |
1008 | The ClearScreen() function clears the output device(s) display to the currently\r | |
1009 | selected background color. The cursor position is set to (0, 0).\r | |
1010 | \r | |
1011 | @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r | |
0a6f4824 | 1012 | \r |
55a1bb43 | 1013 | @retval EFI_SUCESS The operation completed successfully.\r |
1014 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r | |
1015 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode.\r | |
1016 | \r | |
a73d0c74 | 1017 | **/\r |
e081218d | 1018 | EFI_STATUS\r |
1019 | EFIAPI\r | |
1020 | VgaClassClearScreen (\r | |
1021 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r | |
1022 | )\r | |
e081218d | 1023 | {\r |
1024 | EFI_STATUS Status;\r | |
1025 | VGA_CLASS_DEV *VgaClassDev;\r | |
1026 | UINTN MaxRow;\r | |
1027 | UINTN MaxColumn;\r | |
1028 | UINT32 VideoChar;\r | |
1029 | \r | |
1030 | VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r | |
1031 | \r | |
1032 | Status = This->QueryMode (\r | |
55a1bb43 | 1033 | This,\r |
1034 | This->Mode->Mode,\r | |
1035 | &MaxColumn,\r | |
1036 | &MaxRow\r | |
1037 | );\r | |
e081218d | 1038 | if (EFI_ERROR (Status)) {\r |
1039 | return Status;\r | |
1040 | }\r | |
1041 | \r | |
1042 | VideoChar = (This->Mode->Attribute << 8) | ' ';\r | |
1043 | VideoChar = (VideoChar << 16) | VideoChar;\r | |
1044 | VgaClassDev->PciIo->Mem.Write (\r | |
1045 | VgaClassDev->PciIo,\r | |
1046 | EfiPciIoWidthFillUint32,\r | |
1047 | VgaClassDev->VgaMiniPort->VgaMemoryBar,\r | |
1048 | VgaClassDev->VgaMiniPort->VgaMemoryOffset,\r | |
1049 | (MaxRow * MaxColumn) >> 1,\r | |
1050 | &VideoChar\r | |
1051 | );\r | |
1052 | \r | |
1053 | This->SetCursorPosition (This, 0, 0);\r | |
1054 | \r | |
1055 | return EFI_SUCCESS;\r | |
1056 | }\r | |
1057 | \r | |
a73d0c74 | 1058 | /**\r |
55a1bb43 | 1059 | Sets the background and foreground colors for theOutputString() and ClearScreen() functions.\r |
0a6f4824 | 1060 | \r |
55a1bb43 | 1061 | This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().\r |
1062 | It sets the background and foreground colors for the OutputString() and ClearScreen() functions.\r | |
1063 | The color mask can be set even when the device is in an invalid text mode.\r | |
1064 | Devices supporting a different number of text colors are required to emulate the above colors\r | |
689b2d72 | 1065 | to the best of the device's capabilities.\r |
55a1bb43 | 1066 | \r |
1067 | @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r | |
1068 | @param Attribute The attribute to set.\r | |
1069 | Bits 0..3 are the foreground color,\r | |
1070 | and bits 4..6 are the background color.\r | |
0a6f4824 | 1071 | \r |
55a1bb43 | 1072 | @retval EFI_SUCCESS The requested attributes were set.\r |
1073 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r | |
1074 | \r | |
a73d0c74 | 1075 | **/\r |
e081218d | 1076 | EFI_STATUS\r |
1077 | EFIAPI\r | |
1078 | VgaClassSetAttribute (\r | |
55a1bb43 | 1079 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r |
e081218d | 1080 | IN UINTN Attribute\r |
1081 | )\r | |
e081218d | 1082 | {\r |
1083 | if (Attribute <= EFI_MAX_ATTRIBUTE) {\r | |
1084 | This->Mode->Attribute = (INT32) Attribute;\r | |
1085 | return EFI_SUCCESS;\r | |
1086 | }\r | |
1087 | \r | |
1088 | return EFI_UNSUPPORTED;\r | |
1089 | }\r | |
1090 | \r | |
a73d0c74 | 1091 | /**\r |
55a1bb43 | 1092 | Sets the current coordinates of the cursor position.\r |
0a6f4824 | 1093 | \r |
55a1bb43 | 1094 | This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().\r |
1095 | It sets the current coordinates of the cursor position.\r | |
1096 | The upper left corner of the screen is defined as coordinate (0, 0).\r | |
0a6f4824 | 1097 | \r |
55a1bb43 | 1098 | @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r |
1099 | @param Column Column of position to set the cursor to.\r | |
1100 | @param Row Row of position to set the cursor to.\r | |
0a6f4824 | 1101 | \r |
55a1bb43 | 1102 | @retval EFI_SUCCESS The operation completed successfully.\r |
1103 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r | |
1104 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the cursor\r | |
1105 | position is invalid for the current mode.\r | |
1106 | \r | |
a73d0c74 | 1107 | **/\r |
e081218d | 1108 | EFI_STATUS\r |
1109 | EFIAPI\r | |
1110 | VgaClassSetCursorPosition (\r | |
55a1bb43 | 1111 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r |
e081218d | 1112 | IN UINTN Column,\r |
1113 | IN UINTN Row\r | |
1114 | )\r | |
e081218d | 1115 | {\r |
1116 | EFI_STATUS Status;\r | |
1117 | VGA_CLASS_DEV *VgaClassDev;\r | |
1118 | UINTN MaxColumn;\r | |
1119 | UINTN MaxRow;\r | |
1120 | \r | |
1121 | VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r | |
1122 | \r | |
1123 | Status = This->QueryMode (\r | |
55a1bb43 | 1124 | This,\r |
1125 | This->Mode->Mode,\r | |
1126 | &MaxColumn,\r | |
1127 | &MaxRow\r | |
1128 | );\r | |
e081218d | 1129 | if (EFI_ERROR (Status)) {\r |
1130 | return Status;\r | |
1131 | }\r | |
1132 | \r | |
1133 | if (Column >= MaxColumn || Row >= MaxRow) {\r | |
1134 | return EFI_UNSUPPORTED;\r | |
1135 | }\r | |
1136 | \r | |
1137 | SetVideoCursorPosition (VgaClassDev, Column, Row, MaxColumn);\r | |
1138 | \r | |
1139 | This->Mode->CursorColumn = (INT32) Column;\r | |
1140 | This->Mode->CursorRow = (INT32) Row;\r | |
1141 | \r | |
1142 | return EFI_SUCCESS;\r | |
1143 | }\r | |
1144 | \r | |
a73d0c74 | 1145 | /**\r |
55a1bb43 | 1146 | Makes the cursor visible or invisible.\r |
0a6f4824 | 1147 | \r |
55a1bb43 | 1148 | This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.EnableCursor().\r |
1149 | It makes the cursor visible or invisible.\r | |
1150 | \r | |
1151 | @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r | |
1152 | @param Visible If TRUE, the cursor is set to be visible.\r | |
1153 | If FALSE, the cursor is set to be invisible.\r | |
0a6f4824 | 1154 | \r |
55a1bb43 | 1155 | @retval EFI_SUCESS The operation completed successfully.\r |
1156 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request or the\r | |
1157 | device does not support changing the cursor mode.\r | |
1158 | @retval EFI_UNSUPPORTED The output device does not support visibility control of the cursor.\r | |
1159 | \r | |
a73d0c74 | 1160 | **/\r |
e081218d | 1161 | EFI_STATUS\r |
1162 | EFIAPI\r | |
1163 | VgaClassEnableCursor (\r | |
55a1bb43 | 1164 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r |
e081218d | 1165 | IN BOOLEAN Visible\r |
1166 | )\r | |
e081218d | 1167 | {\r |
1168 | VGA_CLASS_DEV *VgaClassDev;\r | |
1169 | \r | |
1170 | VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r | |
1171 | if (Visible) {\r | |
55a1bb43 | 1172 | if (This->Mode->Mode == 1) {\r |
1173 | //\r | |
1174 | // 80 * 50\r | |
1175 | //\r | |
e081218d | 1176 | WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x06);\r |
1177 | WriteCrtc (VgaClassDev, CRTC_CURSOR_END, 0x07);\r | |
55a1bb43 | 1178 | } else {\r |
1179 | //\r | |
1180 | // 80 * 25\r | |
1181 | //\r | |
e081218d | 1182 | WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x0e);\r |
1183 | WriteCrtc (VgaClassDev, CRTC_CURSOR_END, 0x0f);\r | |
e081218d | 1184 | }\r |
1185 | } else {\r | |
1186 | WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x20);\r | |
1187 | }\r | |
1188 | \r | |
1189 | This->Mode->CursorVisible = Visible;\r | |
1190 | return EFI_SUCCESS;\r | |
1191 | }\r | |
1192 | \r | |
a73d0c74 | 1193 | /**\r |
55a1bb43 | 1194 | Returns information for an available text mode that the output device(s) supports.\r |
1195 | \r | |
1196 | This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r | |
1197 | It returns information for an available text mode that the output device(s) supports.\r | |
1198 | It is required that all output devices support at least 80x25 text mode. This mode is defined to be mode 0.\r | |
1199 | If the output devices support 80x50, that is defined to be mode 1.\r | |
1200 | \r | |
1201 | @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r | |
1202 | @param ModeNumber The mode number to return information on.\r | |
1203 | @param Columns Columen in current mode number\r | |
1204 | @param Rows Row in current mode number.\r | |
0a6f4824 | 1205 | \r |
55a1bb43 | 1206 | @retval EFI_SUCCESS The requested mode information was returned.\r |
1207 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r | |
1208 | @retval EFI_UNSUPPORTED The mode number was not valid.\r | |
1209 | \r | |
a73d0c74 | 1210 | **/\r |
e081218d | 1211 | EFI_STATUS\r |
1212 | EFIAPI\r | |
1213 | VgaClassQueryMode (\r | |
55a1bb43 | 1214 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r |
e081218d | 1215 | IN UINTN ModeNumber,\r |
1216 | OUT UINTN *Columns,\r | |
1217 | OUT UINTN *Rows\r | |
1218 | )\r | |
e081218d | 1219 | {\r |
1220 | if ((INT32) ModeNumber >= This->Mode->MaxMode) {\r | |
1221 | *Columns = 0;\r | |
1222 | *Rows = 0;\r | |
1223 | return EFI_UNSUPPORTED;\r | |
1224 | }\r | |
1225 | \r | |
1226 | switch (ModeNumber) {\r | |
1227 | case 0:\r | |
1228 | *Columns = 80;\r | |
1229 | *Rows = 25;\r | |
1230 | break;\r | |
1231 | \r | |
1232 | case 1:\r | |
1233 | *Columns = 80;\r | |
1234 | *Rows = 50;\r | |
1235 | break;\r | |
1236 | \r | |
1237 | default:\r | |
1238 | *Columns = 0;\r | |
1239 | *Rows = 0;\r | |
1240 | return EFI_UNSUPPORTED;\r | |
1241 | }\r | |
1242 | \r | |
1243 | return EFI_SUCCESS;\r | |
1244 | }\r | |
1245 | \r | |
a73d0c74 | 1246 | /**\r |
55a1bb43 | 1247 | Sets the output device(s) to a specified mode.\r |
0a6f4824 | 1248 | \r |
55a1bb43 | 1249 | This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r |
1250 | It sets the output device(s) to the requested mode.\r | |
1251 | On success the device is in the geometry for the requested mode,\r | |
1252 | and the device has been cleared to the current background color with the cursor at (0,0).\r | |
1253 | \r | |
1254 | @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r | |
1255 | @param ModeNumber The text mode to set.\r | |
0a6f4824 | 1256 | \r |
55a1bb43 | 1257 | @retval EFI_SUCCESS The requested text mode was set.\r |
1258 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r | |
1259 | @retval EFI_UNSUPPORTED The mode number was not valid.\r | |
1260 | \r | |
a73d0c74 | 1261 | **/\r |
e081218d | 1262 | EFI_STATUS\r |
1263 | EFIAPI\r | |
1264 | VgaClassSetMode (\r | |
55a1bb43 | 1265 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r |
e081218d | 1266 | IN UINTN ModeNumber\r |
1267 | )\r | |
e081218d | 1268 | {\r |
e081218d | 1269 | VGA_CLASS_DEV *VgaClassDev;\r |
1270 | \r | |
1271 | VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r | |
1272 | \r | |
1273 | if ((INT32) ModeNumber >= This->Mode->MaxMode) {\r | |
1274 | return EFI_UNSUPPORTED;\r | |
1275 | }\r | |
1276 | \r | |
1277 | This->ClearScreen (This);\r | |
1278 | \r | |
1279 | This->Mode->Mode = (INT32) ModeNumber;\r | |
1280 | \r | |
55a1bb43 | 1281 | return VgaClassDev->VgaMiniPort->SetMode (VgaClassDev->VgaMiniPort, ModeNumber);\r |
e081218d | 1282 | }\r |