From d5cc9cd7fe86337ff1e4ea7e06e70c0622728195 Mon Sep 17 00:00:00 2001 From: valentinbreiz Date: Thu, 16 Jul 2020 21:07:43 +0200 Subject: [PATCH] remove useless using + VBEAvailable function --- source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs | 4 +-- source/Cosmos.HAL2/PCIDevice.cs | 1 - .../Graphics/FullScreenCanvas.cs | 31 ++++++++++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs b/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs index d97846d7c..e7329e6f8 100644 --- a/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs +++ b/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs @@ -84,7 +84,7 @@ namespace Cosmos.HAL.Drivers IO.LinearFrameBuffer = new MemoryBlock(VBE.getLfbOffset(), (uint)xres * yres * (uint)(bpp / 8)); lastbuffer = new ManagedMemoryBlock((uint)xres * yres * (uint)(bpp / 8)); } - else if (Available()) //Bochs Graphics Adaptor ISA Mode + else if (AvailableISAMode()) //Bochs Graphics Adaptor ISA Mode { Global.mDebugger.SendInternal($"Creating VBE BGA driver with Mode {xres}*{yres}@{bpp}."); @@ -123,7 +123,7 @@ namespace Cosmos.HAL.Drivers IO.VbeIndex.Word = (ushort)index; return IO.VbeData.Word; } - public static bool Available() + public static bool AvailableISAMode() { //This code wont work as long as Bochs uses BGA ISA, since it wont discover it in PCI #if false diff --git a/source/Cosmos.HAL2/PCIDevice.cs b/source/Cosmos.HAL2/PCIDevice.cs index d9c690c8b..c910de4f4 100644 --- a/source/Cosmos.HAL2/PCIDevice.cs +++ b/source/Cosmos.HAL2/PCIDevice.cs @@ -5,7 +5,6 @@ using System.Text; using Cosmos.Core.IOGroup; using Cosmos.Common.Extensions; using Cosmos.Debug.Kernel; -using System.Threading; namespace Cosmos.HAL { diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index 321c9741b..48f01bf88 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -1,4 +1,5 @@ //#define COSMOSDEBUG +using Cosmos.Core; using Cosmos.HAL; using Cosmos.HAL.Drivers; @@ -66,7 +67,7 @@ namespace Cosmos.System.Graphics { return new SVGAIICanvas(); } - else if (BGAExists() || PCI.Exists(VendorID.VirtualBox, DeviceID.VBVGA) || PCI.Exists(VendorID.Bochs, DeviceID.BGA) || Core.VBE.IsAvailable()) + if (VBEAvailable()) { return new VBECanvas(); } @@ -76,6 +77,34 @@ namespace Cosmos.System.Graphics } } + /// + /// Checks is VBE is supported exists + /// + /// + 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; + } + } + /// /// Get video driver. ///