]> git.proxmox.com Git - mirror_edk2.git/blob - OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c
a2488472739b9258274238dbcc7c65914a0e5619
[mirror_edk2.git] / OptionRomPkg / CirrusLogic5430Dxe / CirrusLogic5430.c
1 /** @file
2 Cirrus Logic 5430 Controller Driver.
3 This driver is a sample implementation of the UGA Draw and Graphics Output
4 Protocols for the Cirrus Logic 5430 family of PCI video controllers.
5 This driver is only usable in the EFI pre-boot environment.
6 This sample is intended to show how the UGA Draw and Graphics output Protocol
7 is able to function.
8 The UGA I/O Protocol is not implemented in this sample.
9 A fully compliant EFI UGA driver requires both
10 the UGA Draw and the UGA I/O Protocol. Please refer to Microsoft's
11 documentation on UGA for details on how to write a UGA driver that is able
12 to function both in the EFI pre-boot environment and from the OS runtime.
13
14 Copyright (c) 2006, Intel Corporation
15 All rights reserved. This program and the accompanying materials
16 are licensed and made available under the terms and conditions of the BSD License
17 which accompanies this distribution. The full text of the license may be found at
18 http://opensource.org/licenses/bsd-license.php
19
20 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
21 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22
23 **/
24
25 //
26 // Cirrus Logic 5430 Controller Driver
27 //
28 #include "CirrusLogic5430.h"
29
30 EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding = {
31 CirrusLogic5430ControllerDriverSupported,
32 CirrusLogic5430ControllerDriverStart,
33 CirrusLogic5430ControllerDriverStop,
34 0x10,
35 NULL,
36 NULL
37 };
38
39 ///
40 /// Generic Attribute Controller Register Settings
41 ///
42 UINT8 AttributeController[21] = {
43 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
44 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
45 0x41, 0x00, 0x0F, 0x00, 0x00
46 };
47
48 ///
49 /// Generic Graphics Controller Register Settings
50 ///
51 UINT8 GraphicsController[9] = {
52 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF
53 };
54
55 //
56 // 640 x 480 x 256 color @ 60 Hertz
57 //
58 UINT8 Crtc_640_480_256_60[28] = {
59 0x5d, 0x4f, 0x50, 0x82, 0x53, 0x9f, 0x00, 0x3e,
60 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 0xe1, 0x83, 0xdf, 0x50, 0x00, 0xe7, 0x04, 0xe3,
62 0xff, 0x00, 0x00, 0x22
63 };
64
65 UINT16 Seq_640_480_256_60[15] = {
66 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
67 0x5b0c, 0x450d, 0x7e0e, 0x2b1b, 0x2f1c, 0x301d, 0x331e
68 };
69
70 //
71 // 800 x 600 x 256 color @ 60 Hertz
72 //
73 UINT8 Crtc_800_600_256_60[28] = {
74 0x7F, 0x63, 0x64, 0x80, 0x6B, 0x1B, 0x72, 0xF0,
75 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76 0x58, 0x8C, 0x57, 0x64, 0x00, 0x5F, 0x91, 0xE3,
77 0xFF, 0x00, 0x00, 0x22
78 };
79
80 UINT16 Seq_800_600_256_60[15] = {
81 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
82 0x5b0c, 0x450d, 0x510e, 0x2b1b, 0x2f1c, 0x301d, 0x3a1e
83 };
84
85 //
86 // 1024 x 768 x 256 color @ 60 Hertz
87 //
88 UINT8 Crtc_1024_768_256_60[28] = {
89 0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD,
90 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
91 0x02, 0x88, 0xFF, 0x80, 0x00, 0x00, 0x24, 0xE3,
92 0xFF, 0x4A, 0x00, 0x22
93 };
94
95 UINT16 Seq_1024_768_256_60[15] = {
96 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
97 0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e
98 };
99
100 ///
101 /// Table of supported video modes
102 ///
103 CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes[] = {
104 { 640, 480, 8, 60, Crtc_640_480_256_60, Seq_640_480_256_60, 0xe3 },
105 { 800, 600, 8, 60, Crtc_800_600_256_60, Seq_800_600_256_60, 0xef },
106 { 1024, 768, 8, 60, Crtc_1024_768_256_60, Seq_1024_768_256_60, 0xef }
107 };
108
109
110 /**
111 CirrusLogic5430ControllerDriverSupported
112
113 TODO: This - add argument and description to function comment
114 TODO: Controller - add argument and description to function comment
115 TODO: RemainingDevicePath - add argument and description to function comment
116 **/
117 EFI_STATUS
118 EFIAPI
119 CirrusLogic5430ControllerDriverSupported (
120 IN EFI_DRIVER_BINDING_PROTOCOL *This,
121 IN EFI_HANDLE Controller,
122 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
123 )
124 {
125 EFI_STATUS Status;
126 EFI_PCI_IO_PROTOCOL *PciIo;
127 PCI_TYPE00 Pci;
128
129 //
130 // Open the PCI I/O Protocol
131 //
132 Status = gBS->OpenProtocol (
133 Controller,
134 &gEfiPciIoProtocolGuid,
135 (VOID **) &PciIo,
136 This->DriverBindingHandle,
137 Controller,
138 EFI_OPEN_PROTOCOL_BY_DRIVER
139 );
140 if (EFI_ERROR (Status)) {
141 return Status;
142 }
143
144 //
145 // Read the PCI Configuration Header from the PCI Device
146 //
147 Status = PciIo->Pci.Read (
148 PciIo,
149 EfiPciIoWidthUint32,
150 0,
151 sizeof (Pci) / sizeof (UINT32),
152 &Pci
153 );
154 if (EFI_ERROR (Status)) {
155 goto Done;
156 }
157
158 Status = EFI_UNSUPPORTED;
159 //
160 // See if the I/O enable is on. Most systems only allow one VGA device to be turned on
161 // at a time, so see if this is one that is turned on.
162 //
163 // if (((Pci.Hdr.Command & 0x01) == 0x01)) {
164 //
165 // See if this is a Cirrus Logic PCI controller
166 //
167 if (Pci.Hdr.VendorId == CIRRUS_LOGIC_VENDOR_ID) {
168 //
169 // See if this is a 5430 or a 5446 PCI controller
170 //
171 if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5430_DEVICE_ID) {
172 Status = EFI_SUCCESS;
173 }
174
175 if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID) {
176 Status = EFI_SUCCESS;
177 }
178
179 if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5446_DEVICE_ID) {
180 Status = EFI_SUCCESS;
181 }
182 }
183
184 Done:
185 //
186 // Close the PCI I/O Protocol
187 //
188 gBS->CloseProtocol (
189 Controller,
190 &gEfiPciIoProtocolGuid,
191 This->DriverBindingHandle,
192 Controller
193 );
194
195 return Status;
196 }
197
198 /**
199 CirrusLogic5430ControllerDriverStart
200
201 TODO: This - add argument and description to function comment
202 TODO: Controller - add argument and description to function comment
203 TODO: RemainingDevicePath - add argument and description to function comment
204 **/
205 EFI_STATUS
206 EFIAPI
207 CirrusLogic5430ControllerDriverStart (
208 IN EFI_DRIVER_BINDING_PROTOCOL *This,
209 IN EFI_HANDLE Controller,
210 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
211 )
212 {
213 EFI_STATUS Status;
214 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;
215 BOOLEAN PciAttributesSaved;
216 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
217 ACPI_ADR_DEVICE_PATH AcpiDeviceNode;
218
219 PciAttributesSaved = FALSE;
220 //
221 // Allocate Private context data for UGA Draw inteface.
222 //
223 Private = AllocateZeroPool (sizeof (CIRRUS_LOGIC_5430_PRIVATE_DATA));
224 if (Private == NULL) {
225 Status = EFI_OUT_OF_RESOURCES;
226 goto Error;
227 }
228
229 //
230 // Set up context record
231 //
232 Private->Signature = CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE;
233 Private->Handle = NULL;
234
235 //
236 // Open PCI I/O Protocol
237 //
238 Status = gBS->OpenProtocol (
239 Controller,
240 &gEfiPciIoProtocolGuid,
241 (VOID **) &Private->PciIo,
242 This->DriverBindingHandle,
243 Controller,
244 EFI_OPEN_PROTOCOL_BY_DRIVER
245 );
246 if (EFI_ERROR (Status)) {
247 goto Error;
248 }
249
250 //
251 // Save original PCI attributes
252 //
253 Status = Private->PciIo->Attributes (
254 Private->PciIo,
255 EfiPciIoAttributeOperationGet,
256 0,
257 &Private->OriginalPciAttributes
258 );
259
260 if (EFI_ERROR (Status)) {
261 goto Error;
262 }
263 PciAttributesSaved = TRUE;
264
265 Status = Private->PciIo->Attributes (
266 Private->PciIo,
267 EfiPciIoAttributeOperationEnable,
268 EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,
269 NULL
270 );
271 if (EFI_ERROR (Status)) {
272 goto Error;
273 }
274
275 //
276 // Get ParentDevicePath
277 //
278 Status = gBS->HandleProtocol (
279 Controller,
280 &gEfiDevicePathProtocolGuid,
281 (VOID **) &ParentDevicePath
282 );
283 if (EFI_ERROR (Status)) {
284 goto Error;
285 }
286
287 if (FeaturePcdGet (PcdSupportGop)) {
288 //
289 // Set Gop Device Path
290 //
291 if (RemainingDevicePath == NULL) {
292 ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH));
293 AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH;
294 AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;
295 AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);
296 SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof (ACPI_ADR_DEVICE_PATH));
297
298 Private->GopDevicePath = AppendDevicePathNode (
299 ParentDevicePath,
300 (EFI_DEVICE_PATH_PROTOCOL *) &AcpiDeviceNode
301 );
302 } else {
303 Private->GopDevicePath = AppendDevicePathNode (ParentDevicePath, RemainingDevicePath);
304 }
305
306 //
307 // Creat child handle and device path protocol firstly
308 //
309 Private->Handle = NULL;
310 Status = gBS->InstallMultipleProtocolInterfaces (
311 &Private->Handle,
312 &gEfiDevicePathProtocolGuid,
313 Private->GopDevicePath,
314 NULL
315 );
316 }
317
318 //
319 // Construct video mode buffer
320 //
321 Status = CirrusLogic5430VideoModeSetup (Private);
322 if (EFI_ERROR (Status)) {
323 goto Error;
324 }
325
326 if (FeaturePcdGet (PcdSupportUga)) {
327 //
328 // Start the UGA Draw software stack.
329 //
330 Status = CirrusLogic5430UgaDrawConstructor (Private);
331 ASSERT_EFI_ERROR (Status);
332
333 Private->UgaDevicePath = ParentDevicePath;
334 Status = gBS->InstallMultipleProtocolInterfaces (
335 &Controller,
336 &gEfiUgaDrawProtocolGuid,
337 &Private->UgaDraw,
338 &gEfiDevicePathProtocolGuid,
339 Private->UgaDevicePath,
340 NULL
341 );
342
343 } else if (FeaturePcdGet (PcdSupportGop)) {
344 //
345 // Start the GOP software stack.
346 //
347 Status = CirrusLogic5430GraphicsOutputConstructor (Private);
348 ASSERT_EFI_ERROR (Status);
349
350 Status = gBS->InstallMultipleProtocolInterfaces (
351 &Private->Handle,
352 &gEfiGraphicsOutputProtocolGuid,
353 &Private->GraphicsOutput,
354 &gEfiEdidDiscoveredProtocolGuid,
355 &Private->EdidDiscovered,
356 &gEfiEdidActiveProtocolGuid,
357 &Private->EdidActive,
358 NULL
359 );
360
361 } else {
362 //
363 // This driver must support eithor GOP or UGA or both.
364 //
365 ASSERT (FALSE);
366 Status = EFI_UNSUPPORTED;
367 }
368
369
370 Error:
371 if (EFI_ERROR (Status)) {
372 if (Private) {
373 if (Private->PciIo) {
374 if (PciAttributesSaved == TRUE) {
375 //
376 // Restore original PCI attributes
377 //
378 Private->PciIo->Attributes (
379 Private->PciIo,
380 EfiPciIoAttributeOperationSet,
381 Private->OriginalPciAttributes,
382 NULL
383 );
384 }
385 //
386 // Close the PCI I/O Protocol
387 //
388 gBS->CloseProtocol (
389 Private->Handle,
390 &gEfiPciIoProtocolGuid,
391 This->DriverBindingHandle,
392 Private->Handle
393 );
394 }
395
396 gBS->FreePool (Private);
397 }
398 }
399
400 return Status;
401 }
402
403 /**
404 CirrusLogic5430ControllerDriverStop
405
406 TODO: This - add argument and description to function comment
407 TODO: Controller - add argument and description to function comment
408 TODO: NumberOfChildren - add argument and description to function comment
409 TODO: ChildHandleBuffer - add argument and description to function comment
410 TODO: EFI_SUCCESS - add return value to function comment
411 **/
412 EFI_STATUS
413 EFIAPI
414 CirrusLogic5430ControllerDriverStop (
415 IN EFI_DRIVER_BINDING_PROTOCOL *This,
416 IN EFI_HANDLE Controller,
417 IN UINTN NumberOfChildren,
418 IN EFI_HANDLE *ChildHandleBuffer
419 )
420 {
421 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
422 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
423
424 EFI_STATUS Status;
425 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;
426
427 if (FeaturePcdGet (PcdSupportUga)) {
428 Status = gBS->OpenProtocol (
429 Controller,
430 &gEfiUgaDrawProtocolGuid,
431 (VOID **) &UgaDraw,
432 This->DriverBindingHandle,
433 Controller,
434 EFI_OPEN_PROTOCOL_GET_PROTOCOL
435 );
436 if (EFI_ERROR (Status)) {
437 return Status;
438 }
439 //
440 // Get our private context information
441 //
442 Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (UgaDraw);
443 CirrusLogic5430UgaDrawDestructor (Private);
444
445 if (FeaturePcdGet (PcdSupportGop)) {
446 CirrusLogic5430GraphicsOutputDestructor (Private);
447 //
448 // Remove the UGA and GOP protocol interface from the system
449 //
450 Status = gBS->UninstallMultipleProtocolInterfaces (
451 Private->Handle,
452 &gEfiUgaDrawProtocolGuid,
453 &Private->UgaDraw,
454 &gEfiGraphicsOutputProtocolGuid,
455 &Private->GraphicsOutput,
456 NULL
457 );
458 } else {
459 //
460 // Remove the UGA Draw interface from the system
461 //
462 Status = gBS->UninstallMultipleProtocolInterfaces (
463 Private->Handle,
464 &gEfiUgaDrawProtocolGuid,
465 &Private->UgaDraw,
466 NULL
467 );
468 }
469 } else {
470 Status = gBS->OpenProtocol (
471 Controller,
472 &gEfiGraphicsOutputProtocolGuid,
473 (VOID **) &GraphicsOutput,
474 This->DriverBindingHandle,
475 Controller,
476 EFI_OPEN_PROTOCOL_GET_PROTOCOL
477 );
478 if (EFI_ERROR (Status)) {
479 return Status;
480 }
481
482 //
483 // Get our private context information
484 //
485 Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);
486
487 CirrusLogic5430GraphicsOutputDestructor (Private);
488 //
489 // Remove the GOP protocol interface from the system
490 //
491 Status = gBS->UninstallMultipleProtocolInterfaces (
492 Private->Handle,
493 &gEfiUgaDrawProtocolGuid,
494 &Private->UgaDraw,
495 &gEfiGraphicsOutputProtocolGuid,
496 &Private->GraphicsOutput,
497 NULL
498 );
499 }
500
501 if (EFI_ERROR (Status)) {
502 return Status;
503 }
504
505 //
506 // Restore original PCI attributes
507 //
508 Private->PciIo->Attributes (
509 Private->PciIo,
510 EfiPciIoAttributeOperationSet,
511 Private->OriginalPciAttributes,
512 NULL
513 );
514
515 //
516 // Close the PCI I/O Protocol
517 //
518 gBS->CloseProtocol (
519 Controller,
520 &gEfiPciIoProtocolGuid,
521 This->DriverBindingHandle,
522 Controller
523 );
524
525 //
526 // Free our instance data
527 //
528 gBS->FreePool (Private);
529
530 return EFI_SUCCESS;
531 }
532
533 /**
534 CirrusLogic5430UgaDrawDestructor
535
536 TODO: Private - add argument and description to function comment
537 TODO: EFI_SUCCESS - add return value to function comment
538 **/
539 EFI_STATUS
540 CirrusLogic5430UgaDrawDestructor (
541 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
542 )
543 {
544 return EFI_SUCCESS;
545 }
546
547 /**
548 TODO: Add function description
549
550 @param Private TODO: add argument description
551 @param Address TODO: add argument description
552 @param Data TODO: add argument description
553
554 TODO: add return values
555
556 **/
557 VOID
558 outb (
559 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
560 UINTN Address,
561 UINT8 Data
562 )
563 {
564 Private->PciIo->Io.Write (
565 Private->PciIo,
566 EfiPciIoWidthUint8,
567 EFI_PCI_IO_PASS_THROUGH_BAR,
568 Address,
569 1,
570 &Data
571 );
572 }
573
574 /**
575 TODO: Add function description
576
577 @param Private TODO: add argument description
578 @param Address TODO: add argument description
579 @param Data TODO: add argument description
580
581 TODO: add return values
582
583 **/
584 VOID
585 outw (
586 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
587 UINTN Address,
588 UINT16 Data
589 )
590 {
591 Private->PciIo->Io.Write (
592 Private->PciIo,
593 EfiPciIoWidthUint16,
594 EFI_PCI_IO_PASS_THROUGH_BAR,
595 Address,
596 1,
597 &Data
598 );
599 }
600
601 /**
602 TODO: Add function description
603
604 @param Private TODO: add argument description
605 @param Address TODO: add argument description
606
607 TODO: add return values
608
609 **/
610 UINT8
611 inb (
612 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
613 UINTN Address
614 )
615 {
616 UINT8 Data;
617
618 Private->PciIo->Io.Read (
619 Private->PciIo,
620 EfiPciIoWidthUint8,
621 EFI_PCI_IO_PASS_THROUGH_BAR,
622 Address,
623 1,
624 &Data
625 );
626 return Data;
627 }
628
629 /**
630 TODO: Add function description
631
632 @param Private TODO: add argument description
633 @param Address TODO: add argument description
634
635 TODO: add return values
636
637 **/
638 UINT16
639 inw (
640 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
641 UINTN Address
642 )
643 {
644 UINT16 Data;
645
646 Private->PciIo->Io.Read (
647 Private->PciIo,
648 EfiPciIoWidthUint16,
649 EFI_PCI_IO_PASS_THROUGH_BAR,
650 Address,
651 1,
652 &Data
653 );
654 return Data;
655 }
656
657 /**
658 TODO: Add function description
659
660 @param Private TODO: add argument description
661 @param Index TODO: add argument description
662 @param Red TODO: add argument description
663 @param Green TODO: add argument description
664 @param Blue TODO: add argument description
665
666 TODO: add return values
667
668 **/
669 VOID
670 SetPaletteColor (
671 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
672 UINTN Index,
673 UINT8 Red,
674 UINT8 Green,
675 UINT8 Blue
676 )
677 {
678 outb (Private, PALETTE_INDEX_REGISTER, (UINT8) Index);
679 outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Red >> 2));
680 outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Green >> 2));
681 outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Blue >> 2));
682 }
683
684 /**
685 TODO: Add function description
686
687 @param Private TODO: add argument description
688
689 TODO: add return values
690
691 **/
692 VOID
693 SetDefaultPalette (
694 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
695 )
696 {
697 UINTN Index;
698 UINTN RedIndex;
699 UINTN GreenIndex;
700 UINTN BlueIndex;
701
702 Index = 0;
703 for (RedIndex = 0; RedIndex < 8; RedIndex++) {
704 for (GreenIndex = 0; GreenIndex < 8; GreenIndex++) {
705 for (BlueIndex = 0; BlueIndex < 4; BlueIndex++) {
706 SetPaletteColor (Private, Index, (UINT8) (RedIndex << 5), (UINT8) (GreenIndex << 5), (UINT8) (BlueIndex << 6));
707 Index++;
708 }
709 }
710 }
711 }
712
713 /**
714 TODO: Add function description
715
716 @param Private TODO: add argument description
717
718 TODO: add return values
719
720 **/
721 VOID
722 ClearScreen (
723 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
724 )
725 {
726 UINT32 Color;
727
728 Color = 0;
729 Private->PciIo->Mem.Write (
730 Private->PciIo,
731 EfiPciIoWidthFillUint32,
732 0,
733 0,
734 0x100000 >> 2,
735 &Color
736 );
737 }
738
739 /**
740 TODO: Add function description
741
742 @param Private TODO: add argument description
743
744 TODO: add return values
745
746 **/
747 VOID
748 DrawLogo (
749 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
750 UINTN ScreenWidth,
751 UINTN ScreenHeight
752 )
753 {
754 }
755
756 /**
757 TODO: Add function description
758
759 @param Private TODO: add argument description
760 @param ModeData TODO: add argument description
761
762 TODO: add return values
763
764 **/
765 VOID
766 InitializeGraphicsMode (
767 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
768 CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData
769 )
770 {
771 UINT8 Byte;
772 UINTN Index;
773
774 outw (Private, SEQ_ADDRESS_REGISTER, 0x1206);
775 outw (Private, SEQ_ADDRESS_REGISTER, 0x0012);
776
777 for (Index = 0; Index < 15; Index++) {
778 outw (Private, SEQ_ADDRESS_REGISTER, ModeData->SeqSettings[Index]);
779 }
780
781 outb (Private, SEQ_ADDRESS_REGISTER, 0x0f);
782 Byte = (UINT8) ((inb (Private, SEQ_DATA_REGISTER) & 0xc7) ^ 0x30);
783 outb (Private, SEQ_DATA_REGISTER, Byte);
784
785 outb (Private, MISC_OUTPUT_REGISTER, ModeData->MiscSetting);
786 outw (Private, GRAPH_ADDRESS_REGISTER, 0x0506);
787 outw (Private, SEQ_ADDRESS_REGISTER, 0x0300);
788 outw (Private, CRTC_ADDRESS_REGISTER, 0x2011);
789
790 for (Index = 0; Index < 28; Index++) {
791 outw (Private, CRTC_ADDRESS_REGISTER, (UINT16) ((ModeData->CrtcSettings[Index] << 8) | Index));
792 }
793
794 for (Index = 0; Index < 9; Index++) {
795 outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((GraphicsController[Index] << 8) | Index));
796 }
797
798 inb (Private, INPUT_STATUS_1_REGISTER);
799
800 for (Index = 0; Index < 21; Index++) {
801 outb (Private, ATT_ADDRESS_REGISTER, (UINT8) Index);
802 outb (Private, ATT_ADDRESS_REGISTER, AttributeController[Index]);
803 }
804
805 outb (Private, ATT_ADDRESS_REGISTER, 0x20);
806
807 outw (Private, GRAPH_ADDRESS_REGISTER, 0x0009);
808 outw (Private, GRAPH_ADDRESS_REGISTER, 0x000a);
809 outw (Private, GRAPH_ADDRESS_REGISTER, 0x000b);
810 outb (Private, DAC_PIXEL_MASK_REGISTER, 0xff);
811
812 SetDefaultPalette (Private);
813 ClearScreen (Private);
814 }
815
816 EFI_STATUS
817 EFIAPI
818 InitializeCirrusLogic5430 (
819 IN EFI_HANDLE ImageHandle,
820 IN EFI_SYSTEM_TABLE *SystemTable
821 )
822 {
823 EFI_STATUS Status;
824
825 Status = EfiLibInstallDriverBindingComponentName2 (
826 ImageHandle,
827 SystemTable,
828 &gCirrusLogic5430DriverBinding,
829 ImageHandle,
830 &gCirrusLogic5430ComponentName,
831 &gCirrusLogic5430ComponentName2
832 );
833 ASSERT_EFI_ERROR (Status);
834
835 //
836 // Install EFI Driver Supported EFI Version Protocol required for
837 // EFI drivers that are on PCI and other plug in cards.
838 //
839 gCirrusLogic5430DriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion);
840 Status = gBS->InstallMultipleProtocolInterfaces (
841 &ImageHandle,
842 &gEfiDriverSupportedEfiVersionProtocolGuid,
843 &gCirrusLogic5430DriverSupportedEfiVersion,
844 NULL
845 );
846 ASSERT_EFI_ERROR (Status);
847
848 return Status;
849 }