160{
169 USHORT TrampolineMemorySegment;
170 USHORT TrampolineMemoryOffset;
183
184
187 {
188 VgaExtension->Int10Interface.Size = 0;
189 VgaExtension->Int10Interface.Version = 0;
190 return;
191 }
192
193
199 {
200 VgaExtension->Int10Interface.Size = 0;
201 VgaExtension->Int10Interface.Version = 0;
202 }
203
204
206 VgaExtension->Int10Interface.InterfaceReference(VgaExtension->Int10Interface.Context);
207 Context = VgaExtension->Int10Interface.Context;
208
209
210 Status = VgaExtension->Int10Interface.Int10AllocateBuffer(
Context,
211 &TrampolineMemorySegment,
212 &TrampolineMemoryOffset,
216 if (!VbeInfo) return;
217
218 VbeModeInfo = &VbeInfo->Modes;
219
220
222 VbeInfo->ModeArray[128] = 0xFFFF;
224 Status = VgaExtension->Int10Interface.Int10WriteMemory(
Context,
225 TrampolineMemorySegment,
226 TrampolineMemoryOffset,
228 4);
230
231
233 BiosArguments.
Edi = TrampolineMemoryOffset;
234 BiosArguments.
SegEs = TrampolineMemorySegment;
236 Status = VgaExtension->Int10Interface.Int10CallBios(
Context, &BiosArguments);
239 {
241 return;
242 }
243 Status = VgaExtension->Int10Interface.Int10ReadMemory(
Context,
244 TrampolineMemorySegment,
245 TrampolineMemoryOffset,
246 VbeInfo,
247 512);
249
250
253 VbeVersion = VbeInfo->Info.
Version;
254 VideoDebugPrint((0,
"vbe version %lx memory %lx\n", VbeVersion, TotalMemory));
256
257
259 Status = VgaExtension->Int10Interface.Int10ReadMemory(
Context,
262 VbeInfo->ModeArray,
266
267
268 ThisMode = VbeInfo->ModeArray;
269 ModeResult = VbeInfo->ModeArray[0];
270 while (ModeResult != 0xFFFF)
271 {
272 Mode = ModeResult & 0x1FF;
274 if ((
Mode == 0x102) || (
Mode == 0x6A)) FourBppModeFound =
TRUE;
275 ModeResult = *++ThisMode;
276 NewModes++;
277 }
278
279
282
283
287
288
290 {
293 }
294
295
298 ThisMode = VbeInfo->ModeArray;
300 while (NewModes--)
301 {
302
306 BiosArguments.
Ecx = *ThisMode;
307 BiosArguments.
Edi = TrampolineMemoryOffset;
308 BiosArguments.
SegEs = TrampolineMemorySegment;
309 Status = VgaExtension->Int10Interface.Int10CallBios(
Context, &BiosArguments);
312 Status = VgaExtension->Int10Interface.Int10ReadMemory(
Context,
313 TrampolineMemorySegment,
314 TrampolineMemoryOffset,
315 VbeModeInfo,
316 256);
318
319
323 LinearAddressing = ((VbeVersion >= 0x200) &&
327
328
334 {
335
344
345
349
350
354
355
359
360
362 if (!LinearAddressing)
363 {
364
366
369
370
371 ScreenSize =
VgaMode->hres * ScreenStride;
373 Size = (ScreenSize + ((64 * 1024) - 1)) & ((64 * 1024) - 1);
375 if (
Size > TotalMemory)
Size = (
Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1);
377
378
383 VgaMode->FrameBufferSize = 64 * 1024;
387 }
388 else
389 {
390
394
397
398
403 if (
Size > TotalMemory)
Size = (
Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1);
405
406
414
415
417 }
418
419
421
422
423 if (ScreenSize <= TotalMemory)
424 {
426 ModeCount++;
427 }
428 }
429Next:
430
431 ThisMode++;
432 }
433
434
435 VideoDebugPrint((0,
"mode scan complete. Total modes: %d\n", ModeCount));
437 {
438
442 {
444 }
445 else
446 {
447
448 ModeCount = 0;
449 }
450 }
451
452
454 VgaExtension->Int10Interface.Int10FreeBuffer(
Context,
455 TrampolineMemorySegment,
456 TrampolineMemoryOffset);
458 return;
459
461
464 VgaExtension->Int10Interface.Int10FreeBuffer(
Context,
465 TrampolineMemorySegment,
466 TrampolineMemoryOffset);
467}
static const WCHAR Cleanup[]
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define VIDEO_MODE_GRAPHICS
#define VIDEO_MODE_LINEAR
#define VIDEO_MODE_BANKED
struct _VIDEO_PORT_INT10_INTERFACE VIDEO_PORT_INT10_INTERFACE
VPAPI VOID NTAPI VideoPortZeroMemory(IN PVOID Destination, IN ULONG Length)
VPAPI PVOID NTAPI VideoPortGetDeviceBase(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS IoAddress, IN ULONG NumberOfUchars, IN UCHAR InIoSpace)
VPAPI VOID NTAPI VideoPortFreeDeviceBase(IN PVOID HwDeviceExtension, IN PVOID MappedAddress)
VPAPI BOOLEAN NTAPI VideoPortIsNoVesa(VOID)
VPAPI VOID NTAPI VideoPortFreePool(IN PVOID HwDeviceExtension, IN PVOID Ptr)
VPAPI VP_STATUS NTAPI VideoPortQueryServices(IN PVOID HwDeviceExtension, IN VIDEO_PORT_SERVICES ServicesType, IN OUT PINTERFACE Interface)
VPAPI VOID NTAPI VideoPortMoveMemory(IN PVOID Destination, IN PVOID Source, IN ULONG Length)
#define VIDEO_PORT_INT10_INTERFACE_VERSION_1
VPAPI PVOID NTAPI VideoPortAllocatePool(IN PVOID HwDeviceExtension, IN VP_POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
#define VideoDebugPrint(x)
USHORT LinBytesPerScanLine
ULONG NTAPI RaiseToPower2Ulong(IN ULONG Value)
ULONG NTAPI RaiseToPower2(IN USHORT Value)
#define VBE_GETRETURNCODE(x)
#define VBE_GET_MODE_INFORMATION
#define VBE_GET_CONTROLLER_INFORMATION
#define VBE_MODEATTR_LINEAR
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
BOOLEAN g_bIntelBrookdaleBIOS
BOOLEAN NTAPI ValidateVbeInfo(IN PHW_DEVICE_EXTENSION VgaExtension, IN PVBE_INFO VbeInfo)
#define VBE_MODEATTR_NO_BANK_SWITCH
#define VBE_MODEATTR_COLOR
#define VBE_MODEATTR_NON_VGA
#define VBE_MODEATTR_GRAPHICS
#define VBE_MODEATTR_VALID
#define VBE_MODE_LINEAR_FRAMEBUFFER
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress