check if VBE is available with multiboot

This commit is contained in:
valentinbreiz 2020-07-06 05:31:17 +02:00
parent f20d7f3930
commit cf019fef47
3 changed files with 27 additions and 2 deletions

View file

@ -64,6 +64,25 @@ namespace Cosmos.Core
public unsafe static class VBE
{
static uint VBEINFO_PRESENT = (1 << 11);
public static bool IsAvailable()
{
if ((Bootstrap.header->Flags & VBEINFO_PRESENT) == 0)
{
return false;
}
else
{
return true;
}
}
public static ModeInfo getModeInfo()
{
return *Bootstrap.modeinfo;
}
[StructLayout(LayoutKind.Explicit, Size = 36)]
public struct ControllerInfo
{

View file

@ -66,7 +66,7 @@ namespace Cosmos.System.Graphics
{
return new SVGAIICanvas();
}
else if (BGAExists() || PCI.GetDevice((VendorID)0x80EE, (DeviceID)0xBEEF) != null)
else if (BGAExists() || PCI.GetDevice((VendorID)0x80EE, (DeviceID)0xBEEF) != null || Core.VBE.IsAvailable())
{
return new VBECanvas();
}
@ -88,7 +88,7 @@ namespace Cosmos.System.Graphics
{
return new SVGAIICanvas(mode);
}
else if (BGAExists() || PCI.GetDevice((VendorID)0x80EE, (DeviceID)0xBEEF) != null)
else if (BGAExists() || PCI.GetDevice((VendorID)0x80EE, (DeviceID)0xBEEF) != null || Core.VBE.IsAvailable())
{
return new VBECanvas(mode);
}

View file

@ -44,6 +44,12 @@ namespace Cosmos.System.Graphics
{
Global.mDebugger.SendInternal($"Creating new VBEScreen() with mode {aMode.Columns}x{aMode.Rows}x{(uint)aMode.ColorDepth}");
if (Core.VBE.IsAvailable())
{
Core.VBE.ModeInfo ModeInfo = Core.VBE.getModeInfo();
aMode = new Mode(ModeInfo.width, ModeInfo.height, (ColorDepth)ModeInfo.bpp);
}
ThrowIfModeIsNotValid(aMode);
_VBEDriver = new VBEDriver((ushort)aMode.Columns, (ushort)aMode.Rows, (ushort)aMode.ColorDepth);