bfa121b0191bc1bedeed721885e430e3c982d48c
[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 CirrusLogic5430ControllerDriverSupported
111
112 TODO: This - add argument and description to function comment
113 TODO: Controller - add argument and description to function comment
114 TODO: RemainingDevicePath - add argument and description to function comment
115 **/
116 EFI_STATUS
117 EFIAPI
118 CirrusLogic5430ControllerDriverSupported (
119 IN EFI_DRIVER_BINDING_PROTOCOL *This,
120 IN EFI_HANDLE Controller,
121 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
122 )
123 {
124 EFI_STATUS Status;
125 EFI_PCI_IO_PROTOCOL *PciIo;
126 PCI_TYPE00 Pci;
127
128 //
129 // Open the PCI I/O Protocol
130 //
131 Status = gBS->OpenProtocol (
132 Controller,
133 &gEfiPciIoProtocolGuid,
134 (VOID **) &PciIo,
135 This->DriverBindingHandle,
136 Controller,
137 EFI_OPEN_PROTOCOL_BY_DRIVER
138 );
139 if (EFI_ERROR (Status)) {
140 return Status;
141 }
142
143 //
144 // Read the PCI Configuration Header from the PCI Device
145 //
146 Status = PciIo->Pci.Read (
147 PciIo,
148 EfiPciIoWidthUint32,
149 0,
150 sizeof (Pci) / sizeof (UINT32),
151 &Pci
152 );
153 if (EFI_ERROR (Status)) {
154 goto Done;
155 }
156
157 Status = EFI_UNSUPPORTED;
158 //
159 // See if the I/O enable is on. Most systems only allow one VGA device to be turned on
160 // at a time, so see if this is one that is turned on.
161 //
162 // if (((Pci.Hdr.Command & 0x01) == 0x01)) {
163 //
164 // See if this is a Cirrus Logic PCI controller
165 //
166 if (Pci.Hdr.VendorId == CIRRUS_LOGIC_VENDOR_ID) {
167 //
168 // See if this is a 5430 or a 5446 PCI controller
169 //
170 if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5430_DEVICE_ID) {
171 Status = EFI_SUCCESS;
172 }
173
174 if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID) {
175 Status = EFI_SUCCESS;
176 }
177
178 if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5446_DEVICE_ID) {
179 Status = EFI_SUCCESS;
180 }
181 }
182
183 Done:
184 //
185 // Close the PCI I/O Protocol
186 //
187 gBS->CloseProtocol (
188 Controller,
189 &gEfiPciIoProtocolGuid,
190 This->DriverBindingHandle,
191 Controller
192 );
193
194 return Status;
195 }
196
197 /**
198 CirrusLogic5430ControllerDriverStart
199
200 TODO: This - add argument and description to function comment
201 TODO: Controller - add argument and description to function comment
202 TODO: RemainingDevicePath - add argument and description to function comment
203 **/
204 EFI_STATUS
205 EFIAPI
206 CirrusLogic5430ControllerDriverStart (
207 IN EFI_DRIVER_BINDING_PROTOCOL *This,
208 IN EFI_HANDLE Controller,
209 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
210 )
211 {
212 EFI_STATUS Status;
213 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;
214
215 //
216 // Allocate Private context data for UGA Draw inteface.
217 //
218 Private = AllocateZeroPool (sizeof (CIRRUS_LOGIC_5430_PRIVATE_DATA));
219 if (Private == NULL) {
220 Status = EFI_OUT_OF_RESOURCES;
221 goto Error;
222 }
223
224 //
225 // Set up context record
226 //
227 Private->Signature = CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE;
228 Private->Handle = Controller;
229
230 //
231 // Open PCI I/O Protocol
232 //
233 Status = gBS->OpenProtocol (
234 Private->Handle,
235 &gEfiPciIoProtocolGuid,
236 (VOID **) &Private->PciIo,
237 This->DriverBindingHandle,
238 Private->Handle,
239 EFI_OPEN_PROTOCOL_BY_DRIVER
240 );
241 if (EFI_ERROR (Status)) {
242 goto Error;
243 }
244
245 Status = Private->PciIo->Attributes (
246 Private->PciIo,
247 EfiPciIoAttributeOperationEnable,
248 EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,
249 NULL
250 );
251 if (EFI_ERROR (Status)) {
252 goto Error;
253 }
254
255 if (FeaturePcdGet (PcdSupportUga)) {
256 //
257 // Start the UGA Draw software stack.
258 //
259 Status = CirrusLogic5430UgaDrawConstructor (Private);
260 ASSERT_EFI_ERROR (Status);
261 if (FeaturePcdGet (PcdSupportGop)) {
262 Status = CirrusLogic5430GraphicsOutputConstructor (Private);
263 ASSERT_EFI_ERROR (Status);
264
265 Status = gBS->InstallMultipleProtocolInterfaces (
266 &Private->Handle,
267 &gEfiUgaDrawProtocolGuid,
268 &Private->UgaDraw,
269 &gEfiGraphicsOutputProtocolGuid,
270 &Private->GraphicsOutput,
271 NULL
272 );
273 } else {
274 Status = gBS->InstallMultipleProtocolInterfaces (
275 &Private->Handle,
276 &gEfiUgaDrawProtocolGuid,
277 &Private->UgaDraw,
278 NULL
279 );
280
281 }
282 } else {
283 if (FeaturePcdGet (PcdSupportGop)) {
284 Status = CirrusLogic5430GraphicsOutputConstructor (Private);
285 ASSERT_EFI_ERROR (Status);
286
287 Status = gBS->InstallMultipleProtocolInterfaces (
288 &Private->Handle,
289 &gEfiGraphicsOutputProtocolGuid,
290 &Private->GraphicsOutput,
291 NULL
292 );
293
294 } else {
295 //
296 // This driver must support eithor GOP or UGA or both.
297 //
298 ASSERT (FALSE);
299 Status = EFI_UNSUPPORTED;
300 }
301 }
302
303
304 Error:
305 if (EFI_ERROR (Status)) {
306 if (Private) {
307 if (Private->PciIo) {
308 Private->PciIo->Attributes (
309 Private->PciIo,
310 EfiPciIoAttributeOperationDisable,
311 EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,
312 NULL
313 );
314 }
315 }
316
317 //
318 // Close the PCI I/O Protocol
319 //
320 gBS->CloseProtocol (
321 Private->Handle,
322 &gEfiPciIoProtocolGuid,
323 This->DriverBindingHandle,
324 Private->Handle
325 );
326 if (Private) {
327 gBS->FreePool (Private);
328 }
329 }
330
331 return Status;
332 }
333
334 /**
335 CirrusLogic5430ControllerDriverStop
336
337 TODO: This - add argument and description to function comment
338 TODO: Controller - add argument and description to function comment
339 TODO: NumberOfChildren - add argument and description to function comment
340 TODO: ChildHandleBuffer - add argument and description to function comment
341 TODO: EFI_SUCCESS - add return value to function comment
342 **/
343 EFI_STATUS
344 EFIAPI
345 CirrusLogic5430ControllerDriverStop (
346 IN EFI_DRIVER_BINDING_PROTOCOL *This,
347 IN EFI_HANDLE Controller,
348 IN UINTN NumberOfChildren,
349 IN EFI_HANDLE *ChildHandleBuffer
350 )
351 {
352 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
353 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
354
355 EFI_STATUS Status;
356 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;
357
358 if (FeaturePcdGet (PcdSupportUga)) {
359 Status = gBS->OpenProtocol (
360 Controller,
361 &gEfiUgaDrawProtocolGuid,
362 (VOID **) &UgaDraw,
363 This->DriverBindingHandle,
364 Controller,
365 EFI_OPEN_PROTOCOL_GET_PROTOCOL
366 );
367 if (EFI_ERROR (Status)) {
368 return Status;
369 }
370 //
371 // Get our private context information
372 //
373 Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (UgaDraw);
374 CirrusLogic5430UgaDrawDestructor (Private);
375
376 if (FeaturePcdGet (PcdSupportGop)) {
377 CirrusLogic5430GraphicsOutputDestructor (Private);
378 //
379 // Remove the UGA and GOP protocol interface from the system
380 //
381 Status = gBS->UninstallMultipleProtocolInterfaces (
382 Private->Handle,
383 &gEfiUgaDrawProtocolGuid,
384 &Private->UgaDraw,
385 &gEfiGraphicsOutputProtocolGuid,
386 &Private->GraphicsOutput,
387 NULL
388 );
389 } else {
390 //
391 // Remove the UGA Draw interface from the system
392 //
393 Status = gBS->UninstallMultipleProtocolInterfaces (
394 Private->Handle,
395 &gEfiUgaDrawProtocolGuid,
396 &Private->UgaDraw,
397 NULL
398 );
399 }
400 } else {
401 Status = gBS->OpenProtocol (
402 Controller,
403 &gEfiGraphicsOutputProtocolGuid,
404 (VOID **) &GraphicsOutput,
405 This->DriverBindingHandle,
406 Controller,
407 EFI_OPEN_PROTOCOL_GET_PROTOCOL
408 );
409 if (EFI_ERROR (Status)) {
410 return Status;
411 }
412
413 //
414 // Get our private context information
415 //
416 Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);
417
418 CirrusLogic5430GraphicsOutputDestructor (Private);
419 //
420 // Remove the GOP protocol interface from the system
421 //
422 Status = gBS->UninstallMultipleProtocolInterfaces (
423 Private->Handle,
424 &gEfiUgaDrawProtocolGuid,
425 &Private->UgaDraw,
426 &gEfiGraphicsOutputProtocolGuid,
427 &Private->GraphicsOutput,
428 NULL
429 );
430 }
431
432 if (EFI_ERROR (Status)) {
433 return Status;
434 }
435
436
437 //
438 // Shutdown the hardware
439 //
440 Private->PciIo->Attributes (
441 Private->PciIo,
442 EfiPciIoAttributeOperationDisable,
443 EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,
444 NULL
445 );
446
447 //
448 // Close the PCI I/O Protocol
449 //
450 gBS->CloseProtocol (
451 Controller,
452 &gEfiPciIoProtocolGuid,
453 This->DriverBindingHandle,
454 Controller
455 );
456
457 //
458 // Free our instance data
459 //
460 gBS->FreePool (Private);
461
462 return EFI_SUCCESS;
463 }
464
465 /**
466 CirrusLogic5430UgaDrawDestructor
467
468 TODO: Private - add argument and description to function comment
469 TODO: EFI_SUCCESS - add return value to function comment
470 **/
471 EFI_STATUS
472 CirrusLogic5430UgaDrawDestructor (
473 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
474 )
475 {
476 return EFI_SUCCESS;
477 }
478
479 /**
480 TODO: Add function description
481
482 @param Private TODO: add argument description
483 @param Address TODO: add argument description
484 @param Data TODO: add argument description
485
486 TODO: add return values
487
488 **/
489 VOID
490 outb (
491 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
492 UINTN Address,
493 UINT8 Data
494 )
495 {
496 Private->PciIo->Io.Write (
497 Private->PciIo,
498 EfiPciIoWidthUint8,
499 EFI_PCI_IO_PASS_THROUGH_BAR,
500 Address,
501 1,
502 &Data
503 );
504 }
505
506 /**
507 TODO: Add function description
508
509 @param Private TODO: add argument description
510 @param Address TODO: add argument description
511 @param Data TODO: add argument description
512
513 TODO: add return values
514
515 **/
516 VOID
517 outw (
518 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
519 UINTN Address,
520 UINT16 Data
521 )
522 {
523 Private->PciIo->Io.Write (
524 Private->PciIo,
525 EfiPciIoWidthUint16,
526 EFI_PCI_IO_PASS_THROUGH_BAR,
527 Address,
528 1,
529 &Data
530 );
531 }
532
533 /**
534 TODO: Add function description
535
536 @param Private TODO: add argument description
537 @param Address TODO: add argument description
538
539 TODO: add return values
540
541 **/
542 UINT8
543 inb (
544 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
545 UINTN Address
546 )
547 {
548 UINT8 Data;
549
550 Private->PciIo->Io.Read (
551 Private->PciIo,
552 EfiPciIoWidthUint8,
553 EFI_PCI_IO_PASS_THROUGH_BAR,
554 Address,
555 1,
556 &Data
557 );
558 return Data;
559 }
560
561 /**
562 TODO: Add function description
563
564 @param Private TODO: add argument description
565 @param Address TODO: add argument description
566
567 TODO: add return values
568
569 **/
570 UINT16
571 inw (
572 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
573 UINTN Address
574 )
575 {
576 UINT16 Data;
577
578 Private->PciIo->Io.Read (
579 Private->PciIo,
580 EfiPciIoWidthUint16,
581 EFI_PCI_IO_PASS_THROUGH_BAR,
582 Address,
583 1,
584 &Data
585 );
586 return Data;
587 }
588
589 /**
590 TODO: Add function description
591
592 @param Private TODO: add argument description
593 @param Index TODO: add argument description
594 @param Red TODO: add argument description
595 @param Green TODO: add argument description
596 @param Blue TODO: add argument description
597
598 TODO: add return values
599
600 **/
601 VOID
602 SetPaletteColor (
603 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
604 UINTN Index,
605 UINT8 Red,
606 UINT8 Green,
607 UINT8 Blue
608 )
609 {
610 outb (Private, PALETTE_INDEX_REGISTER, (UINT8) Index);
611 outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Red >> 2));
612 outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Green >> 2));
613 outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Blue >> 2));
614 }
615
616 /**
617 TODO: Add function description
618
619 @param Private TODO: add argument description
620
621 TODO: add return values
622
623 **/
624 VOID
625 SetDefaultPalette (
626 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
627 )
628 {
629 UINTN Index;
630 UINTN RedIndex;
631 UINTN GreenIndex;
632 UINTN BlueIndex;
633
634 Index = 0;
635 for (RedIndex = 0; RedIndex < 8; RedIndex++) {
636 for (GreenIndex = 0; GreenIndex < 8; GreenIndex++) {
637 for (BlueIndex = 0; BlueIndex < 4; BlueIndex++) {
638 SetPaletteColor (Private, Index, (UINT8) (RedIndex << 5), (UINT8) (GreenIndex << 5), (UINT8) (BlueIndex << 6));
639 Index++;
640 }
641 }
642 }
643 }
644
645 /**
646 TODO: Add function description
647
648 @param Private TODO: add argument description
649
650 TODO: add return values
651
652 **/
653 STATIC
654 VOID
655 ClearScreen (
656 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
657 )
658 {
659 UINT32 Color;
660
661 Color = 0;
662 Private->PciIo->Mem.Write (
663 Private->PciIo,
664 EfiPciIoWidthFillUint32,
665 0,
666 0,
667 0x100000 >> 2,
668 &Color
669 );
670 }
671
672 /**
673 TODO: Add function description
674
675 @param Private TODO: add argument description
676
677 TODO: add return values
678
679 **/
680 VOID
681 DrawLogo (
682 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
683 UINTN ScreenWidth,
684 UINTN ScreenHeight
685 )
686 {
687 UINTN Offset;
688 UINTN X;
689 UINTN Y;
690 UINT8 Color;
691
692 Offset = 0;
693 for (Y = 0; Y < ScreenHeight; Y++) {
694 for (X = 0; X < ScreenWidth; X++) {
695 Color = (UINT8) (256 * (X + Y) / (ScreenWidth + ScreenHeight));
696 Private->LineBuffer[X] = Color;
697 }
698
699 Private->PciIo->Mem.Write (
700 Private->PciIo,
701 EfiPciIoWidthUint32,
702 0,
703 Offset + (Y * ScreenWidth),
704 ScreenWidth >> 2,
705 Private->LineBuffer
706 );
707 }
708 }
709
710 /**
711 TODO: Add function description
712
713 @param Private TODO: add argument description
714 @param ModeData TODO: add argument description
715
716 TODO: add return values
717
718 **/
719 VOID
720 InitializeGraphicsMode (
721 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
722 CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData
723 )
724 {
725 UINT8 Byte;
726 UINTN Index;
727
728 outw (Private, SEQ_ADDRESS_REGISTER, 0x1206);
729 outw (Private, SEQ_ADDRESS_REGISTER, 0x0012);
730
731 for (Index = 0; Index < 15; Index++) {
732 outw (Private, SEQ_ADDRESS_REGISTER, ModeData->SeqSettings[Index]);
733 }
734
735 outb (Private, SEQ_ADDRESS_REGISTER, 0x0f);
736 Byte = (UINT8) ((inb (Private, SEQ_DATA_REGISTER) & 0xc7) ^ 0x30);
737 outb (Private, SEQ_DATA_REGISTER, Byte);
738
739 outb (Private, MISC_OUTPUT_REGISTER, ModeData->MiscSetting);
740 outw (Private, GRAPH_ADDRESS_REGISTER, 0x0506);
741 outw (Private, SEQ_ADDRESS_REGISTER, 0x0300);
742 outw (Private, CRTC_ADDRESS_REGISTER, 0x2011);
743
744 for (Index = 0; Index < 28; Index++) {
745 outw (Private, CRTC_ADDRESS_REGISTER, (UINT16) ((ModeData->CrtcSettings[Index] << 8) | Index));
746 }
747
748 for (Index = 0; Index < 9; Index++) {
749 outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((GraphicsController[Index] << 8) | Index));
750 }
751
752 inb (Private, INPUT_STATUS_1_REGISTER);
753
754 for (Index = 0; Index < 21; Index++) {
755 outb (Private, ATT_ADDRESS_REGISTER, (UINT8) Index);
756 outb (Private, ATT_ADDRESS_REGISTER, AttributeController[Index]);
757 }
758
759 outb (Private, ATT_ADDRESS_REGISTER, 0x20);
760
761 outw (Private, GRAPH_ADDRESS_REGISTER, 0x0009);
762 outw (Private, GRAPH_ADDRESS_REGISTER, 0x000a);
763 outw (Private, GRAPH_ADDRESS_REGISTER, 0x000b);
764 outb (Private, DAC_PIXEL_MASK_REGISTER, 0xff);
765
766 SetDefaultPalette (Private);
767 ClearScreen (Private);
768 }
769
770 EFI_STATUS
771 EFIAPI
772 InitializeCirrusLogic5430 (
773 IN EFI_HANDLE ImageHandle,
774 IN EFI_SYSTEM_TABLE *SystemTable
775 )
776 {
777 EFI_STATUS Status;
778
779 Status = EfiLibInstallDriverBindingComponentName2 (
780 ImageHandle,
781 SystemTable,
782 &gCirrusLogic5430DriverBinding,
783 ImageHandle,
784 &gCirrusLogic5430ComponentName,
785 &gCirrusLogic5430ComponentName2
786 );
787 ASSERT_EFI_ERROR (Status);
788
789 //
790 // Install EFI Driver Supported EFI Version Protocol required for
791 // EFI drivers that are on PCI and other plug in cards.
792 //
793 gCirrusLogic5430DriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion);
794 Status = gBS->InstallMultipleProtocolInterfaces (
795 &ImageHandle,
796 &gEfiDriverSupportedEfiVersionProtocolGuid,
797 &gCirrusLogic5430DriverSupportedEfiVersion,
798 NULL
799 );
800 ASSERT_EFI_ERROR (Status);
801
802 return Status;
803 }