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