From 67405de5fa817cf97127feb137cd026ec3c412c0 Mon Sep 17 00:00:00 2001
From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498>
Date: Wed, 7 May 2008 02:26:49 +0000
Subject: [PATCH] Eliminated obsoleted IOSpace
---
.../Cosmos.Hardware/Cosmos.Hardware.csproj | 1 -
source/Cosmos/Cosmos.Hardware/IOSpace.cs | 74 -------------------
.../Network/Devices/RTL8139/RTL8139.cs | 9 ++-
.../Cosmos.Hardware/PC/Bus/AddressSpace.cs | 21 ++----
.../Cosmos/Cosmos.Hardware/PC/Bus/CPUBus.cs | 5 +-
5 files changed, 15 insertions(+), 95 deletions(-)
delete mode 100644 source/Cosmos/Cosmos.Hardware/IOSpace.cs
diff --git a/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj b/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj
index a496a1839..2bedf9e59 100644
--- a/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj
+++ b/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj
@@ -56,7 +56,6 @@
-
diff --git a/source/Cosmos/Cosmos.Hardware/IOSpace.cs b/source/Cosmos/Cosmos.Hardware/IOSpace.cs
deleted file mode 100644
index 5151a4ca1..000000000
--- a/source/Cosmos/Cosmos.Hardware/IOSpace.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Cosmos.Hardware
-{
- ///
- /// The IOSpace class is used to access memory directly.
- ///
- [Obsolete()]
- public static class IOSpace
- {
- #region Read from IO space
- public static unsafe byte Read8(uint address)
- {
- byte* pointer = (byte*)address;
- byte data = *pointer;
- return data;
- }
-
- public static unsafe UInt16 Read16(uint address)
- {
- UInt16* pointer = (UInt16*)address;
- UInt16 data = *pointer;
- return data;
- }
-
- public static unsafe UInt32 Read32(uint address)
- {
- UInt32* pointer = (UInt32*)address;
- UInt32 data = *pointer;
- return data;
- }
-
- public static unsafe UInt64 Read64(uint address)
- {
- UInt64* pointer = (UInt64*)address;
- UInt64 data = *pointer;
- return data;
- }
-
- #endregion
-
- #region Write to IO space
- public static unsafe void Write8(uint address, byte data)
- {
- byte* pointer = (byte*)address;
- *pointer = data;
- }
-
- public static unsafe void Write16(uint address, UInt16 data)
- {
- UInt16* pointer = (UInt16*)address;
- *pointer = data;
- }
-
- public static unsafe void Write32(uint address, UInt32 data)
- {
- UInt32* pointer = (UInt32*)address;
- *pointer = data;
- }
-
- public static unsafe void Write64(uint address, UInt64 data)
- {
- UInt64* pointer = (UInt64*)address;
- *pointer = data;
- }
-
- #endregion
-
-
-
- }
-}
diff --git a/source/Cosmos/Cosmos.Hardware/Network/Devices/RTL8139/RTL8139.cs b/source/Cosmos/Cosmos.Hardware/Network/Devices/RTL8139/RTL8139.cs
index dee4d0426..38661ff85 100644
--- a/source/Cosmos/Cosmos.Hardware/Network/Devices/RTL8139/RTL8139.cs
+++ b/source/Cosmos/Cosmos.Hardware/Network/Devices/RTL8139/RTL8139.cs
@@ -230,12 +230,14 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139
{
get
{
- return IOSpace.Read32(pciCard.BaseAddress1 + (byte)Register.MainRegister.Bit.Timer);
+ var xMem = new MemoryAddressSpace(pciCard.BaseAddress1 + (byte)Register.MainRegister.Bit.Timer, 1);
+ return xMem.Read32(0);
}
set
{
UInt32 address = pciCard.BaseAddress1 + (byte)Register.MainRegister.Bit.Timer;
- IOSpace.Write32(address, 0x00); //Resets timer
+ var xMem = new MemoryAddressSpace(address, 1);
+ xMem.Write32(0, 0); //Resets timer
}
}
@@ -510,7 +512,8 @@ namespace Cosmos.Hardware.Network.Devices.RTL8139
//Each of the four Transmit Status Descriptors (TSD) has its own EarlyTxThreshold.
UInt32 address = pciCard.BaseAddress1 + (byte)Register.MainRegister.Bit.RxEarlyCnt;
- IOSpace.Write8(address, (byte)bytecount);
+ var xMem = new MemoryAddressSpace(address, 1);
+ xMem.Write8(0, (byte)bytecount);
}
///
diff --git a/source/Cosmos/Cosmos.Hardware/PC/Bus/AddressSpace.cs b/source/Cosmos/Cosmos.Hardware/PC/Bus/AddressSpace.cs
index 07aba0860..a6ca0b06d 100644
--- a/source/Cosmos/Cosmos.Hardware/PC/Bus/AddressSpace.cs
+++ b/source/Cosmos/Cosmos.Hardware/PC/Bus/AddressSpace.cs
@@ -3,17 +3,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
-namespace Cosmos.Hardware.PC.Bus
-{
- public abstract class AddressSpace
- {
+namespace Cosmos.Hardware.PC.Bus {
+ public abstract class AddressSpace {
public UInt32 Offset;
public UInt32 Size;
- public AddressSpace(UInt32 offset, UInt32 size)
- {
- this.Offset = offset;
- this.Size = size;
+ public AddressSpace(UInt32 offset, UInt32 size) {
+ Offset = offset;
+ Size = size;
}
///
@@ -103,14 +100,12 @@ namespace Cosmos.Hardware.PC.Bus
public unsafe class MemoryAddressSpace : AddressSpace
{
- public MemoryAddressSpace(UInt32 offset, UInt32 size)
- : base(offset, size)
- {
- }
+ public MemoryAddressSpace(UInt32 offset, UInt32 size) : base(offset, size)
+ { }
public override byte Read8(UInt32 offset)
{
- if (offset < 0 || offset > Size)
+ if (offset > Size)
throw new ArgumentOutOfRangeException("offset");
return *(byte*)(this.Offset + offset);
}
diff --git a/source/Cosmos/Cosmos.Hardware/PC/Bus/CPUBus.cs b/source/Cosmos/Cosmos.Hardware/PC/Bus/CPUBus.cs
index e6ab576bb..24a5c7ad3 100644
--- a/source/Cosmos/Cosmos.Hardware/PC/Bus/CPUBus.cs
+++ b/source/Cosmos/Cosmos.Hardware/PC/Bus/CPUBus.cs
@@ -5,10 +5,7 @@ using System.Text;
namespace Cosmos.Hardware.PC.Bus {
public class CPUBus : Cosmos.Hardware.Bus.CPUBus {
- // These are public. Would prefer internal, but will cause issues
- // in future as we add devices from other assemblies.
- // What else can we do to restrict access to them?
- //
+
// all plugs
public static void Write8(UInt16 aPort, byte aData) { }
public static void Write16(UInt16 aPort, UInt16 aData) { }