Cosmos/source/FrodeTest/Test/RAMBusTest.cs
Scalpel_cp 50e33e1a79 RTL8139 network card can now find its own MAC address.
Added IOSpace.cs to Read/Write IO space memory.
MACAddress ToString prints as Hex.
2008-03-12 21:16:03 +00:00

64 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace FrodeTest.Test
{
public class RAMBusTest
{
public static void RunTest()
{
uint address = 0xc100;
//ushort address = 49409;
//byte data = 0x23;
//UInt16 longdata = 0xFFFF;
//Console.WriteLine("Writing " + data + " to memory");
//Write8(address, data);
Console.WriteLine("Reading back from memory: " + Read8(address));
//Console.WriteLine("Writing " + longdata + " to memory");
//Write16(address, longdata);
Console.WriteLine("Reading back from memory: " + Read16(address));
Console.WriteLine("Reading 4 bytes: " + Read64(address));
}
public static unsafe void Write8(uint address, byte data)
{
ushort* pointer = (ushort*)address;
*pointer = data;
}
public static unsafe void Write16(uint address, UInt16 data)
{
UInt16* pointer = (UInt16*)address;
*pointer = data;
}
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 UInt64 Read64(uint address)
{
UInt64* pointer = (UInt64*)address;
UInt64 data = *pointer;
return data;
}
}
}