/// <summary> /// Create new instance of the <see cref="VBEDriver"/> class. /// </summary> /// <param name="xres">X resolution.</param> /// <param name="yres">Y resolution.</param> /// <param name="bpp">BPP (color depth).</param> public VBEDriver(ushort xres, ushort yres, ushort bpp) { PCIDevice videocard; mScrollSize = (xres * yres) * (bpp / 8); mRow2Addr = xres * (bpp / 8) * 16; if (VBE.IsAvailable()) //VBE VESA Enabled Mulitboot Parsing { Global.mDebugger.SendInternal($"Creating VBE VESA driver with Mode {xres}*{yres}@{bpp}"); IO.LinearFrameBuffer = new MemoryBlock(VBE.getLfbOffset(), (uint)xres * yres * (uint)(bpp / 8)); } else if (ISAModeAvailable()) //Bochs Graphics Adaptor ISA Mode { Global.mDebugger.SendInternal($"Creating VBE BGA driver with Mode {xres}*{yres}@{bpp}."); IO.LinearFrameBuffer = new MemoryBlock(0xE0000000, 1920 * 1200 * 4); VBESet(xres, yres, bpp); } else if (((videocard = HAL.PCI.GetDevice(VendorID.VirtualBox, DeviceID.VBVGA)) != null) || //VirtualBox Video Adapter PCI Mode ((videocard = HAL.PCI.GetDevice(VendorID.Bochs, DeviceID.BGA)) != null)) // Bochs Graphics Adaptor PCI Mode { Global.mDebugger.SendInternal($"Creating VBE BGA driver with Mode {xres}*{yres}@{bpp}. Framebuffer address=" + videocard.BAR0); IO.LinearFrameBuffer = new MemoryBlock(videocard.BAR0, 1920 * 1200 * 4); VBESet(xres, yres, bpp); } else { throw new Exception("No supported VBE device found."); } }
/// <summary> /// Checks is VBE is supported exists /// </summary> /// <returns></returns> private static bool VBEAvailable() { if (BGAExists()) { return(true); } else if (PCI.Exists(VendorID.VirtualBox, DeviceID.VBVGA)) { return(true); } else if (PCI.Exists(VendorID.Bochs, DeviceID.BGA)) { return(true); } else if (VBE.IsAvailable()) { return(true); } else { return(false); } }