ReactOS 0.4.16-dev-109-gf4cb10f
vbe.c File Reference
#include "vga.h"
Include dependency graph for vbe.c:

Go to the source code of this file.

Functions

BOOLEAN NTAPI IsVesaBiosOk (IN PVIDEO_PORT_INT10_INTERFACE Interface, IN ULONG OemRevision, IN PCHAR Vendor, IN PCHAR Product, IN PCHAR Revision)
 
BOOLEAN NTAPI ValidateVbeInfo (IN PHW_DEVICE_EXTENSION VgaExtension, IN PVBE_INFO VbeInfo)
 
VP_STATUS NTAPI VbeSetColorLookup (IN PHW_DEVICE_EXTENSION VgaExtension, IN PVIDEO_CLUT ClutBuffer)
 

Variables

static const CHAR Nv11Board [] = "NV11 (GeForce2) Board"
 
static const CHAR Nv11Chip [] = "Chip Rev B2"
 
static const CHAR Nv11Vendor [] = "NVidia Corporation"
 
static const CHAR IntelBrookdale [] = "Brookdale-G Graphics Controller"
 
static const PCHAR BrokenVesaBiosList []
 
BOOLEAN g_bIntelBrookdaleBIOS
 

Function Documentation

◆ IsVesaBiosOk()

BOOLEAN NTAPI IsVesaBiosOk ( IN PVIDEO_PORT_INT10_INTERFACE  Interface,
IN ULONG  OemRevision,
IN PCHAR  Vendor,
IN PCHAR  Product,
IN PCHAR  Revision 
)

Definition at line 37 of file vbe.c.

42{
43 ULONG i;
44 CHAR Version[21];
45
46 /* If the broken VESA bios found, turn VESA off */
47 VideoDebugPrint((0, "Vendor: %s Product: %s Revision: %s (%lx)\n", Vendor, Product, Revision, OemRevision));
48 for (i = 0; i < (sizeof(BrokenVesaBiosList) / sizeof(PCHAR)); i++)
49 {
50 if (!strncmp(Product, BrokenVesaBiosList[i], strlen(BrokenVesaBiosList[i]))) return FALSE;
51 }
52
53 /* For Brookdale-G (Intel), special hack used */
55
56 /* For NVIDIA make sure */
57 if (!(strncmp(Vendor, Nv11Vendor, sizeof(Nv11Vendor) - 1)) &&
58 !(strncmp(Product, Nv11Board, sizeof(Nv11Board) - 1)) &&
59 !(strncmp(Revision, Nv11Chip, sizeof(Nv11Chip) - 1)) &&
60 (OemRevision == 0x311))
61 {
62 /* Read version */
63 if (Interface->Int10ReadMemory(Interface->Context,
64 0xC000,
65 345,
66 Version,
67 sizeof(Version))) return FALSE;
68 if (!strncmp(Version, "Version 3.11.01.24N16", sizeof(Version))) return FALSE;
69 }
70
71 /* VESA ok */
72 VideoDebugPrint((0, "Vesa ok\n"));
73 return TRUE;
74}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG Revision
Definition: rtlfuncs.h:1142
#define VideoDebugPrint(x)
Definition: video.h:75
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
static const CHAR IntelBrookdale[]
Definition: vbe.c:18
BOOLEAN g_bIntelBrookdaleBIOS
Definition: vbe.c:31
static const PCHAR BrokenVesaBiosList[]
Definition: vbe.c:19
static const CHAR Nv11Board[]
Definition: vbe.c:15
static const CHAR Nv11Chip[]
Definition: vbe.c:16
static const CHAR Nv11Vendor[]
Definition: vbe.c:17
char CHAR
Definition: xmlstorage.h:175

Referenced by ValidateVbeInfo().

◆ ValidateVbeInfo()

BOOLEAN NTAPI ValidateVbeInfo ( IN PHW_DEVICE_EXTENSION  VgaExtension,
IN PVBE_INFO  VbeInfo 
)

Definition at line 78 of file vbe.c.

80{
81 BOOLEAN VesaBiosOk;
83 CHAR ProductRevision[80];
84 CHAR OemString[80];
85 CHAR ProductName[80];
86 CHAR VendorName[80];
88
89 /* Set default */
90 VesaBiosOk = FALSE;
91 Context = VgaExtension->Int10Interface.Context;
92
93 /* Check magic and version */
94 if (VbeInfo->Info.Signature != VESA_MAGIC) return VesaBiosOk;
95 if (VbeInfo->Info.Version < 0x102) return VesaBiosOk;
96
97 /* Read strings */
98 Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
99 HIWORD(VbeInfo->Info.OemStringPtr),
100 LOWORD(VbeInfo->Info.OemStringPtr),
101 OemString,
102 sizeof(OemString));
103 if (Status != NO_ERROR) return VesaBiosOk;
104 Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
105 HIWORD(VbeInfo->Info.OemVendorNamePtr),
106 LOWORD(VbeInfo->Info.OemVendorNamePtr),
108 sizeof(VendorName));
109 if (Status != NO_ERROR) return VesaBiosOk;
110 Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
111 HIWORD(VbeInfo->Info.OemProductNamePtr),
112 LOWORD(VbeInfo->Info.OemProductNamePtr),
113 ProductName,
114 sizeof(ProductName));
115 if (Status != NO_ERROR) return VesaBiosOk;
116 Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
117 HIWORD(VbeInfo->Info.OemProductRevPtr),
118 LOWORD(VbeInfo->Info.OemProductRevPtr),
119 ProductRevision,
120 sizeof(ProductRevision));
121 if (Status != NO_ERROR) return VesaBiosOk;
122
123 /* Null-terminate strings */
124 VendorName[sizeof(OemString) - 1] = ANSI_NULL;
125 ProductName[sizeof(OemString) - 1] = ANSI_NULL;
126 ProductRevision[sizeof(OemString) - 1] = ANSI_NULL;
127 OemString[sizeof(OemString) - 1] = ANSI_NULL;
128
129 /* Check for known bad BIOS */
130 VesaBiosOk = IsVesaBiosOk(&VgaExtension->Int10Interface,
131 VbeInfo->Info.OemSoftwareRevision,
133 ProductName,
134 ProductRevision);
135 VgaExtension->VesaBiosOk = VesaBiosOk;
136 return VesaBiosOk;
137}
static const char VendorName[]
Definition: ParaNdis-Oid.c:36
unsigned char BOOLEAN
#define NO_ERROR
Definition: dderror.h:5
Status
Definition: gdiplustypes.h:25
#define ANSI_NULL
#define LOWORD(l)
Definition: pedump.c:82
LONG VP_STATUS
Definition: video.h:153
#define HIWORD(l)
Definition: typedefs.h:247
BOOLEAN NTAPI IsVesaBiosOk(IN PVIDEO_PORT_INT10_INTERFACE Interface, IN ULONG OemRevision, IN PCHAR Vendor, IN PCHAR Product, IN PCHAR Revision)
Definition: vbe.c:37
#define VESA_MAGIC
Definition: vga.h:448
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1574

Referenced by InitializeModeTable().

◆ VbeSetColorLookup()

VP_STATUS NTAPI VbeSetColorLookup ( IN PHW_DEVICE_EXTENSION  VgaExtension,
IN PVIDEO_CLUT  ClutBuffer 
)

Definition at line 141 of file vbe.c.

143{
144 PVBE_COLOR_REGISTER VesaClut;
145 INT10_BIOS_ARGUMENTS BiosArguments;
148 ULONG BufferSize = 4 * 1024;
149 USHORT TrampolineMemorySegment, TrampolineMemoryOffset;
151 USHORT i;
152 PVIDEOMODE CurrentMode = VgaExtension->CurrentMode;
153
154 Entries = ClutBuffer->NumEntries;
155
156 VideoDebugPrint((0, "Setting %lu entries.\n", Entries));
157
158 /*
159 * For Vga compatible modes, write them directly.
160 * Otherwise, the LGPL VGABIOS (used in bochs) fails!
161 * It is also said that this way is faster.
162 */
163 if(!CurrentMode->NonVgaMode)
164 {
165 for (i=ClutBuffer->FirstEntry; i<ClutBuffer->FirstEntry + Entries; i++)
166 {
168 VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Red);
169 VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Green);
170 VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Blue);
171 }
172 return NO_ERROR;
173 }
174
175 /* Allocate INT10 context/buffer */
176 VesaClut = VideoPortAllocatePool(VgaExtension, 1, sizeof(ULONG) * Entries, ' agV');
177 if (!VesaClut) return ERROR_INVALID_PARAMETER;
178 if (!VgaExtension->Int10Interface.Size) return ERROR_INVALID_PARAMETER;
179 Context = VgaExtension->Int10Interface.Context;
180 Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context,
181 &TrampolineMemorySegment,
182 &TrampolineMemoryOffset,
183 &BufferSize);
185
186 /* VESA has color registers backward! */
187 for (i = 0; i < Entries; i++)
188 {
189 VesaClut[i].Blue = ClutBuffer->LookupTable[i].RgbArray.Blue;
190 VesaClut[i].Green = ClutBuffer->LookupTable[i].RgbArray.Green;
191 VesaClut[i].Red = ClutBuffer->LookupTable[i].RgbArray.Red;
192 VesaClut[i].Pad = 0;
193 }
194 Status = VgaExtension->Int10Interface.Int10WriteMemory(Context,
195 TrampolineMemorySegment,
196 TrampolineMemoryOffset,
197 VesaClut,
198 Entries * sizeof(ULONG));
200
201 /* Write the palette */
202 VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
203 BiosArguments.Ebx = 0;
204 BiosArguments.Ecx = Entries;
205 BiosArguments.Edx = ClutBuffer->FirstEntry;
206 BiosArguments.Edi = TrampolineMemoryOffset;
207 BiosArguments.SegEs = TrampolineMemorySegment;
208 BiosArguments.Eax = VBE_SET_GET_PALETTE_DATA;
209 Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments);
211 VideoPortFreePool(VgaExtension, VesaClut);
212 VideoDebugPrint((Error, "VBE Status: %lx\n", BiosArguments.Eax));
213 if (VBE_GETRETURNCODE(BiosArguments.Eax) == VBE_SUCCESS)
214 return NO_ERROR;
216}
static const ENTRY Entries[]
BOOL Error
Definition: chkdsk.c:66
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
unsigned short USHORT
Definition: pedump.c:61
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
VPAPI VOID NTAPI VideoPortFreePool(IN PVOID HwDeviceExtension, IN PVOID Ptr)
Definition: resource.c:1039
VPAPI PVOID NTAPI VideoPortAllocatePool(IN PVOID HwDeviceExtension, IN VP_POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: resource.c:1024
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)
unsigned char * PUCHAR
Definition: typedefs.h:53
#define VBE_SUCCESS
Definition: vbemp.h:95
#define VBE_GETRETURNCODE(x)
Definition: vbemp.h:100
#define VBE_SET_GET_PALETTE_DATA
Definition: vbemp.h:55
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by VgaSetColorLookup().

Variable Documentation

◆ BrokenVesaBiosList

const PCHAR BrokenVesaBiosList[]
static
Initial value:
=
{
"SiS 5597",
"MGA-G100",
"3Dfx Banshee",
"Voodoo3 2000 LC ",
"Voodoo3 3000 LC ",
"Voodoo4 4500 ",
"ArtX I",
"ATI S1-370TL"
}

Definition at line 19 of file vbe.c.

Referenced by IsVesaBiosOk().

◆ g_bIntelBrookdaleBIOS

BOOLEAN g_bIntelBrookdaleBIOS

Definition at line 31 of file vbe.c.

Referenced by InitializeModeTable(), and IsVesaBiosOk().

◆ IntelBrookdale

const CHAR IntelBrookdale[] = "Brookdale-G Graphics Controller"
static

Definition at line 18 of file vbe.c.

Referenced by IsVesaBiosOk().

◆ Nv11Board

const CHAR Nv11Board[] = "NV11 (GeForce2) Board"
static

Definition at line 15 of file vbe.c.

Referenced by IsVesaBiosOk().

◆ Nv11Chip

const CHAR Nv11Chip[] = "Chip Rev B2"
static

Definition at line 16 of file vbe.c.

Referenced by IsVesaBiosOk().

◆ Nv11Vendor

const CHAR Nv11Vendor[] = "NVidia Corporation"
static

Definition at line 17 of file vbe.c.

Referenced by IsVesaBiosOk().