Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenvbe.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS VGA Miniport Driver 00003 * LICENSE: BSD - See COPYING.ARM in the top level directory 00004 * FILE: boot/drivers/video/miniport/vga/vbe.c 00005 * PURPOSE: Main VESA VBE 1.02+ SVGA Miniport Handling Code 00006 * PROGRAMMERS: ReactOS Portable Systems Group 00007 */ 00008 00009 /* INCLUDES *******************************************************************/ 00010 00011 #include "vga.h" 00012 00013 /* GLOBALS ********************************************************************/ 00014 00015 static const CHAR Nv11Board[] = "NV11 (GeForce2) Board"; 00016 static const CHAR Nv11Chip[] = "Chip Rev B2"; 00017 static const CHAR Nv11Vendor[] = "NVidia Corporation"; 00018 static const CHAR IntelBrookdale[] = "Brookdale-G Graphics Controller"; 00019 static const PCHAR BrokenVesaBiosList[] = 00020 { 00021 "SiS 5597", 00022 "MGA-G100", 00023 "3Dfx Banshee", 00024 "Voodoo3 2000 LC ", 00025 "Voodoo3 3000 LC ", 00026 "Voodoo4 4500 ", 00027 "ArtX I", 00028 "ATI S1-370TL" 00029 }; 00030 00031 BOOLEAN g_bIntelBrookdaleBIOS; 00032 00033 /* FUNCTIONS ******************************************************************/ 00034 00035 BOOLEAN 00036 NTAPI 00037 IsVesaBiosOk(IN PVIDEO_PORT_INT10_INTERFACE Interface, 00038 IN ULONG OemRevision, 00039 IN PCHAR Vendor, 00040 IN PCHAR Product, 00041 IN PCHAR Revision) 00042 { 00043 ULONG i; 00044 CHAR Version[21]; 00045 00046 /* If the broken VESA bios found, turn VESA off */ 00047 VideoPortDebugPrint(0, "Vendor: %s Product: %s Revision: %s (%lx)\n", Vendor, Product, Revision, OemRevision); 00048 for (i = 0; i < (sizeof(BrokenVesaBiosList) / sizeof(PCHAR)); i++) 00049 { 00050 if (!strncmp(Product, BrokenVesaBiosList[i], strlen(BrokenVesaBiosList[i]))) return FALSE; 00051 } 00052 00053 /* For Brookdale-G (Intel), special hack used */ 00054 g_bIntelBrookdaleBIOS = !strncmp(Product, IntelBrookdale, sizeof(IntelBrookdale) - 1); 00055 00056 /* For NVIDIA make sure */ 00057 if (!(strncmp(Vendor, Nv11Vendor, sizeof(Nv11Vendor) - 1)) && 00058 !(strncmp(Product, Nv11Board, sizeof(Nv11Board) - 1)) && 00059 !(strncmp(Revision, Nv11Chip, sizeof(Nv11Chip) - 1)) && 00060 (OemRevision == 0x311)) 00061 { 00062 /* Read version */ 00063 if (Interface->Int10ReadMemory(Interface->Context, 00064 0xC000, 00065 345, 00066 Version, 00067 sizeof(Version))) return FALSE; 00068 if (!strncmp(Version, "Version 3.11.01.24N16", sizeof(Version))) return FALSE; 00069 } 00070 00071 /* VESA ok */ 00072 //VideoPortDebugPrint(0, "Vesa ok\n"); 00073 return TRUE; 00074 } 00075 00076 BOOLEAN 00077 NTAPI 00078 ValidateVbeInfo(IN PHW_DEVICE_EXTENSION VgaExtension, 00079 IN PVBE_INFO VbeInfo) 00080 { 00081 BOOLEAN VesaBiosOk; 00082 PVOID Context; 00083 CHAR ProductRevision[80]; 00084 CHAR OemString[80]; 00085 CHAR ProductName[80]; 00086 CHAR VendorName[80]; 00087 VP_STATUS Status; 00088 00089 /* Set default */ 00090 VesaBiosOk = FALSE; 00091 Context = VgaExtension->Int10Interface.Context; 00092 00093 /* Check magic and version */ 00094 if (VbeInfo->Info.Signature == VESA_MAGIC) return VesaBiosOk; 00095 if (VbeInfo->Info.Version < 0x102) return VesaBiosOk; 00096 00097 /* Read strings */ 00098 Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, 00099 HIWORD(VbeInfo->Info.OemStringPtr), 00100 LOWORD(VbeInfo->Info.OemStringPtr), 00101 OemString, 00102 sizeof(OemString)); 00103 if (Status != NO_ERROR) return VesaBiosOk; 00104 Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, 00105 HIWORD(VbeInfo->Info.OemVendorNamePtr), 00106 LOWORD(VbeInfo->Info.OemVendorNamePtr), 00107 VendorName, 00108 sizeof(VendorName)); 00109 if (Status != NO_ERROR) return VesaBiosOk; 00110 Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, 00111 HIWORD(VbeInfo->Info.OemProductNamePtr), 00112 LOWORD(VbeInfo->Info.OemProductNamePtr), 00113 ProductName, 00114 sizeof(ProductName)); 00115 if (Status != NO_ERROR) return VesaBiosOk; 00116 Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, 00117 HIWORD(VbeInfo->Info.OemProductRevPtr), 00118 LOWORD(VbeInfo->Info.OemProductRevPtr), 00119 ProductRevision, 00120 sizeof(ProductRevision)); 00121 if (Status != NO_ERROR) return VesaBiosOk; 00122 00123 /* Null-terminate strings */ 00124 VendorName[sizeof(OemString) - 1] = ANSI_NULL; 00125 ProductName[sizeof(OemString) - 1] = ANSI_NULL; 00126 ProductRevision[sizeof(OemString) - 1] = ANSI_NULL; 00127 OemString[sizeof(OemString) - 1] = ANSI_NULL; 00128 00129 /* Check for known bad BIOS */ 00130 VesaBiosOk = IsVesaBiosOk(&VgaExtension->Int10Interface, 00131 VbeInfo->Info.OemSoftwareRevision, 00132 VendorName, 00133 ProductName, 00134 ProductRevision); 00135 VgaExtension->VesaBiosOk = VesaBiosOk; 00136 return VesaBiosOk; 00137 } 00138 00139 VP_STATUS 00140 NTAPI 00141 VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension, 00142 IN PVIDEO_CLUT ClutBuffer) 00143 { 00144 PVBE_COLOR_REGISTER VesaClut; 00145 INT10_BIOS_ARGUMENTS BiosArguments; 00146 PVOID Context; 00147 ULONG Entries; 00148 ULONG BufferSize = 4 * 1024; 00149 USHORT TrampolineMemorySegment, TrampolineMemoryOffset; 00150 VP_STATUS Status; 00151 USHORT i; 00152 00153 Entries = ClutBuffer->NumEntries; 00154 00155 /* Allocate INT10 context/buffer */ 00156 VesaClut = VideoPortAllocatePool(VgaExtension, 1, sizeof(ULONG) * Entries, 0x20616756u); 00157 if (!VesaClut) return ERROR_INVALID_PARAMETER; 00158 if (!VgaExtension->Int10Interface.Size) return ERROR_INVALID_PARAMETER; 00159 Context = VgaExtension->Int10Interface.Context; 00160 Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context, 00161 &TrampolineMemorySegment, 00162 &TrampolineMemoryOffset, 00163 &BufferSize); 00164 if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; 00165 00166 /* VESA has color registers backward! */ 00167 for (i = 0; i < Entries; i++) 00168 { 00169 VesaClut[i].Blue = ClutBuffer->LookupTable[i].RgbArray.Blue; 00170 VesaClut[i].Green = ClutBuffer->LookupTable[i].RgbArray.Green; 00171 VesaClut[i].Red = ClutBuffer->LookupTable[i].RgbArray.Red; 00172 VesaClut[i].Pad = 0; 00173 } 00174 Status = VgaExtension->Int10Interface.Int10WriteMemory(Context, 00175 TrampolineMemorySegment, 00176 TrampolineMemoryOffset, 00177 VesaClut, 00178 Entries * sizeof(ULONG)); 00179 if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; 00180 00181 /* Write new palette */ 00182 BiosArguments.Ebx = 0; 00183 BiosArguments.Ecx = Entries; 00184 BiosArguments.Edx = ClutBuffer->FirstEntry; 00185 BiosArguments.Edi = TrampolineMemoryOffset; 00186 BiosArguments.SegEs = TrampolineMemorySegment; 00187 BiosArguments.Eax = VBE_SET_GET_PALETTE_DATA; 00188 Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); 00189 if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; 00190 VideoPortFreePool(VgaExtension, VesaClut); 00191 VideoPortDebugPrint(Error, "VBE Status: %lx\n", BiosArguments.Eax); 00192 if (BiosArguments.Eax == VBE_SUCCESS) return NO_ERROR; 00193 return ERROR_INVALID_PARAMETER; 00194 } 00195 00196 /* EOF */ Generated on Sat May 26 2012 04:36:58 for ReactOS by
1.7.6.1
|