Skip to content

Commit

Permalink
Finally! Fixed PCIDeviceExists returning null if it doesn't instead o…
Browse files Browse the repository at this point in the history
…f false - Bit of a hack but it's done the job for now, needs redoing
  • Loading branch information
Arawn Davies committed Feb 25, 2018
1 parent efa36d1 commit becfc92
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 12 deletions.
9 changes: 5 additions & 4 deletions Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Bochs_Name>CosmosGraphicSubsystemBoot</Bochs_Name>
</PropertyGroup>

<PropertyGroup>
<BinFormat>elf</BinFormat>
<BinFormat>Bin</BinFormat>
<DebugEnabled>True</DebugEnabled>
<DebugMode>Source</DebugMode>
<TraceMode>User</TraceMode>
Expand All @@ -17,9 +18,9 @@
<StackCorruptionDetectionLevel>MethodFooters</StackCorruptionDetectionLevel>
<IgnoreDebugStubAttribute>False</IgnoreDebugStubAttribute>
<CosmosDebugPort>Serial: COM1</CosmosDebugPort>
<Launch>Bochs</Launch>
<Profile>Bochs</Profile>
<Description>Use Bochs emulator to deploy and debug.</Description>
<Launch>VMware</Launch>
<Profile>VMware</Profile>
<Description>Use VMware Player or Workstation to deploy and debug.</Description>
<PxeInterface>192.168.0.8</PxeInterface>
<VMware_StackCorruptionDetectionEnabled>True</VMware_StackCorruptionDetectionEnabled>
<VMware_StackCorruptionDetectionLevel>MethodFooters</VMware_StackCorruptionDetectionLevel>
Expand Down
8 changes: 6 additions & 2 deletions Demos/CosmosGraphicSubsystem/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ public class Kernel : Sys.Kernel
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode");
Console.WriteLine("Specifying custom graphics mode as 800x600@32");
// Specify custom graphics mode (800x600 @ 16)
Mode start = new Mode(800, 600, ColorDepth.ColorDepth32);

/* Get on instance of the Canvas that is all the Screen */
Mode start = new Mode(640, 480, ColorDepth.ColorDepth32);
Console.WriteLine("Here we go!");
// Create new instance of FullScreenCanvas, specifying graphics mode
canvas = FullScreenCanvas.GetFullScreenCanvas(start);


/* Clear the Screen with the color 'Blue' */
canvas.Clear(Color.Blue);
}
Expand Down
16 changes: 15 additions & 1 deletion Kernel.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kernel G2", "Kernel G2", "{9A923E6F-FF63-4F02-A4EA-C2D44F9323FD}"
EndProject
Expand Down Expand Up @@ -94,6 +94,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spruce", "..\XSharp\source\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XSharp.x86", "..\XSharp\source\XSharp.x86\XSharp.x86.csproj", "{7370A62F-12DA-4181-BE3B-009D0926CA7E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PCITest", "PCITest", "{58AEE3B6-80BF-4ED3-AD1E-17359139E3FC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PCITest", "Demos\PCITest\PCITest.csproj", "{D3639BE5-49A0-4163-9174-1D0CC6823E06}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -335,6 +339,14 @@ Global
{7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|Any CPU.Build.0 = Release|Any CPU
{7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.ActiveCfg = Release|Any CPU
{7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.Build.0 = Release|Any CPU
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|x86.ActiveCfg = Debug|Any CPU
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|x86.Build.0 = Debug|Any CPU
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|Any CPU.Build.0 = Release|Any CPU
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|x86.ActiveCfg = Release|Any CPU
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -380,6 +392,8 @@ Global
{E35E0DBF-555F-4D38-8F28-ACDFA9DC97BD} = {5FF9BF2A-5162-4F12-82B6-1693AD776636}
{0812DD0A-4CEE-4376-B78A-02EBCBAA14C2} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78}
{7370A62F-12DA-4181-BE3B-009D0926CA7E} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78}
{58AEE3B6-80BF-4ED3-AD1E-17359139E3FC} = {B56A6119-1B8F-44E4-9446-291E52F47D4C}
{D3639BE5-49A0-4163-9174-1D0CC6823E06} = {58AEE3B6-80BF-4ED3-AD1E-17359139E3FC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1A1E8F1D-82B3-471F-9B59-0350DEA9203D}
Expand Down
10 changes: 8 additions & 2 deletions source/Cosmos.HAL2/PciDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,14 @@ public PCIDevice(uint bus, uint slot, uint function)
HeaderType = (PCIHeaderType)ReadRegister8((byte)Config.HeaderType);
BIST = (PCIBist)ReadRegister8((byte)Config.BIST);
InterruptPIN = (PCIInterruptPIN)ReadRegister8((byte)Config.InterruptPIN);

DeviceExists = (uint)VendorID != 0xFFFF && (uint)DeviceID != 0xFFFF;
if ((uint)VendorID == 0xFF && (uint)DeviceID == 0xFFFF)
{
DeviceExists = false;
}
else
{
DeviceExists = true;
}
if (HeaderType == PCIHeaderType.Normal)
{
BaseAddressBar = new PCIBaseAddressBar[6];
Expand Down
22 changes: 19 additions & 3 deletions source/Cosmos.System2/Graphics/FullScreenCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,23 @@ private enum VideoDriver

private static PCIDevice SVGAIIDevice = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter);

private static bool SVGAIIExists = SVGAIIDevice.DeviceExists;
public static bool DoesSVGAIIExist()
{
if (SVGAIIDevice != null)
{
if (SVGAIIDevice.DeviceExists == true)
{
return true;
}
return false;
}
else
{
return false;
}

}
//public static bool SVGAIIExists = SVGAIIDevice != null;

private static VideoDriver videoDevice;

Expand Down Expand Up @@ -50,12 +66,12 @@ public static Canvas GetFullScreenCanvas()
}
public static Canvas GetFullScreenCanvas(Mode mode)
{
Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode");
Global.mDebugger.SendInternal($"GetFullScreenCanvas() with mode" + mode);
// If MyVideoDriver is null (hasn't checked if VMWare SVGA exists),
// Do necessary check and set gfx mode as specified (mode)
if (MyVideoDriver == null)
{
if (SVGAIIExists)
if (DoesSVGAIIExist())
{
// Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode
// MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set.
Expand Down

0 comments on commit becfc92

Please sign in to comment.