protected override void Initialize() { Device.Name = "AMDPCNet_0x" + Device.Resources.GetIOPortRegion(0).BaseIOPort.ToString("X"); ioProm1 = Device.Resources.GetIOPortReadWrite(0, 0x0); ioProm4 = Device.Resources.GetIOPortReadWrite(0, 0x4); rdp = Device.Resources.GetIOPortReadWrite(0, 0x10); rap = Device.Resources.GetIOPortReadWrite(0, 0x14); bdp = Device.Resources.GetIOPortReadWrite(0, 0x1C); initBlock = Device.Resources.GetMemory(0); txDescriptor = Device.Resources.GetMemory(1); rxDescriptor = Device.Resources.GetMemory(2); buffers = Device.Resources.GetMemory(3); bufferSize = 2048; uint len = (ushort)(~bufferSize); len = ((len + 1) & 0x0FFF) | 0x8000F000; physicalBufferAddress = HAL.GetPhysicalAddress(buffers); for (uint index = 0; index < 16; index++) { uint offset = index * 4; rxDescriptor.Write32((offset + 1) * 4, len); rxDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * index)); txDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * (index + 16))); } nextTXDesc = 0; }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(IHardwareResources hardwareResources) { this.hardwareResources = hardwareResources; base.name = "AMDPCNet_0x" + hardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X"); ioProm1 = hardwareResources.GetIOPort(0, 0x0); ioProm4 = hardwareResources.GetIOPort(0, 0x4); rdp = hardwareResources.GetIOPort(0, 0x10); rap = hardwareResources.GetIOPort(0, 0x14); bdp = hardwareResources.GetIOPort(0, 0x1C); initBlock = hardwareResources.GetMemory(0); txDescriptor = hardwareResources.GetMemory(1); rxDescriptor = hardwareResources.GetMemory(2); buffers = hardwareResources.GetMemory(3); bufferSize = 2048; uint len = (ushort)(~bufferSize); len = (len + 1) & 0x0FFF | 0x8000F000; physicalBufferAddress = HAL.GetPhysicalAddress(buffers); for (uint index = 0; index < 16; index++) { uint offset = index * 4; rxDescriptor.Write32((offset + 1) * 4, len); rxDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * index)); txDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * (index + 16))); } nextTXDesc = 0; return(true); }
public override void Start() { if (Device.Status != DeviceStatus.Available) { return; } // Enable the card //HardwareResources.DeviceResource.EnableDevice(); // TODO // Do a 32-bit write to set 32-bit mode rdp.Write32(0); // Get the EEPROM MAC Address var eepromMac = new byte[6]; var data = ioProm1.Read32(); eepromMac[0] = (byte)(data & 0xFF); eepromMac[1] = (byte)((data >> 8) & 0xFF); eepromMac[2] = (byte)((data >> 16) & 0xFF); eepromMac[3] = (byte)((data >> 24) & 0xFF); data = ioProm4.Read32(); eepromMac[4] = (byte)(data & 0xFF); eepromMac[5] = (byte)((data >> 8) & 0xFF); macAddress = new MACAddress(eepromMac); // Fill in the initialization block initBlock.Write32(0, (0x4 << 28) | (0x4 << 30)); initBlock.Write32(4, (uint)(eepromMac[0] | (eepromMac[1] << 8) | (eepromMac[2] << 16) | (eepromMac[3] << 24))); initBlock.Write32(8, (uint)(eepromMac[4] | (eepromMac[5] << 8))); // Fill in the hardware MAC address initBlock.Write32(16, 0x0); initBlock.Write32(24, 0x0); initBlock.Write32(28, rxDescriptor.Address); initBlock.Write32(32, txDescriptor.Address); // Write the initialization blocks address to the registers on the card InitializationBlockAddress = HAL.GetPhysicalAddress(initBlock); // Set the device to PCNet-PCI II Controller mode (full 32-bit mode) SoftwareStyleRegister = 0x03; nextTXDesc = 0; Device.Status = DeviceStatus.Online; }