diff --git a/source/Cosmos/Cosmos.Hardware/Network/Devices/AMDPCNetII/AMDPCNet.cs b/source/Cosmos/Cosmos.Hardware/Network/Devices/AMDPCNetII/AMDPCNet.cs
index 607200c4e..bfb12429f 100644
--- a/source/Cosmos/Cosmos.Hardware/Network/Devices/AMDPCNetII/AMDPCNet.cs
+++ b/source/Cosmos/Cosmos.Hardware/Network/Devices/AMDPCNetII/AMDPCNet.cs
@@ -30,6 +30,9 @@ namespace Cosmos.Hardware.Network.Devices.AMDPCNetII
}
pciCard = device;
+ // We are handling this device
+ pciCard.Claimed = true;
+
// Setup interrupt handling
//Interrupts.IRQ09 += HandleNetworkInterrupt;
Interrupts.AddIRQHandler(device.InterruptLine, HandleNetworkInterrupt);
@@ -133,7 +136,7 @@ namespace Cosmos.Hardware.Network.Devices.AMDPCNetII
Console.WriteLine("Scanning for AMD PCNet cards...");
foreach (PCIDevice device in Cosmos.Hardware.PCIBus.Devices)
{
- if ((device.VendorID == 0x1022) && (device.DeviceID == 0x2000))
+ if ((device.VendorID == 0x1022) && (device.DeviceID == 0x2000) && (device.Claimed == false))
{
AMDPCNet nic = new AMDPCNet(device);
diff --git a/source/Cosmos/Cosmos.Hardware/Network/Devices/RTL8139/RTL8139.cs b/source/Cosmos/Cosmos.Hardware/Network/Devices/RTL8139/RTL8139.cs
index 303753fe7..0ec1735d8 100644
--- a/source/Cosmos/Cosmos.Hardware/Network/Devices/RTL8139/RTL8139.cs
+++ b/source/Cosmos/Cosmos.Hardware/Network/Devices/RTL8139/RTL8139.cs
@@ -32,6 +32,9 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139
}
pciCard = device;
+ // We are handling this device
+ pciCard.Claimed = true;
+
// Setup interrupt handling
//Interrupts.IRQ11 += HandleNetworkInterrupt;
Interrupts.AddIRQHandler(device.InterruptLine, HandleNetworkInterrupt);
@@ -87,7 +90,7 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139
foreach (PCIDevice device in Cosmos.Hardware.PCIBus.Devices)
{
//DebugWriteLine("VendorID: " + device.VendorID + " - DeviceID: " + device.DeviceID);
- if ((device.VendorID == 0x10EC) && (device.DeviceID == 0x8139))
+ if ((device.VendorID == 0x10EC) && (device.DeviceID == 0x8139) && (device.Claimed == false))
{
RTL8139 nic = new RTL8139(device);
diff --git a/source/Cosmos/Cosmos.Hardware/Network/Devices/ViaRhine/VT6102.cs b/source/Cosmos/Cosmos.Hardware/Network/Devices/ViaRhine/VT6102.cs
index 0360bd4ab..f65745a38 100644
--- a/source/Cosmos/Cosmos.Hardware/Network/Devices/ViaRhine/VT6102.cs
+++ b/source/Cosmos/Cosmos.Hardware/Network/Devices/ViaRhine/VT6102.cs
@@ -26,6 +26,9 @@ namespace Cosmos.Hardware.Network.Devices.ViaRhine
}
pciCard = device;
+ // We are handling this device
+ pciCard.Claimed = true;
+
// Setup interrupt handling
//Interrupts.IRQ10 += HandleNetworkInterrupt;
Interrupts.AddIRQHandler(device.InterruptLine, HandleNetworkInterrupt);
@@ -127,7 +130,7 @@ namespace Cosmos.Hardware.Network.Devices.ViaRhine
Console.WriteLine("Scanning for VIA Rhine-II cards...");
foreach (PCIDevice device in Cosmos.Hardware.PCIBus.Devices)
{
- if ((device.VendorID == 0x1106) && (device.DeviceID == 0x3065))
+ if ((device.VendorID == 0x1106) && (device.DeviceID == 0x3065) && (device.Claimed == false))
{
VT6102 nic = new VT6102(device);
diff --git a/source/Cosmos/Cosmos.Hardware/PCIBus.cs b/source/Cosmos/Cosmos.Hardware/PCIBus.cs
index bd398de5c..3476fc77f 100644
--- a/source/Cosmos/Cosmos.Hardware/PCIBus.cs
+++ b/source/Cosmos/Cosmos.Hardware/PCIBus.cs
@@ -6723,6 +6723,7 @@ namespace Cosmos.Hardware {
this.Bus = bus;
this.Slot = slot;
this.Function = function;
+ this.Claimed = false;
}
private bool NeedsIO = false;
@@ -6789,6 +6790,10 @@ namespace Cosmos.Hardware {
return IOMaps[index];
}
+ ///
+ /// Has this device been claimed a driver
+ ///
+ public bool Claimed { get; set; }
///
/// The bus the device is on
///
diff --git a/source/SSchockeTest/VMWareSVGA.cs b/source/SSchockeTest/VMWareSVGA.cs
index 37642667e..269284c61 100644
--- a/source/SSchockeTest/VMWareSVGA.cs
+++ b/source/SSchockeTest/VMWareSVGA.cs
@@ -71,8 +71,8 @@ namespace Cosmos.Playground.SSchocke
SVGA_SCRATCH_BASE = SVGA_PALETTE_BASE + 768
/* Base of scratch registers */
- /* Next reg[SCRATCH_SIZE] registers exist for scratch usage:
- First 4 are reserved for VESA BIOS Extension; any remaining are for
+ /* Next reg[SCRATCH_SIZE] registers exist for scratch usage:
+ First 4 are reserved for VESA BIOS Extension; any remaining are for
the use of the current SVGA driver. */
};
private enum SVGA_CAP
@@ -116,15 +116,15 @@ namespace Cosmos.Playground.SSchocke
FENCE = 30,
ESCAPE = 33,
MAX
- };
-
+ };
+
private class FifoStruct
{
- /*struct {
- uint32 reservedSize;
- Bool usingBounceBuffer;
- uint8 bounceBuffer[1024 * 1024];
- uint32 nextFence;
+ /*struct {
+ uint32 reservedSize;
+ Bool usingBounceBuffer;
+ uint8 bounceBuffer[1024 * 1024];
+ uint32 nextFence;
} fifo;*/
internal UInt32 reservedSize;
internal bool usingBounceEffect;
@@ -217,9 +217,9 @@ namespace Cosmos.Playground.SSchocke
private const UInt32 SVGA_INDEX_PORT = 0x0;
private const UInt32 SVGA_VALUE_PORT = 0x1;
- private const UInt32 SVGA_IRQSTATUS_PORT = 0x8;
-
- private const UInt32 SVGA3D_HWVERSION_CURRENT = 2 << 16;
+ private const UInt32 SVGA_IRQSTATUS_PORT = 0x8;
+
+ private const UInt32 SVGA3D_HWVERSION_CURRENT = 2 << 16;
public static void Test()
{
@@ -228,7 +228,7 @@ namespace Cosmos.Playground.SSchocke
Console.WriteLine("Scanning for VMWare SVGA cards...");
foreach (PCIDevice device in Cosmos.Hardware.PCIBus.Devices)
{
- if ((device.VendorID == 0x15AD) && (device.DeviceID == 0x0405))
+ if ((device.VendorID == 0x15AD) && (device.DeviceID == 0x0405) && (device.Claimed == false))
{
Console.WriteLine("Found VMWare SVGA on PCI " + device.Bus + ":" + device.Slot + ":" + device.Function);
Console.WriteLine("VGA IRQ: " + device.InterruptLine);
@@ -336,6 +336,8 @@ namespace Cosmos.Playground.SSchocke
return;
}
+ this.pciDev.Claimed = true;
+
if (deviceVersionID >= SVGA_ID_1)
{
this.capabilities = readSVGARegister(SVGA_REG.CAPABILITIES);
@@ -450,16 +452,16 @@ namespace Cosmos.Playground.SSchocke
if (!hasFIFOCap(SVGA_FIFO_CAP.FENCE))
{
- /*
- * Fall back on the legacy sync if the host does not support
- * fences. This is the old sync mechanism that has been
- * supported in the SVGA device pretty much since the dawn of
- * time: write to the SYNC register, then read from BUSY until
- * it's nonzero. This will drain the entire FIFO.
- *
- * The parameter we write to SVGA_REG_SYNC is an arbitrary
- * nonzero value which can be used for debugging, but which is
- * ignored by release builds of VMware products.
+ /*
+ * Fall back on the legacy sync if the host does not support
+ * fences. This is the old sync mechanism that has been
+ * supported in the SVGA device pretty much since the dawn of
+ * time: write to the SYNC register, then read from BUSY until
+ * it's nonzero. This will drain the entire FIFO.
+ *
+ * The parameter we write to SVGA_REG_SYNC is an arbitrary
+ * nonzero value which can be used for debugging, but which is
+ * ignored by release builds of VMware products.
*/
//DebugUtil.SendMessage("VMWare", "SyncToFence old style sync!!");
@@ -491,9 +493,9 @@ namespace Cosmos.Playground.SSchocke
if (!hasFencePassed(fence))
{
- /*
- * This shouldn't happen. If it does, there might be a bug in
- * the SVGA device.
+ /*
+ * This shouldn't happen. If it does, there might be a bug in
+ * the SVGA device.
*/
DebugUtil.SendError("VMWare", "SyncToFence failed!!");
}
@@ -593,22 +595,22 @@ namespace Cosmos.Playground.SSchocke
if (fifo.usingBounceEffect)
{
- /*
- * Slow paths: copy out of a bounce buffer.
+ /*
+ * Slow paths: copy out of a bounce buffer.
*/
MemoryAddressSpace buffer = fifo.bounceBuffer;
if (reserveable)
{
- /*
- * Slow path: bulk copy out of a bounce buffer in two chunks.
- *
- * Note that the second chunk may be zero-length if the reserved
- * size was large enough to wrap around but the commit size was
- * small enough that everything fit contiguously into the FIFO.
- *
- * Note also that we didn't need to tell the FIFO about the
- * reservation in the bounce buffer, but we do need to tell it
- * about the data we're bouncing from there into the FIFO.
+ /*
+ * Slow path: bulk copy out of a bounce buffer in two chunks.
+ *
+ * Note that the second chunk may be zero-length if the reserved
+ * size was large enough to wrap around but the commit size was
+ * small enough that everything fit contiguously into the FIFO.
+ *
+ * Note also that we didn't need to tell the FIFO about the
+ * reservation in the bounce buffer, but we do need to tell it
+ * about the data we're bouncing from there into the FIFO.
*/
uint chunkSize = Math.Min(bytes, max - nextCmd);
@@ -618,10 +620,10 @@ namespace Cosmos.Playground.SSchocke
}
else
{
- /*
- * Slowest path: copy one dword at a time, updating NEXT_CMD as
- * we go, so that we bound how much data the guest has written
- * and the host doesn't know to checkpoint.
+ /*
+ * Slowest path: copy one dword at a time, updating NEXT_CMD as
+ * we go, so that we bound how much data the guest has written
+ * and the host doesn't know to checkpoint.
*/
uint index = 0;
@@ -702,34 +704,34 @@ namespace Cosmos.Playground.SSchocke
// No valid FIFO data between nextCmd and max
if ((nextCmd + bytes < max) || ((nextCmd + bytes == max) && (stop > min)))
{
- /*
- * Fastest path 1: There is already enough contiguous space
- * between nextCmd and max (the end of the buffer).
- *
- * Note the edge case: If the "<" path succeeds, we can
- * quickly return without performing any other tests. If
- * we end up on the "==" path, we're writing exactly up to
- * the top of the FIFO and we still need to make sure that
- * there is at least one unused DWORD at the bottom, in
- * order to be sure we don't fill the FIFO entirely.
- *
- * If the "==" test succeeds, but stop <= min (the FIFO
- * would be completely full if we were to reserve this
- * much space) we'll end up hitting the FIFOFull path below.
+ /*
+ * Fastest path 1: There is already enough contiguous space
+ * between nextCmd and max (the end of the buffer).
+ *
+ * Note the edge case: If the "<" path succeeds, we can
+ * quickly return without performing any other tests. If
+ * we end up on the "==" path, we're writing exactly up to
+ * the top of the FIFO and we still need to make sure that
+ * there is at least one unused DWORD at the bottom, in
+ * order to be sure we don't fill the FIFO entirely.
+ *
+ * If the "==" test succeeds, but stop <= min (the FIFO
+ * would be completely full if we were to reserve this
+ * much space) we'll end up hitting the FIFOFull path below.
*/
reserveInPlace = true;
//DebugUtil.SendMessage("VMWare", "FIFOReserve Path 1");
}
else if ((max - nextCmd) + (stop - min) <= bytes)
{
- /*
- * We have to split the FIFO command into two pieces,
- * but there still isn't enough total free space in
- * the FIFO to store it.
- *
- * Note the "<=". We need to keep at least one DWORD
- * of the FIFO free at all times, or we won't be able
- * to tell the difference between full and empty.
+ /*
+ * We have to split the FIFO command into two pieces,
+ * but there still isn't enough total free space in
+ * the FIFO to store it.
+ *
+ * Note the "<=". We need to keep at least one DWORD
+ * of the FIFO free at all times, or we won't be able
+ * to tell the difference between full and empty.
*/
//DebugUtil.SendMessage("VMWare", "FIFOReserve Path 2");
FIFOFull();
@@ -745,18 +747,18 @@ namespace Cosmos.Playground.SSchocke
// There is FIFO Data between nextCmd and max
if (nextCmd + bytes < stop)
{
- /*
- * Fastest path 2: There is already enough contiguous space
- * between nextCmd and stop.
+ /*
+ * Fastest path 2: There is already enough contiguous space
+ * between nextCmd and stop.
*/
reserveInPlace = true;
//DebugUtil.SendMessage("VMWare", "FIFOReserve Path 4");
}
else
{
- /*
- * There isn't enough room between nextCmd and stop.
- * The FIFO is too full to accept this command.
+ /*
+ * There isn't enough room between nextCmd and stop.
+ * The FIFO is too full to accept this command.
*/
FIFOFull();
//DebugUtil.SendMessage("VMWare", "FIFOReserve Path 5");