- Timestamp:
- Jun 12, 2017 6:02:10 PM (8 years ago)
- Location:
- trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/Edid.c
r62500 r67352 365 365 VALID_EDID_TIMING ValidEdidTiming; 366 366 UINT32 ValidModeCount; 367 VBOX_VGA_MODE_DATA *ModeData;367 VBOX_VGA_MODE_DATA *ModeData; 368 368 BOOLEAN TimingMatch; 369 VBOX_VGA_VIDEO_MODES *VideoMode;369 VBOX_VGA_VIDEO_MODES *VideoMode; 370 370 EDID_TIMING TempTiming; 371 371 … … 429 429 if (ReadEdidData (Private, &EdidDiscoveredDataBlock, &EdidDiscoveredDataSize) == EFI_SUCCESS) { 430 430 Private->EdidDiscovered.SizeOfEdid = (UINT32) EdidDiscoveredDataSize; 431 431 Private->EdidDiscovered.Edid = (UINT8 *) AllocateCopyPool ( 432 432 EdidDiscoveredDataSize, 433 433 EdidDiscoveredDataBlock 434 434 ); 435 435 436 436 if (NULL == Private->EdidDiscovered.Edid) { … … 450 450 EdidActiveDataBlock = EdidOverrideDataBlock; 451 451 EdidFound = TRUE; 452 453 454 452 } 453 454 if (EdidFound == TRUE) { 455 455 // 456 456 // Parse EDID data structure to retrieve modes supported by monitor … … 481 481 // 482 482 ValidModeCount = 0; 483 Private->ModeData = AllocatePool(sizeof(VBOX_VGA_MODE_DATA) * VBoxVgaVideoModeCount); 483 484 ModeData = &Private->ModeData[0]; 484 485 VideoMode = &VBoxVgaVideoModes[0]; 485 for (Index = 0; Index < VB OX_VGA_MODE_COUNT; Index++) {486 for (Index = 0; Index < VBoxVgaVideoModeCount; Index++) { 486 487 487 488 TimingMatch = TRUE; … … 501 502 // 502 503 if ((VideoMode->Width == 0) || (VideoMode->Height == 0)) { 504 TimingMatch = FALSE; 505 } 506 507 // 508 // Check whether the mode would be exceeding the VRAM size. 509 // 510 if (VideoMode->Width * VideoMode->Height * (VideoMode->ColorDepth / 8) > Private->VRAMSize) { 503 511 TimingMatch = FALSE; 504 512 } … … 517 525 VideoMode ++; 518 526 } 519 520 Private->MaxMode = ValidModeCount;521 522 527 } else { 523 528 // 524 529 // If EDID information wasn't found 525 530 // 531 ValidModeCount = 0; 532 Private->ModeData = AllocatePool(sizeof(VBOX_VGA_MODE_DATA) * VBoxVgaVideoModeCount); 526 533 ModeData = &Private->ModeData[0]; 527 534 VideoMode = &VBoxVgaVideoModes[0]; 528 for (Index = 0; Index < VBOX_VGA_MODE_COUNT; Index ++) { 529 ModeData->ModeNumber = Index; 530 ModeData->HorizontalResolution = VideoMode->Width; 531 ModeData->VerticalResolution = VideoMode->Height; 532 ModeData->ColorDepth = VideoMode->ColorDepth; 533 ModeData->RefreshRate = VideoMode->RefreshRate; 534 535 ModeData ++ ; 535 for (Index = 0; Index < VBoxVgaVideoModeCount; Index ++) { 536 // 537 // Check whether the mode would be exceeding the VRAM size. 538 // 539 if (VideoMode->Width * VideoMode->Height * (VideoMode->ColorDepth / 8) <= Private->VRAMSize) { 540 ModeData->ModeNumber = Index; 541 ModeData->HorizontalResolution = VideoMode->Width; 542 ModeData->VerticalResolution = VideoMode->Height; 543 ModeData->ColorDepth = VideoMode->ColorDepth; 544 ModeData->RefreshRate = VideoMode->RefreshRate; 545 546 ModeData ++; 547 ValidModeCount ++; 548 } 549 536 550 VideoMode ++; 537 551 } 538 Private->MaxMode = VBOX_VGA_MODE_COUNT; 539 } 552 } 553 554 Private->MaxMode = ValidModeCount; 540 555 541 556 if (EdidOverrideDataBlock != NULL) { -
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.c
r62500 r67352 52 52 53 53 // 54 // Cirrus Logic 5430Controller Driver54 // VirtualBox VGA Controller Driver 55 55 // 56 56 #include "VBoxVga.h" 57 #include <IndustryStandard/Acpi.h> 57 58 #include "iprt/asm.h" 58 #include <IndustryStandard/Acpi.h> 59 60 61 #define BOUTB(storage, count, aport, dport) \ 62 do { \ 63 for (i = 0 ; i < (count); ++i) \ 64 if ((dport) == (aport) + 1) \ 65 ASMOutU16((aport), ((UINT16)storage[i] << 8) | (UINT8)i); \ 66 else { \ 67 ASMOutU8((aport), (UINT8)i); \ 68 ASMOutU8((dport), storage[i]); \ 69 } \ 70 } while (0) 71 72 59 73 60 74 EFI_DRIVER_BINDING_PROTOCOL gVBoxVgaDriverBinding = { … … 80 94 /// 81 95 UINT8 GraphicsController[9] = { 82 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0x FF96 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xff 83 97 }; 84 98 99 /// 100 /// Generic Graphics Controller Sequencer Register Settings 101 /// 102 UINT8 Seq_Default[5] = { 103 0x01, 0x01, 0x0f, 0x00, 0x0a 104 }; 105 106 #if 0 // CRTC tables not used (and not checked for correctness), as VBE is much simpler 85 107 // 86 108 // 640 x 480 x 256 color @ 60 Hertz … … 95 117 /* r24 = */0xff 96 118 }; 97 UINT8 Seq_640_480_256_60[5] = {98 0x01, 0x01, 0x0f, 0x00, 0x0a99 };100 119 101 120 // … … 103 122 // 104 123 UINT8 Crtc_800_600_256_60[25] = { 105 /* r0 = */0x 5f, /* r1 = */0x4f, /* r2 = */0x50, /* r3 = */0x82,106 /* r4 = */0x 54, /* r5 = */0x80, /* r6 = */0x0b, /* r7 = */0x3e,107 /* r8 = */0x00, /* r9 = */0x 40, /* r10 = */0x00, /* r11 = */0x00,124 /* r0 = */0x7f, /* r1 = */0x63, /* r2 = */0x64, /* r3 = */0x82, 125 /* r4 = */0x6b, /* r5 = */0x80, /* r6 = */0x0b, /* r7 = */0x3e, 126 /* r8 = */0x00, /* r9 = */0x60, /* r10 = */0x00, /* r11 = */0x00, 108 127 /* r12 = */0x00, /* r13 = */0x00, /* r14 = */0x00, /* r15 = */0x00, 109 128 /* r16 = */0xea, /* r17 = */0x0c, /* r18 = */0xdf, /* r19 = */0x28, … … 111 130 /* r24 = */0xff 112 131 113 };114 115 UINT8 Seq_800_600_256_60[5] = {116 0x01, 0x01, 0x0f, 0x00, 0x0a117 132 }; 118 133 … … 129 144 /* r24 = */0xff 130 145 }; 131 132 UINT8 Seq_1024_768_256_60[5] = { 133 0x01, 0x01, 0x0f, 0x00, 0x0a 134 }; 135 136 // 137 // 1280x1024 138 // 139 UINT8 Crtc_1280_1024_256_60[25] = { 140 /* r0 = */0xa3, /* r1 = */0x9f, /* r2 = */0x81, /* r3 = */0x90, 141 /* r4 = */0x88, /* r5 = */0x05, /* r6 = */0x28, /* r7 = */0xbd, 142 /* r8 = */0x00, /* r9 = */0x60, /* r10 = */0x00, /* r11 = */0x00, 143 /* r12 = */0x00, /* r13 = */0x00, /* r14 = */0x00, /* r15 = */0x00, 144 /* r16 = */0x06, /* r17 = */0x0f, /* r18 = */0x3f, /* r19 = */0x40, 145 /* r20 = */0x4f, /* r21 = */0x05, /* r22 = */0x1a, /* r23 = */0xe3, 146 /* r24 = */0xff 147 }; 148 149 UINT8 Seq_1280_1024_256_60[5] = { 150 0x01, 0x01, 0x0f, 0x00, 0x0a 151 }; 152 153 // 154 // 1440x900 155 // 156 UINT8 Crtc_1440_900_256_60[25] = { 157 /* r0 = */0xa3, /* r1 = */0xb3, /* r2 = */0x81, /* r3 = */0x90, 158 /* r4 = */0x88, /* r5 = */0x05, /* r6 = */0x28, /* r7 = */0xbd, 159 /* r8 = */0x00, /* r9 = */0x60, /* r10 = */0x00, /* r11 = */0x00, 160 /* r12 = */0x00, /* r13 = */0x00, /* r14 = */0x00, /* r15 = */0x00, 161 /* r16 = */0x06, /* r17 = */0x0f, /* r18 = */0x38, /* r19 = */0x40, 162 /* r20 = */0x4f, /* r21 = */0x05, /* r22 = */0x1a, /* r23 = */0xe3, 163 /* r24 = */0xff 164 }; 165 166 UINT8 Seq_1440_900_256_60[5] = { 167 0x01, 0x01, 0x0f, 0x00, 0x0a 168 }; 169 170 // 171 // 1920x1200 172 // 173 UINT8 Crtc_1920_1200_256_60[25] = { 174 /* r0 = */0xa3, /* r1 = */0xef, /* r2 = */0x81, /* r3 = */0x90, 175 /* r4 = */0x88, /* r5 = */0x05, /* r6 = */0x28, /* r7 = */0xbd, 176 /* r8 = */0x00, /* r9 = */0x60, /* r10 = */0x00, /* r11 = */0x00, 177 /* r12 = */0x00, /* r13 = */0x00, /* r14 = */0x00, /* r15 = */0x00, 178 /* r16 = */0x06, /* r17 = */0x0f, /* r18 = */0x50, /* r19 = */0x40, 179 /* r20 = */0x4f, /* r21 = */0x05, /* r22 = */0x1a, /* r23 = */0xe3, 180 /* r24 = */0xff 181 }; 182 183 UINT8 Seq_1920_1200_256_60[5] = { 184 0x01, 0x01, 0x0f, 0x00, 0x0a 185 }; 146 #endif 186 147 187 148 /// 188 /// Table of supported video modes 149 /// Table of supported video modes (sorted by pixel count!) 189 150 /// 190 151 VBOX_VGA_VIDEO_MODES VBoxVgaVideoModes[] = 191 152 { 192 { 640, 480, 32, 60, Crtc_640_480_256_60, Seq_640_480_256_60, 0xe3 }, 193 { 800, 600, 32, 60, Crtc_800_600_256_60, Seq_800_600_256_60, 0x23 }, 194 { 1024, 768, 32, 60, Crtc_1024_768_256_60, Seq_1024_768_256_60, 0xef }, 195 { 1280, 1024, 32, 60, Crtc_1280_1024_256_60, Seq_1280_1024_256_60, 0xef }, 196 { 1440, 900, 32, 60, Crtc_1440_900_256_60, Seq_1440_900_256_60, 0xef }, 197 { 1920, 1200, 32, 60, Crtc_1920_1200_256_60, Seq_1920_1200_256_60, 0xef } 153 { 640, 480, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // VGA 4:3 154 { 800, 600, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // SVGA 4:3 155 { 1024, 768, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // XGA 4:3 156 { 1280, 720, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // HD 16:9 157 { 1152, 864, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // XGA+ 4:3 158 { 1280, 800, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // WXGA 16:10 159 { 1440, 900, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // WXGA+ 16:10 160 { 1280, 1024, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // SXGA 5:4 161 { 1400, 1050, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // SXGA+ 4:3 162 { 1600, 900, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // HD+ 16:9 163 { 1680, 1050, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // WSXGA+ 16:10 164 { 1600, 1200, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // UXGA 4:3 165 { 1920, 1080, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // FHD 16:9 166 { 2048, 1080, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // DCI_2K 19:10 167 { 1920, 1200, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // WUXGA 16:10 168 { 2160, 1440, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // FHD+ 3:2 169 { 2304, 1440, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // unnamed 16:10 170 { 2560, 1440, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // QHD 16:9 171 { 2560, 1600, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // WQXGA 16:10 172 { 2880, 1800, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // QWXGA+ 16:10 173 { 3200, 1800, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // QHD+ 16:9 174 { 3200, 2048, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // WQSXGA 16:10 175 { 3840, 2160, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // 4K_UHD 16:9 176 { 4096, 2160, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // DCI_4K 19:10 177 { 3840, 2400, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // WQUXGA 16:10 178 { 4096, 3072, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // HXGA 4:3 179 { 5120, 2880, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // UHD+ 16:9 180 { 5120, 3200, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // WHXGA 16:10 181 { 6400, 4096, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // WHSXGA 16:10 182 { 6400, 4800, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // HUXGA 4:3 183 { 7680, 4320, 32, 60, NULL /* crtc */, NULL /* sequencer */, 0x01 }, // 8K_UHD2 16:9 198 184 }; 185 186 const UINT32 VBoxVgaVideoModeCount = sizeof(VBoxVgaVideoModes) / sizeof(VBoxVgaVideoModes[0]); 199 187 200 188 typedef struct _APPLE_FRAMEBUFFERINFO_PROTOCOL APPLE_FRAMEBUFFERINFO_PROTOCOL; … … 307 295 // if (((Pci.Hdr.Command & 0x01) == 0x01)) { 308 296 // 309 // See if this is a Cirrus LogicPCI controller297 // See if this is a VirtualBox VGA PCI controller 310 298 // 311 299 if (Pci.Hdr.VendorId == VBOX_VENDOR_ID) { … … 483 471 484 472 // 485 // Construct video mode buffer 473 // Get VRAM size, needed for constructing a correct video mode list 474 // 475 Private->VRAMSize = ASMInU32(VBE_DISPI_IOPORT_DATA); 476 477 // 478 // Construct video mode list 486 479 // 487 480 Status = VBoxVgaVideoModeSetup (Private); … … 489 482 goto Error; 490 483 } 491 492 484 493 485 if (FeaturePcdGet (PcdSupportUga)) { … … 547 539 Status = EFI_UNSUPPORTED; 548 540 } 549 550 541 551 542 Error: … … 618 609 return Status; 619 610 } 611 620 612 // 621 613 // Get our private context information … … 672 664 Status = gBS->UninstallMultipleProtocolInterfaces ( 673 665 Private->Handle, 674 &gEfiUgaDrawProtocolGuid,675 &Private->UgaDraw,676 666 &gEfiGraphicsOutputProtocolGuid, 677 667 &Private->GraphicsOutput, … … 682 672 if (EFI_ERROR (Status)) { 683 673 return Status; 674 } 675 676 if (Private->ModeData) { 677 FreePool(Private->ModeData); 678 Private->ModeData = NULL; 684 679 } 685 680 … … 725 720 return EFI_SUCCESS; 726 721 } 727 728 #define inb(ignore, port) ASMInU8((port))729 #define inw(ignore, port) ASMInU16((port))730 #define outb(ignore, port, val) ASMOutU8((port), (val))731 #define outw(ignore, port, val) ASMOutU16((port), (val))732 733 722 734 723 /** … … 753 742 ) 754 743 { 755 outb (Private,PALETTE_INDEX_REGISTER, (UINT8) Index);756 outb (Private,PALETTE_DATA_REGISTER, (UINT8) (Red >> 2));757 outb (Private,PALETTE_DATA_REGISTER, (UINT8) (Green >> 2));758 outb (Private,PALETTE_DATA_REGISTER, (UINT8) (Blue >> 2));744 ASMOutU8(PALETTE_INDEX_REGISTER, (UINT8) Index); 745 ASMOutU8(PALETTE_DATA_REGISTER, (UINT8) (Red >> 2)); 746 ASMOutU8(PALETTE_DATA_REGISTER, (UINT8) (Green >> 2)); 747 ASMOutU8(PALETTE_DATA_REGISTER, (UINT8) (Blue >> 2)); 759 748 } 760 749 … … 859 848 for (i = 0; i < 64; ++i) 860 849 { 861 outb(Private, 0x3c8, (UINT8)i);862 outb(Private, 0x3c9, s_a3bVgaDac[i*3 + 0]);863 outb(Private, 0x3c9, s_a3bVgaDac[i*3 + 1]);864 outb(Private, 0x3c9, s_a3bVgaDac[i*3 + 2]);850 ASMOutU8(PALETTE_INDEX_REGISTER, (UINT8)i); 851 ASMOutU8(PALETTE_DATA_REGISTER, s_a3bVgaDac[i*3 + 0]); 852 ASMOutU8(PALETTE_DATA_REGISTER, s_a3bVgaDac[i*3 + 1]); 853 ASMOutU8(PALETTE_DATA_REGISTER, s_a3bVgaDac[i*3 + 2]); 865 854 } 866 855 } … … 909 898 DrawLogo ( 910 899 VBOX_VGA_PRIVATE_DATA *Private, 911 UINTN 912 UINTN 900 UINTN ScreenWidth, 901 UINTN ScreenHeight 913 902 ) 914 903 { … … 934 923 ) 935 924 { 936 UINT16 DeviceId; 937 EFI_STATUS Status; 938 int i; 939 940 Status = Private->PciIo->Pci.Read ( 925 UINT16 DeviceId; 926 EFI_STATUS Status; 927 int i; 928 929 // 930 // Read the PCI ID from the PCI Device (dummy) 931 // 932 Status = Private->PciIo->Pci.Read ( 941 933 Private->PciIo, 942 934 EfiPciIoWidthUint16, … … 945 937 &DeviceId 946 938 ); 947 outb(Private, 0x3c2, 0xc3); 948 outb(Private, 0x3c4, 0x04); 949 outb(Private, 0x3c5, 0x02); 950 // 951 // Read the PCI Configuration Header from the PCI Device 952 // 953 #define BOUTB(storage, count, aport, dport) \ 954 do { \ 955 for (i = 0 ; i < count; ++i) \ 956 { \ 957 outb(Private, (aport), (UINT8)i);\ 958 outb(Private, (dport), storage[i]); \ 959 } \ 960 } while (0) 961 962 ASSERT_EFI_ERROR (Status); 963 inb(Private, INPUT_STATUS_1_REGISTER); 964 outb(Private, ATT_ADDRESS_REGISTER, 0); 965 outb(Private, CRTC_ADDRESS_REGISTER, 0x11); 966 outb(Private, CRTC_DATA_REGISTER, 0x0); 967 /* 968 * r0 = 1 969 * boutb(1, 0x3c4, 0x3c5); 970 */ 971 outb(Private, SEQ_ADDRESS_REGISTER, 0); 972 outb(Private, SEQ_DATA_REGISTER, 1); 973 974 outw(Private, 0x1ce, 0x00); outw(Private, 0x1cf, 0xb0c0); // ENABLE 975 outw(Private, 0x1ce, 0x04); outw(Private, 0x1cf, 0); // ENABLE 976 outw(Private, 0x1ce, 0x01); outw(Private, 0x1cf, (UINT16)ModeData->Width); // XRES 977 outw(Private, 0x1ce, 0x02); outw(Private, 0x1cf, (UINT16)ModeData->Height); // YRES 978 outw(Private, 0x1ce, 0x03); outw(Private, 0x1cf, (UINT16)ModeData->ColorDepth); // BPP 979 outw(Private, 0x1ce, 0x05); outw(Private, 0x1cf, 0); // BANK 980 outw(Private, 0x1ce, 0x06); outw(Private, 0x1cf, (UINT16)ModeData->Width); // VIRT_WIDTH 981 outw(Private, 0x1ce, 0x07); outw(Private, 0x1cf, (UINT16)ModeData->Height); // VIRT_HEIGHT 982 outw(Private, 0x1ce, 0x08); outw(Private, 0x1cf, 0); // X_OFFSET 983 outw(Private, 0x1ce, 0x09); outw(Private, 0x1cf, 0); // Y_OFFSET 984 outw(Private, 0x1ce, 0x04); outw(Private, 0x1cf, 1); // ENABLE 985 outb(Private, MISC_OUTPUT_REGISTER, ModeData->MiscSetting); 986 BOUTB(ModeData->SeqSettings, 5, SEQ_ADDRESS_REGISTER, SEQ_DATA_REGISTER); 987 /* 988 * r0 = 3 989 * boutb(1, 0x3c4, 0x3c5); 990 */ 991 outb(Private, SEQ_ADDRESS_REGISTER, 0); 992 outb(Private, SEQ_DATA_REGISTER, 3); 993 994 BOUTB(ModeData->CrtcSettings, 25, CRTC_ADDRESS_REGISTER, CRTC_DATA_REGISTER); 995 BOUTB(GraphicsController, 9, GRAPH_ADDRESS_REGISTER , GRAPH_DATA_REGISTER); 996 997 inb (Private, INPUT_STATUS_1_REGISTER); 998 999 BOUTB(AttributeController, 21, ATT_ADDRESS_REGISTER, ATT_ADDRESS_REGISTER); 1000 1001 outw(Private, 0x1ce, 0x05); outw(Private, 0x1cf, 0x0); 1002 1003 outb (Private, ATT_ADDRESS_REGISTER, 0x20); 1004 1005 #if 0 1006 outw (Private, GRAPH_ADDRESS_REGISTER, 0x0009); 1007 outw (Private, GRAPH_ADDRESS_REGISTER, 0x000a); 1008 outw (Private, GRAPH_ADDRESS_REGISTER, 0x000b); 1009 outb (Private, DAC_PIXEL_MASK_REGISTER, 0xff); 1010 1011 SetDefaultPalette (Private); 1012 #endif 1013 ClearScreen (Private); 939 ASSERT_EFI_ERROR(Status); 940 941 ASMOutU8(MISC_OUTPUT_REGISTER, 0xc3); 942 ASMOutU16(SEQ_ADDRESS_REGISTER, 0x0204); 943 944 ASMInU8(INPUT_STATUS_1_REGISTER); // reset attribute address/data flip-flop 945 ASMOutU8(ATT_ADDRESS_REGISTER, 0); // blank screen using the attribute address register 946 947 ASMOutU16(CRTC_ADDRESS_REGISTER, 0x0011); 948 949 ASMOutU16(SEQ_ADDRESS_REGISTER, 0x0100); 950 951 if (!ModeData->CrtcSettings) 952 { 953 // No CRTC settings, use VBE 954 ASMOutU16(VBE_DISPI_IOPORT_INDEX, 0x00); ASMOutU16(VBE_DISPI_IOPORT_DATA, 0xb0c0); // ID 955 ASMOutU16(VBE_DISPI_IOPORT_INDEX, 0x04); ASMOutU16(VBE_DISPI_IOPORT_DATA, 0); // ENABLE 956 ASMOutU16(VBE_DISPI_IOPORT_INDEX, 0x01); ASMOutU16(VBE_DISPI_IOPORT_DATA, (UINT16)ModeData->Width); // XRES 957 ASMOutU16(VBE_DISPI_IOPORT_INDEX, 0x02); ASMOutU16(VBE_DISPI_IOPORT_DATA, (UINT16)ModeData->Height); // YRES 958 ASMOutU16(VBE_DISPI_IOPORT_INDEX, 0x03); ASMOutU16(VBE_DISPI_IOPORT_DATA, (UINT16)ModeData->ColorDepth); // BPP 959 ASMOutU16(VBE_DISPI_IOPORT_INDEX, 0x05); ASMOutU16(VBE_DISPI_IOPORT_DATA, 0); // BANK 960 ASMOutU16(VBE_DISPI_IOPORT_INDEX, 0x06); ASMOutU16(VBE_DISPI_IOPORT_DATA, (UINT16)ModeData->Width); // VIRT_WIDTH 961 ASMOutU16(VBE_DISPI_IOPORT_INDEX, 0x07); ASMOutU16(VBE_DISPI_IOPORT_DATA, (UINT16)ModeData->Height); // VIRT_HEIGHT 962 ASMOutU16(VBE_DISPI_IOPORT_INDEX, 0x08); ASMOutU16(VBE_DISPI_IOPORT_DATA, 0); // X_OFFSET 963 ASMOutU16(VBE_DISPI_IOPORT_INDEX, 0x09); ASMOutU16(VBE_DISPI_IOPORT_DATA, 0); // Y_OFFSET 964 ASMOutU16(VBE_DISPI_IOPORT_INDEX, 0x04); ASMOutU16(VBE_DISPI_IOPORT_DATA, 1); // ENABLE 965 } 966 else 967 { 968 BOUTB(ModeData->CrtcSettings, 25, CRTC_ADDRESS_REGISTER, CRTC_DATA_REGISTER); 969 } 970 971 ASMOutU8(MISC_OUTPUT_REGISTER, ModeData->MiscSetting); 972 973 if (ModeData->SeqSettings) 974 BOUTB(ModeData->SeqSettings, 5, SEQ_ADDRESS_REGISTER, SEQ_DATA_REGISTER); 975 else 976 BOUTB(Seq_Default, 5, SEQ_ADDRESS_REGISTER, SEQ_DATA_REGISTER); 977 978 ASMOutU16(SEQ_ADDRESS_REGISTER, 0x0300); 979 980 BOUTB(GraphicsController, 9, GRAPH_ADDRESS_REGISTER, GRAPH_DATA_REGISTER); 981 982 ASMInU8(INPUT_STATUS_1_REGISTER); // reset attribute address/data flip-flop 983 // attribute controller is weird: data writes to the address register 984 BOUTB(AttributeController, 21, ATT_ADDRESS_REGISTER, ATT_ADDRESS_REGISTER); 985 ASMOutU8(ATT_ADDRESS_REGISTER, 0x20); 986 987 if (ModeData->ColorDepth <= 8) 988 { 989 ASMOutU8(DAC_PIXEL_MASK_REGISTER, 0xff); 990 SetDefaultPalette(Private); 991 } 992 993 ClearScreen(Private); 1014 994 } 1015 995 … … 1029 1009 OUT UINT32 *Depth) 1030 1010 { 1031 /* @todo: figure out from current running mode */1032 1011 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *FrameBufDesc; 1033 1012 UINT32 W, H, BPP; -
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.h
r62500 r67352 42 42 43 43 // 44 // Cirrus Logic 5430Controller Driver44 // VirtualBox VGA Controller Driver 45 45 // 46 46 … … 73 73 #include "VBoxPkg.h" 74 74 #include "DevEFI.h" 75 #include "iprt/asm.h" 76 77 // 78 // Cirrus Logic 5430 PCI Configuration Header values 75 76 // 77 // VirtualBox VGA PCI Configuration Header values 79 78 // 80 79 #define VBOX_VENDOR_ID 0x80ee … … 82 81 83 82 // 84 // Cirrus Logic Graphical Mode Data 85 // 86 #define VBOX_VGA_MODE_COUNT 6 87 83 // VirtualBox VGA Mode Data 84 // 88 85 typedef struct { 89 86 UINT32 ModeNumber; … … 97 94 98 95 // 99 // Cirrus Logic 5440Private Data Structure100 // 101 #define VBOX_VGA_PRIVATE_DATA_SIGNATURE SIGNATURE_32 (' C', 'L', '5', '4')96 // VirtualBox VGA Private Data Structure 97 // 98 #define VBOX_VGA_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('V', 'B', 'V', 'D') 102 99 103 100 typedef struct { … … 114 111 UINTN CurrentMode; 115 112 UINTN MaxMode; 116 VBOX_VGA_MODE_DATA ModeData[VBOX_VGA_MODE_COUNT];117 UINT32 113 VBOX_VGA_MODE_DATA *ModeData; 114 UINT32 *LineBuffer; 118 115 BOOLEAN HardwareNeedsStarting; 116 UINT32 VRAMSize; 119 117 void *TmpBuf; 120 118 } VBOX_VGA_PRIVATE_DATA; … … 128 126 UINT32 ColorDepth; 129 127 UINT32 RefreshRate; 128 /// CRTC settings are optional. If NULL then VBE is used 130 129 UINT8 *CrtcSettings; 131 UINT8 *SeqSettings; 130 /// Sequencer settings are optional. If NULL then defaults are used 131 UINT8 *SeqSettings; 132 132 UINT8 MiscSetting; 133 133 } VBOX_VGA_VIDEO_MODES; … … 146 146 extern UINT8 GraphicsController[]; 147 147 extern UINT8 Crtc_640_480_256_60[]; 148 extern UINT8 Seq_640_480_256_60[];148 extern UINT8 Seq_640_480_256_60[]; 149 149 extern UINT8 Crtc_800_600_256_60[]; 150 extern UINT8 Seq_800_600_256_60[];150 extern UINT8 Seq_800_600_256_60[]; 151 151 extern UINT8 Crtc_1024_768_256_60[]; 152 extern UINT8 Seq_1024_768_256_60[]; 153 extern VBOX_VGA_VIDEO_MODES VBoxVgaVideoModes[]; 152 extern UINT8 Seq_1024_768_256_60[]; 153 extern VBOX_VGA_VIDEO_MODES VBoxVgaVideoModes[]; 154 extern const UINT32 VBoxVgaVideoModeCount; 154 155 extern EFI_DRIVER_BINDING_PROTOCOL gVBoxVgaDriverBinding; 155 156 extern EFI_COMPONENT_NAME_PROTOCOL gVBoxVgaComponentName; … … 167 168 #define GRAPH_DATA_REGISTER 0x3cf 168 169 #define ATT_ADDRESS_REGISTER 0x3c0 170 #define ATT_DATA_REGISTER 0x3c1 169 171 #define MISC_OUTPUT_REGISTER 0x3c2 170 172 #define INPUT_STATUS_1_REGISTER 0x3da … … 172 174 #define PALETTE_INDEX_REGISTER 0x3c8 173 175 #define PALETTE_DATA_REGISTER 0x3c9 176 177 // IO Registers defined by VBE 178 #define VBE_DISPI_IOPORT_INDEX 0x1ce 179 #define VBE_DISPI_IOPORT_DATA 0x1cf 180 174 181 175 182 // … … 419 426 ); 420 427 421 VOID422 outb (423 VBOX_VGA_PRIVATE_DATA *Private,424 UINTN Address,425 UINT8 Data426 );427 428 VOID429 outw (430 VBOX_VGA_PRIVATE_DATA *Private,431 UINTN Address,432 UINT16 Data433 );434 435 UINT8436 inb (437 VBOX_VGA_PRIVATE_DATA *Private,438 UINTN Address439 );440 441 UINT16442 inw (443 VBOX_VGA_PRIVATE_DATA *Private,444 UINTN Address445 );446 447 428 EFI_STATUS 448 429 VBoxVgaVideoModeSetup ( -
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaGraphicsOutput.c
r62500 r67352 444 444 EFI_STATUS Status; 445 445 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; 446 UINT32 GopMode = 2; 446 UINT32 GopMode = 2; /* 1024x768 */ 447 447 448 448 GraphicsOutput = &Private->GraphicsOutput;
Note:
See TracChangeset
for help on using the changeset viewer.