[VGA_NEW]

- Zero out the Int10 Bios call arguments structure before calling Videoprt Int10CallBios
 - Properly check for VESA BIOS return value from such calls
 - Use VGA registers to update the palette when possible.
Now bochs goes up to 3rd stage when using this driver in conjunction with framebuf_new.

svn path=/trunk/; revision=60063
This commit is contained in:
Jérôme Gardou 2013-09-12 20:25:24 +00:00
parent 1997f1ae38
commit 613e1df799
2 changed files with 73 additions and 37 deletions

View file

@ -91,7 +91,7 @@ ValidateVbeInfo(IN PHW_DEVICE_EXTENSION VgaExtension,
Context = VgaExtension->Int10Interface.Context; Context = VgaExtension->Int10Interface.Context;
/* Check magic and version */ /* Check magic and version */
if (VbeInfo->Info.Signature == VESA_MAGIC) return VesaBiosOk; if (VbeInfo->Info.Signature != VESA_MAGIC) return VesaBiosOk;
if (VbeInfo->Info.Version < 0x102) return VesaBiosOk; if (VbeInfo->Info.Version < 0x102) return VesaBiosOk;
/* Read strings */ /* Read strings */
@ -149,11 +149,31 @@ VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension,
USHORT TrampolineMemorySegment, TrampolineMemoryOffset; USHORT TrampolineMemorySegment, TrampolineMemoryOffset;
VP_STATUS Status; VP_STATUS Status;
USHORT i; USHORT i;
PVIDEOMODE CurrentMode = VgaExtension->CurrentMode;
Entries = ClutBuffer->NumEntries; Entries = ClutBuffer->NumEntries;
VideoPortDebugPrint(0, "Setting %lu entries.\n", Entries);
/*
* For Vga compatible modes, write them directly.
* Otherwise, the LGPL VGABIOS (used in bochs) fails!
* It is also said that this way is faster.
*/
if(!CurrentMode->NonVgaMode)
{
for (i=ClutBuffer->FirstEntry; i<ClutBuffer->FirstEntry + Entries; i++)
{
VideoPortWritePortUchar((PUCHAR)0x03c8, i);
VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Red);
VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Green);
VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Blue);
}
return NO_ERROR;
}
/* Allocate INT10 context/buffer */ /* Allocate INT10 context/buffer */
VesaClut = VideoPortAllocatePool(VgaExtension, 1, sizeof(ULONG) * Entries, 0x20616756u); VesaClut = VideoPortAllocatePool(VgaExtension, 1, sizeof(ULONG) * Entries, ' agV');
if (!VesaClut) return ERROR_INVALID_PARAMETER; if (!VesaClut) return ERROR_INVALID_PARAMETER;
if (!VgaExtension->Int10Interface.Size) return ERROR_INVALID_PARAMETER; if (!VgaExtension->Int10Interface.Size) return ERROR_INVALID_PARAMETER;
Context = VgaExtension->Int10Interface.Context; Context = VgaExtension->Int10Interface.Context;
@ -178,7 +198,8 @@ VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension,
Entries * sizeof(ULONG)); Entries * sizeof(ULONG));
if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER;
/* Write new palette */ /* Write the palette */
VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
BiosArguments.Ebx = 0; BiosArguments.Ebx = 0;
BiosArguments.Ecx = Entries; BiosArguments.Ecx = Entries;
BiosArguments.Edx = ClutBuffer->FirstEntry; BiosArguments.Edx = ClutBuffer->FirstEntry;
@ -189,7 +210,8 @@ VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension,
if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER;
VideoPortFreePool(VgaExtension, VesaClut); VideoPortFreePool(VgaExtension, VesaClut);
VideoPortDebugPrint(Error, "VBE Status: %lx\n", BiosArguments.Eax); VideoPortDebugPrint(Error, "VBE Status: %lx\n", BiosArguments.Eax);
if (BiosArguments.Eax == VBE_SUCCESS) return NO_ERROR; if (VBE_GETRETURNCODE(BiosArguments.Eax) == VBE_SUCCESS)
return NO_ERROR;
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
} }

View file

@ -58,13 +58,15 @@ VbeGetVideoMemoryBaseAddress(IN PHW_DEVICE_EXTENSION VgaExtension,
if (Status != NO_ERROR) return 0; if (Status != NO_ERROR) return 0;
/* Ask VBE BIOS for mode info */ /* Ask VBE BIOS for mode info */
VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
BiosArguments.Ecx = HIWORD(VgaMode->Mode); BiosArguments.Ecx = HIWORD(VgaMode->Mode);
BiosArguments.Edi = TrampolineMemorySegment; BiosArguments.Edi = TrampolineMemorySegment;
BiosArguments.SegEs = TrampolineMemoryOffset; BiosArguments.SegEs = TrampolineMemoryOffset;
BiosArguments.Eax = VBE_GET_MODE_INFORMATION; BiosArguments.Eax = VBE_GET_MODE_INFORMATION;
Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments);
if (Status != NO_ERROR) return 0; if (Status != NO_ERROR) return 0;
if (BiosArguments.Eax != VBE_SUCCESS) return 0; if (VBE_GETRETURNCODE(BiosArguments.Eax) != VBE_SUCCESS)
return 0;
Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
TrampolineMemorySegment, TrampolineMemorySegment,
TrampolineMemoryOffset, TrampolineMemoryOffset,
@ -94,23 +96,27 @@ VbeSetMode(IN PHW_DEVICE_EXTENSION VgaDeviceExtension,
VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments)); VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
ModeIndex = VgaMode->Mode; ModeIndex = VgaMode->Mode;
BiosArguments.Eax = ModeIndex & 0x0000FFFF; BiosArguments.Eax = VBE_SET_VBE_MODE;
BiosArguments.Ebx = ModeIndex >> 16; BiosArguments.Ebx = HIWORD(ModeIndex);
VideoPortDebugPrint(0, "Switching to %lx %lx\n", BiosArguments.Eax, BiosArguments.Ebx); VideoPortDebugPrint(0, "Switching to %lx %lx\n", BiosArguments.Eax, BiosArguments.Ebx);
Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments); Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments);
if (Status != NO_ERROR) return Status; if (Status != NO_ERROR) return Status;
if(VBE_GETRETURNCODE(BiosArguments.Eax) != VBE_SUCCESS)
VideoPortDebugPrint(0, "Changing VBE mode failed, Eax %lx", BiosArguments.Eax);
/* Check for VESA mode */ /* Check for VESA mode */
if (ModeIndex >> 16) if (ModeIndex >> 16)
{ {
/* Mode set fail */ /* Mode set fail */
if (BiosArguments.Eax != VBE_SUCCESS) return ERROR_INVALID_PARAMETER; if (VBE_GETRETURNCODE(BiosArguments.Eax) != VBE_SUCCESS)
return ERROR_INVALID_PARAMETER;
/* Check current mode is desired mode */ /* Check current mode is desired mode */
VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
BiosArguments.Eax = VBE_GET_CURRENT_VBE_MODE; BiosArguments.Eax = VBE_GET_CURRENT_VBE_MODE;
Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments); Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments);
if ((Status == NO_ERROR) && if ((Status == NO_ERROR) &&
(BiosArguments.Eax == VBE_SUCCESS) && (VBE_GETRETURNCODE(BiosArguments.Eax) == VBE_SUCCESS) &&
((BiosArguments.Ebx ^ (ModeIndex >> 16)) & VBE_MODE_BITS)) ((BiosArguments.Ebx ^ (ModeIndex >> 16)) & VBE_MODE_BITS))
{ {
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
@ -120,12 +126,13 @@ VbeSetMode(IN PHW_DEVICE_EXTENSION VgaDeviceExtension,
if (VgaMode->LogicalWidth != VgaMode->hres) if (VgaMode->LogicalWidth != VgaMode->hres)
{ {
/* Check setting works after being set */ /* Check setting works after being set */
VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
BiosArguments.Eax = VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH; BiosArguments.Eax = VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH;
BiosArguments.Ecx = VgaMode->LogicalWidth; BiosArguments.Ecx = VgaMode->LogicalWidth;
BiosArguments.Ebx = 0; BiosArguments.Ebx = 0;
Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments); Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments);
if ((Status != NO_ERROR) || if ((Status != NO_ERROR) ||
(BiosArguments.Eax != VBE_SUCCESS) || (VBE_GETRETURNCODE(BiosArguments.Eax) != VBE_SUCCESS) ||
(BiosArguments.Ecx != VgaMode->LogicalWidth)) (BiosArguments.Ecx != VgaMode->LogicalWidth))
{ {
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
@ -192,7 +199,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
} }
/* Add ref */ /* Add ref */
//VideoPortDebugPrint(0, "have int10 iface\n"); VideoPortDebugPrint(0, "have int10 iface\n");
VgaExtension->Int10Interface.InterfaceReference(VgaExtension->Int10Interface.Context); VgaExtension->Int10Interface.InterfaceReference(VgaExtension->Int10Interface.Context);
Context = VgaExtension->Int10Interface.Context; Context = VgaExtension->Int10Interface.Context;
@ -207,23 +214,28 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
if (!VbeInfo) return; if (!VbeInfo) return;
/* Init VBE data and write to card buffer */ /* Init VBE data and write to card buffer */
//VideoPortDebugPrint(0, "have int10 data\n"); VideoPortDebugPrint(0, "have int10 data\n");
VbeInfo->ModeArray[128] = 0xFFFF; VbeInfo->ModeArray[128] = 0xFFFF;
VbeInfo->Info.Signature = VBE2_MAGIC; VbeInfo->Info.Signature = VBE2_MAGIC;
Status = VgaExtension->Int10Interface.Int10WriteMemory(Context, Status = VgaExtension->Int10Interface.Int10WriteMemory(Context,
TrampolineMemorySegment, TrampolineMemorySegment,
TrampolineMemoryOffset, TrampolineMemoryOffset,
VbeInfo, &VbeInfo->Info.Signature,
512); 4);
if (Status != NO_ERROR) return; if (Status != NO_ERROR) return;
/* Get controller info */ /* Get controller info */
VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
BiosArguments.Edi = TrampolineMemoryOffset; BiosArguments.Edi = TrampolineMemoryOffset;
BiosArguments.SegEs = TrampolineMemorySegment; BiosArguments.SegEs = TrampolineMemorySegment;
BiosArguments.Eax = VBE_GET_CONTROLLER_INFORMATION; BiosArguments.Eax = VBE_GET_CONTROLLER_INFORMATION;
Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments);
if (Status != NO_ERROR) return; if (Status != NO_ERROR) return;
if (BiosArguments.Eax != VBE_SUCCESS) return; if(VBE_GETRETURNCODE(BiosArguments.Eax) != VBE_SUCCESS)
{
VideoPortDebugPrint(0, "BiosArguments.Eax %lx\n", BiosArguments.Eax);
return;
}
Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
TrampolineMemorySegment, TrampolineMemorySegment,
TrampolineMemoryOffset, TrampolineMemoryOffset,
@ -232,21 +244,21 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
if (Status != NO_ERROR) return; if (Status != NO_ERROR) return;
/* Check correct VBE BIOS */ /* Check correct VBE BIOS */
//VideoPortDebugPrint(0, "have vbe data\n"); VideoPortDebugPrint(0, "have vbe data\n");
TotalMemory = VbeInfo->Info.TotalMemory << 16; TotalMemory = VbeInfo->Info.TotalMemory << 16;
VbeVersion = VbeInfo->Info.Version; VbeVersion = VbeInfo->Info.Version;
VideoPortDebugPrint(0, "vbe version %lx memory %lx\n", VbeVersion, TotalMemory); VideoPortDebugPrint(0, "vbe version %lx memory %lx\n", VbeVersion, TotalMemory);
if (!ValidateVbeInfo(VgaExtension, VbeInfo)) return; if (!ValidateVbeInfo(VgaExtension, VbeInfo)) return;
/* Read modes */ /* Read modes */
//VideoPortDebugPrint(0, "read modes from %p\n", VbeInfo->Info.VideoModePtr); VideoPortDebugPrint(0, "read modes from %p\n", VbeInfo->Info.VideoModePtr);
Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
HIWORD(VbeInfo->Info.VideoModePtr), HIWORD(VbeInfo->Info.VideoModePtr),
LOWORD(VbeInfo->Info.VideoModePtr), LOWORD(VbeInfo->Info.VideoModePtr),
VbeInfo->ModeArray, VbeInfo->ModeArray,
128 * sizeof(USHORT)); 128 * sizeof(USHORT));
if (Status != NO_ERROR) return; if (Status != NO_ERROR) return;
//VideoPortDebugPrint(0, "Read modes at: %p\n", VbeInfo->ModeArray); VideoPortDebugPrint(0, "Read modes at: %p\n", VbeInfo->ModeArray);
/* Count modes, check for new 4bpp SVGA modes */ /* Count modes, check for new 4bpp SVGA modes */
ThisMode = VbeInfo->ModeArray; ThisMode = VbeInfo->ModeArray;
@ -254,7 +266,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
while (ModeResult != 0xFFFF) while (ModeResult != 0xFFFF)
{ {
Mode = ModeResult & 0x1FF; Mode = ModeResult & 0x1FF;
//VideoPortDebugPrint(0, "Mode found: %lx\n", Mode); VideoPortDebugPrint(0, "Mode found: %lx\n", Mode);
if ((Mode == 0x102) || (Mode == 0x6A)) FourBppModeFound = TRUE; if ((Mode == 0x102) || (Mode == 0x6A)) FourBppModeFound = TRUE;
ModeResult = *++ThisMode; ModeResult = *++ThisMode;
NewModes++; NewModes++;
@ -277,20 +289,22 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
} }
/* Scan SVGA modes */ /* Scan SVGA modes */
// VideoPortDebugPrint(0, "Static modes: %d\n", NumVideoModes); VideoPortDebugPrint(0, "Static modes: %d\n", NumVideoModes);
VgaMode = &VgaModeList[NumVideoModes]; VgaMode = &VgaModeList[NumVideoModes];
ThisMode = VbeInfo->ModeArray; ThisMode = VbeInfo->ModeArray;
//VideoPortDebugPrint(0, "new modes: %d\n", NewModes); VideoPortDebugPrint(0, "new modes: %d\n", NewModes);
while (NewModes--) while (NewModes--)
{ {
/* Get info on mode */ /* Get info on mode */
VideoPortDebugPrint(0, "Getting info of mode %lx.\n", *ThisMode);
VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
BiosArguments.Eax = VBE_GET_MODE_INFORMATION; BiosArguments.Eax = VBE_GET_MODE_INFORMATION;
BiosArguments.Ecx = *ThisMode; BiosArguments.Ecx = *ThisMode;
BiosArguments.Edi = TrampolineMemoryOffset; BiosArguments.Edi = TrampolineMemoryOffset;
BiosArguments.SegEs = TrampolineMemorySegment; BiosArguments.SegEs = TrampolineMemorySegment;
Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments);
if (Status != NO_ERROR) goto Next; if (Status != NO_ERROR) goto Next;
if (BiosArguments.Eax != VBE_SUCCESS) goto Next; if (VBE_GETRETURNCODE(BiosArguments.Eax) != VBE_SUCCESS) goto Next;
Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, Status = VgaExtension->Int10Interface.Int10ReadMemory(Context,
TrampolineMemorySegment, TrampolineMemorySegment,
TrampolineMemoryOffset, TrampolineMemoryOffset,
@ -299,7 +313,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
if (Status != NO_ERROR) goto Next; if (Status != NO_ERROR) goto Next;
/* Parse graphics modes only if linear framebuffer support */ /* Parse graphics modes only if linear framebuffer support */
//VideoPortDebugPrint(0, "attr: %lx\n", VbeModeInfo->ModeAttributes); VideoPortDebugPrint(0, "attr: %lx\n", VbeModeInfo->ModeAttributes);
if (!(VbeModeInfo->ModeAttributes & (VBE_MODEATTR_VALID | if (!(VbeModeInfo->ModeAttributes & (VBE_MODEATTR_VALID |
VBE_MODEATTR_GRAPHICS))) goto Next; VBE_MODEATTR_GRAPHICS))) goto Next;
LinearAddressing = ((VbeVersion >= 0x200) && LinearAddressing = ((VbeVersion >= 0x200) &&
@ -308,7 +322,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
TRUE : FALSE; TRUE : FALSE;
/* Check SVGA modes if 8bpp or higher */ /* Check SVGA modes if 8bpp or higher */
//VideoPortDebugPrint(0, "PhysBase: %lx\n", VbeModeInfo->PhysBasePtr); VideoPortDebugPrint(0, "PhysBase: %lx\n", VbeModeInfo->PhysBasePtr);
if ((VbeModeInfo->XResolution >= 640) && if ((VbeModeInfo->XResolution >= 640) &&
(VbeModeInfo->YResolution >= 480) && (VbeModeInfo->YResolution >= 480) &&
(VbeModeInfo->NumberOfPlanes >= 1) && (VbeModeInfo->NumberOfPlanes >= 1) &&
@ -322,7 +336,7 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
VgaMode->Frequency = 1; VgaMode->Frequency = 1;
VgaMode->Mode = (*ThisMode << 16) | VBE_SET_VBE_MODE; VgaMode->Mode = (*ThisMode << 16) | VBE_SET_VBE_MODE;
VgaMode->Granularity = VbeModeInfo->WinGranularity << 10; VgaMode->Granularity = VbeModeInfo->WinGranularity << 10;
//VideoPortDebugPrint(0, "Mode %lx (Granularity %d)\n", VgaMode->Mode, VgaMode->Granularity); VideoPortDebugPrint(0, "Mode %lx (Granularity %d)\n", VgaMode->Mode, VgaMode->Granularity);
/* Set flags */ /* Set flags */
if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_COLOR) VgaMode->fbType |= VIDEO_MODE_COLOR; if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_COLOR) VgaMode->fbType |= VIDEO_MODE_COLOR;
@ -332,12 +346,12 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
/* If no char data, say 80x25 */ /* If no char data, say 80x25 */
VgaMode->col = VbeModeInfo->XCharSize ? VbeModeInfo->XResolution / VbeModeInfo->XCharSize : 80; VgaMode->col = VbeModeInfo->XCharSize ? VbeModeInfo->XResolution / VbeModeInfo->XCharSize : 80;
VgaMode->row = VbeModeInfo->YCharSize ? VbeModeInfo->YResolution / VbeModeInfo->YCharSize : 25; VgaMode->row = VbeModeInfo->YCharSize ? VbeModeInfo->YResolution / VbeModeInfo->YCharSize : 25;
//VideoPortDebugPrint(0, "%d by %d rows\n", VgaMode->Columns, VgaMode->Rows); VideoPortDebugPrint(0, "%d by %d rows\n", VgaMode->col, VgaMode->row);
/* Check RGB555 (15bpp only) */ /* Check RGB555 (15bpp only) */
VgaMode->bitsPerPlane = VbeModeInfo->BitsPerPixel / VbeModeInfo->NumberOfPlanes; VgaMode->bitsPerPlane = VbeModeInfo->BitsPerPixel / VbeModeInfo->NumberOfPlanes;
if ((VgaMode->bitsPerPlane == 16) && (VbeModeInfo->GreenMaskSize == 5)) VgaMode->bitsPerPlane = 15; if ((VgaMode->bitsPerPlane == 16) && (VbeModeInfo->GreenMaskSize == 5)) VgaMode->bitsPerPlane = 15;
//VideoPortDebugPrint(0, "BPP: %d\n", VgaMode->BitsPerPlane); VideoPortDebugPrint(0, "BPP: %d\n", VgaMode->bitsPerPlane);
/* Do linear or banked frame buffers */ /* Do linear or banked frame buffers */
VgaMode->FrameBufferBase = 0; VgaMode->FrameBufferBase = 0;
@ -347,18 +361,18 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
ScreenStride = RaiseToPower2(VbeModeInfo->BytesPerScanLine); ScreenStride = RaiseToPower2(VbeModeInfo->BytesPerScanLine);
//ASSERT(ScreenStride <= MAX_USHORT); //ASSERT(ScreenStride <= MAX_USHORT);
VgaMode->wbytes = (USHORT)ScreenStride; VgaMode->wbytes = (USHORT)ScreenStride;
//VideoPortDebugPrint(0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->Stride); VideoPortDebugPrint(0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->wbytes);
/* Size of frame buffer is Height X ScanLine, align to bank/page size */ /* Size of frame buffer is Height X ScanLine, align to bank/page size */
ScreenSize = VgaMode->hres * ScreenStride; ScreenSize = VgaMode->hres * ScreenStride;
//VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize);
Size = (ScreenSize + ((64 * 1024) - 1)) & ((64 * 1024) - 1); Size = (ScreenSize + ((64 * 1024) - 1)) & ((64 * 1024) - 1);
//VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize);
if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1); if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1);
//VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize);
/* Banked VGA at 0xA0000 (64K) */ /* Banked VGA at 0xA0000 (64K) */
//VideoPortDebugPrint(0, "Final size: %lx\n", Size); VideoPortDebugPrint(0, "Final size: %lx\n", Size);
VgaMode->fbType |= VIDEO_MODE_BANKED; VgaMode->fbType |= VIDEO_MODE_BANKED;
VgaMode->sbytes = Size; VgaMode->sbytes = Size;
VgaMode->PhysSize = 64 * 1024; VgaMode->PhysSize = 64 * 1024;
@ -370,20 +384,20 @@ InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension)
else else
{ {
/* VBE 3.00+ has specific field, read legacy field if not */ /* VBE 3.00+ has specific field, read legacy field if not */
//VideoPortDebugPrint(0, "LINEAR MODE!!!\n"); VideoPortDebugPrint(0, "LINEAR MODE!!!\n");
ScreenStride = (VbeVersion >= 0x300) ? VbeModeInfo->LinBytesPerScanLine : 0; ScreenStride = (VbeVersion >= 0x300) ? VbeModeInfo->LinBytesPerScanLine : 0;
if (!ScreenStride) ScreenStride = VbeModeInfo->BytesPerScanLine; if (!ScreenStride) ScreenStride = VbeModeInfo->BytesPerScanLine;
//ASSERT(ScreenStride <= MAX_USHORT); //ASSERT(ScreenStride <= MAX_USHORT);
VgaMode->wbytes = (USHORT)ScreenStride; VgaMode->wbytes = (USHORT)ScreenStride;
//VideoPortDebugPrint(0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->Stride); VideoPortDebugPrint(0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->wbytes);
/* Size of frame buffer is Height X ScanLine, align to page size */ /* Size of frame buffer is Height X ScanLine, align to page size */
ScreenSize = VgaMode->hres * LOWORD(VgaMode->wbytes); ScreenSize = VgaMode->hres * LOWORD(VgaMode->wbytes);
//VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize);
Size = RaiseToPower2Ulong(ScreenSize); Size = RaiseToPower2Ulong(ScreenSize);
//VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize);
if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1); if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1);
//VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize);
/* Linear VGA must read settings from VBE */ /* Linear VGA must read settings from VBE */
VgaMode->fbType |= VIDEO_MODE_LINEAR; VgaMode->fbType |= VIDEO_MODE_LINEAR;