Cosmos/source/SSchockeTest/PCITest.cs
sschocke_cp 47140a6627 Added my workspace
Added a few things to the Cosmos.Hardware.Network classes
My workspace includes prelimanary AMD PCNet Network Card Driver
2009-03-09 15:24:21 +00:00

59 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using HW = Cosmos.Hardware;
using Cosmos.Kernel;
namespace Cosmos.Playground.SSchocke
{
public class PCITest {
public static void Test() {
HW.PCIBus.Init();
WriteDevices();
}
public static void WriteDevices() {
var xDeviceIDs = new HW.PCIBus.DeviceIDs();
Console.WriteLine(HW.PCIBus.Devices.Length);
for (int d = 0; d < HW.PCIBus.Devices.Length; d++) {
var xPCIDevice = HW.PCIBus.Devices[d];
//foreach(
//string xVendor = xDeviceIDs.FindVendor(xPCIDevice.VendorID);
//if (xVendor == null) {
string xVendor = xPCIDevice.VendorID.ToHex(4);
//}
Console.Write(xPCIDevice.Bus + "-" + xPCIDevice.Slot + "-" + xPCIDevice.Function);
Console.Write(" " + xVendor + ":" + xPCIDevice.DeviceID.ToHex(4));
Console.WriteLine(" Type: " + xPCIDevice.HeaderType + " IRQ: " + xPCIDevice.InterruptLine);
// /*Enum.GetName(typeof(PCIHeaderType), */ xPCIDevice.HeaderType/*) */);
// Console.WriteLine(" Status: " + xPCIDevice.Status + " " +
// /*Enum.GetName(typeof(PCIStatus), */xPCIDevice.Status/*) */);
// Console.WriteLine(" Command: " + xPCIDevice.Command + " " +
// /*Enum.GetName(typeof(PCICommand), */xPCIDevice.Command /* ) */);
uint xClass = (UInt32)((xPCIDevice.ClassCode << 8) | xPCIDevice.SubClass);
System.Console.Write(" Class [" + xClass.ToHex(4) + "] " + xPCIDevice.GetClassInfo());
System.Console.WriteLine(" Memory: ");
for (byte i = 0; i < xPCIDevice.NumberOfBaseAddresses(); i++) {
var a = xPCIDevice.GetAddressSpace(i);
if (a != null) {
System.Console.Write(" register " + i + " @ " + a.Offset.ToHex(8) + " (" + a.Size + "b) ");
if (a is Cosmos.Kernel.MemoryAddressSpace) {
Console.WriteLine("mem");
} else {
Console.WriteLine("io");
}
}
}
System.Console.WriteLine();
System.Console.WriteLine();
Console.Read();
}
}
}
}