Eliminated obsoleted IOSpace

This commit is contained in:
kudzu_cp 2008-05-07 02:26:49 +00:00
parent 21044004a6
commit 67405de5fa
5 changed files with 15 additions and 95 deletions

View file

@ -56,7 +56,6 @@
<Compile Include="Device.cs" />
<Compile Include="Extension\NumberSystem\Binary.cs" />
<Compile Include="Extension\NumberSystem\Hex.cs" />
<Compile Include="IOSpace.cs" />
<Compile Include="KeyboardOld.cs" />
<Compile Include="Network\Devices\RTL8139\BinaryHelper.cs" />
<Compile Include="Network\Devices\RTL8139\Packet.cs" />

View file

@ -1,74 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Cosmos.Hardware
{
/// <summary>
/// The IOSpace class is used to access memory directly.
/// </summary>
[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
}
}

View file

@ -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);
}
/// <summary>

View file

@ -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;
}
/// <summary>
@ -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);
}

View file

@ -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) { }