public RTL8139(PCIDevice device) { if (device == null) { throw new ArgumentException("PCI Device is null. Unable to get Realtek 8139 card"); } pciCard = device; // We are handling this device pciCard.Claimed = true; // Setup interrupt handling //Interrupts.IRQ11 += HandleNetworkInterrupt; //Interrupts.AddIRQHandler(device.InterruptLine, HandleNetworkInterrupt); // Get IO Address from PCI Bus io = pciCard.GetAddressSpace(0); // Enable the card pciCard.EnableDevice(); // Turn on the card io.Write8(0x52, 0x01); //Do a software reset SoftwareReset(); // Get the MAC Address byte[] eeprom_mac = new byte[6]; for (uint b = 0; b < 6; b++) { eeprom_mac[b] = io.Read8(b); } this.mac = new MACAddress(eeprom_mac); // Get a receive buffer and assign it to the card rxBuffer = new ManagedMemorySpace(RxBufferSize + 2048 + 16, 4); RBStartRegister = rxBuffer.Offset; // Setup receive Configuration RecvConfigRegister = 0xF381; // Setup Transmit Configuration TransmitConfigRegister = 0x3000300; // Setup Interrupts IntMaskRegister = 0x7F; IntStatusRegister = 0xFFFF; // Setup our Receive and Transmit Queues mRecvBuffer = new Queue <byte[]>(); mTransmitBuffer = new Queue <byte[]>(); }
public Intel8254X(PCIDevice dev) { this.dev = dev; dev.EnableDevice(); BAR0 = (uint)(dev.BAR0 & (~3)); INTs.SetIrqHandler(dev.InterruptLine, HandleIRQ); var HasEEPROM = DetectEEPROM(); //Read the mac address if (!HasEEPROM) { address = new MACAddress(new byte[] { Read1ByteRegister(BAR0 + 0x5400), Read1ByteRegister(BAR0 + 0x5401), Read1ByteRegister(BAR0 + 0x5402), Read1ByteRegister(BAR0 + 0x5403), Read1ByteRegister(BAR0 + 0x5404), Read1ByteRegister(BAR0 + 0x5405) }); } else { var firstWord = ReadROM(0); var secondWord = ReadROM(1); var thirdWord = ReadROM(2); address = new MACAddress(new byte[] { (byte)(firstWord & 0xFF), (byte)(firstWord >> 8), (byte)(secondWord & 0xFF), (byte)(secondWord >> 8), (byte)(thirdWord & 0xFF), (byte)(thirdWord >> 8) }); } LinkUp(); //zero out the MTA (multicast tabel array) for (int i = 0; i < 0x80; i++) { WriteRegister((ushort)(0x5200 + i * 4), 0); } //Enable interupts WriteRegister(REG_IMASK, 0x1F6DC); WriteRegister(REG_IMASK, 0xFF & ~4); ReadRegister(0xC0); RXInitialize(); TXInitialize(); }
public VT6102(PCIDevice device) { if (device == null) { throw new ArgumentException("PCI Device is null. Unable to get VIA Rhine-II card"); } pciCard = device; // We are handling this device pciCard.Claimed = true; // Setup interrupt handling //Interrupts.IRQ10 += HandleNetworkInterrupt; //Interrupts.AddIRQHandler(device.InterruptLine, HandleNetworkInterrupt); // Get IO Address from PCI Bus io = pciCard.GetAddressSpace(0) as Kernel.IOAddressSpace; // Enable the card pciCard.EnableDevice(); // Get the EEPROM MAC Address and set it as the devices MAC byte[] eeprom_mac = new byte[6]; UInt32 result = io.Read32(0x00); eeprom_mac[0] = BinaryHelper.GetByteFrom32bit(result, 0); eeprom_mac[1] = BinaryHelper.GetByteFrom32bit(result, 8); eeprom_mac[2] = BinaryHelper.GetByteFrom32bit(result, 16); eeprom_mac[3] = BinaryHelper.GetByteFrom32bit(result, 24); result = io.Read32(0x04); eeprom_mac[4] = BinaryHelper.GetByteFrom32bit(result, 0); eeprom_mac[5] = BinaryHelper.GetByteFrom32bit(result, 8); mac = new MACAddress(eeprom_mac); // Software Reset device SoftwareReset(); // Configure Receive Config ReceiveConfigRegister = 0x1C; // Configure Transmit Config TransmitConfigRegister = 0x04; // Setup RX Descriptors mRxDescriptors = new ManagedMemorySpace(256, 16); // Setup TX Descriptors mTxDescriptors = new ManagedMemorySpace(256, 16); /* Initialize the RX and TX buffers, and set up the RX descriptors to point to the buffers. Also, mark the RX descriptors as being owned by the card so data can be received in them */ mRxBuffers = new List<ManagedMemorySpace>(); for (uint rxd = 0; rxd < 16; rxd++) { uint xOffset = rxd * 16; ManagedMemorySpace buffer = new ManagedMemorySpace(2048); mRxDescriptors.Write32(xOffset + 12, mRxDescriptors.Offset + xOffset + 16); mRxDescriptors.Write32(xOffset + 8, buffer.Offset); mRxDescriptors.Write32(xOffset + 4, buffer.Size); mRxDescriptors.Write32(xOffset, 0x80000000); mRxBuffers.Add(buffer); } mRxDescriptors.Write32(252, mRxDescriptors.Offset); for (uint txd = 0; txd < 16; txd++) { uint xOffset = txd * 16; mTxDescriptors.Write32(xOffset + 12, mTxDescriptors.Offset + xOffset + 16); mTxDescriptors.Write32(xOffset + 8, 0); mTxDescriptors.Write32(xOffset + 4, 0); mTxDescriptors.Write32(xOffset, 0); } mTxDescriptors.Write32(252, mTxDescriptors.Offset); mNextTXDesc = 0; RxDescAddressRegister = mRxDescriptors.Offset; TxDescAddressRegister = mTxDescriptors.Offset; // Setup and clear interrupts IntMaskRegister = 0xFFFF; IntStatusRegister = 0xFFFF; // Setup our Receive and Transmit Queues mTransmitBuffer = new Queue<byte[]>(); mRecvBuffer = new Queue<byte[]>(); }
// Initialize a new instance of the AMD PCNet device driver public AMDPCNet(PCIDevice device) { if (device == null) { throw new ArgumentException("PCI Device is null. Unable to get AMD PCNet card"); } pciCard = device; // We are handling this device pciCard.Claimed = true; // Setup interrupt handling //Interrupts.IRQ09 += HandleNetworkInterrupt; //Interrupts.AddIRQHandler(device.InterruptLine, HandleNetworkInterrupt); // Get IO Address from PCI Bus io = (Kernel.IOAddressSpace)pciCard.GetAddressSpace(0); // Enable the card pciCard.EnableDevice(); // Set the device into 32-bit mode io.Write32(0x10, 0); // Get the EEPROM MAC Address and set it as the devices MAC byte[] eeprom_mac = new byte[6]; UInt32 result = io.Read32(0x00); eeprom_mac[0] = BinaryHelper.GetByteFrom32bit(result, 0); eeprom_mac[1] = BinaryHelper.GetByteFrom32bit(result, 8); eeprom_mac[2] = BinaryHelper.GetByteFrom32bit(result, 16); eeprom_mac[3] = BinaryHelper.GetByteFrom32bit(result, 24); result = io.Read32(0x04); eeprom_mac[4] = BinaryHelper.GetByteFrom32bit(result, 0); eeprom_mac[5] = BinaryHelper.GetByteFrom32bit(result, 8); mac = new MACAddress(eeprom_mac); // Allocate 32 bytes for the 28 byte Initialization block that has to be aligned to a 4 byte boundary //UInt32 address = Heap.MemAlloc(0x20); //mInitBlock = new ManagedUInt32Array(7); // 7 UInt32's, aligned on a 4byte boundary mInitBlock = new ManagedMemorySpace(28, 4); /*Console.Write("Allocated 32 bytes for initialization block @ 0x" + address.ToHex(8)); Console.WriteLine("(Aligned to 0x" + aligned_address.ToHex(8) + ")");*/ // Allocate 80 uints for the 16 RX and TX Descriptor rings. These addresses have to be aligned on a 16-byte boundary mTxDescriptor = new ManagedMemorySpace(256, 16); mRxDescriptor = new ManagedMemorySpace(256, 16); /*Console.Write("Allocated 320 bytes for RX ring descriptors @ 0x" + rd_address.ToHex(8)); Console.WriteLine("(Aligned to 0x" + mRxDescriptorAddress.ToHex(8) + ")"); Console.Write("Allocated 320 bytes for TX ring descriptors @ 0x" + tx_address.ToHex(8)); Console.WriteLine("(Aligned to 0x" + mTxDescriptorAddress.ToHex(8) + ")");*/ // Fill in the Initialization block mInitBlock.Write32(0x00, (0x4 << 28) | (0x4 << 20)); mInitBlock.Write32(0x04, (uint)(eeprom_mac[0] | (eeprom_mac[1] << 8) | (eeprom_mac[2] << 16) | (eeprom_mac[3] << 24))); mInitBlock.Write32(0x08, (uint)(eeprom_mac[4] | (eeprom_mac[5] << 8))); mInitBlock.Write32(0x0C, 0x0); mInitBlock.Write32(0x10, 0x0); mInitBlock.Write32(0x14, mRxDescriptor.Offset); mInitBlock.Write32(0x18, mTxDescriptor.Offset); // Write the Initialization blocks address to the registers on the card InitializationBlockAddress = mInitBlock.Offset; // Set the device to PCNet-PCI II Controller mode (full 32-bit mode) SoftwareStyleRegister = 0x03; /* Initialize the RX and TX buffers, and set up the RX and TX descriptors to point to the buffers. Also, mark the RX descriptors as being owned by the card so data can be received in them */ mRxBuffers = new List<ManagedMemorySpace>(); mTxBuffers = new List<ManagedMemorySpace>(); for (uint rxd = 0; rxd < 16; rxd++) { uint xOffset = rxd * 16; ManagedMemorySpace buffer = new ManagedMemorySpace(2048); mRxDescriptor.Write32(xOffset + 8, buffer.Offset); UInt16 buffer_len = (UInt16)(~buffer.Size); buffer_len++; UInt32 flags = (UInt32)(buffer_len & 0x0FFF) | 0xF000 | 0x80000000; mRxDescriptor.Write32(xOffset + 4, flags); mRxBuffers.Add(buffer); } for (uint txd = 0; txd < 16; txd++) { uint xOffset = txd * 16; ManagedMemorySpace buffer = new ManagedMemorySpace(2048); mTxDescriptor.Write32(xOffset + 8, buffer.Offset); mTxBuffers.Add(buffer); } // Set TX Descriptor 0 as the first one to use... Increment this when we use one to use them in a circular fashion mNextTXDesc = 0; // Setup our Receive and Transmit Queues mTransmitBuffer = new Queue<byte[]>(); mRecvBuffer = new Queue<byte[]>(); }
/// <summary> /// Creates a new instance of the <see cref="AC97"/> class, with the /// given buffer size. /// </summary> /// <param name="bufferSize">The buffer size in samples to use. This value cannot be an odd number, as per the AC97 specification.</param> /// <exception cref="ArgumentException">Thrown when the given buffer size is invalid.</exception> /// <exception cref="InvalidOperationException">Thrown when no AC97-compatible sound card is present.</exception> private AC97(ushort bufferSize) { if (bufferSize % 2 != 0) { // As per the AC97 specification, the buffer size cannot be odd. // (1.2.4.2 PCM Buffer Restrictions, Intel document 302349-003) throw new ArgumentException("The buffer size must be an even number.", nameof(bufferSize)); } PCIDevice pci = Cosmos.HAL.PCI.GetDeviceClass( ClassID.MultimediaDevice, // 0x04 (SubclassID)0x01 // 0x01 ); if (pci == null || !pci.DeviceExists || pci.InterruptLine > 0xF) { throw new InvalidOperationException("No AC97-compatible device could be found."); } PCI = pci; // Expose PCI device to the public API pci.EnableBusMaster(true); pci.EnableMemory(true); pci.EnableDevice(); // enable I/O space INTs.SetIrqHandler(pci.InterruptLine, HandleInterrupt); ushort NAMbar = (ushort)pci.BaseAddressBar[0].BaseAddress; // Native Audio Mixer ushort NABMbar = (ushort)pci.BaseAddressBar[1].BaseAddress; // Native Audio Bus Master pTransferControl = new IOPort((ushort)(NABMbar + 0x1B)); pMasterVolume = new IOPort((ushort)(NAMbar + 0x02)); pPCMOutVolume = new IOPort((ushort)(NAMbar + 0x18)); pBufferDescriptors = new IOPort((ushort)(NABMbar + 0x10)); pTransferStatus = new IOPort((ushort)(NABMbar + 0x16)); pLastValidEntry = new IOPort((ushort)(NABMbar + 0x15)); pGlobalControl = new IOPort((ushort)(NABMbar + 0x2C)); pResetRegister = new IOPort((ushort)(NAMbar + 0x00)); // Reset device pGlobalControl.Byte = 0x2; pResetRegister.DWord = 0xDEADBEEF; // any value will do here // Reset PCM out uint polls = 0; // The amount we polled the device for a reset pTransferControl.Byte = (byte)(pTransferControl.Byte | TC_TRANSFER_RESET); while ((pTransferControl.Byte & TC_TRANSFER_RESET) != 0 && polls < RESET_POLL_LIMIT) { // Wait until the byte is cleared polls++; } // The device hasn't responded to our reset request. Probably not a fully-compatible AC97 card. if (polls >= RESET_POLL_LIMIT) { throw new InvalidOperationException("No AC97-compatible device could be found - the reset timeout has expired."); } // Volume pMasterVolume.Word = CreateMixerVolumeValue(AC97_VOLUME_MAX, AC97_VOLUME_MAX, false); pPCMOutVolume.Word = CreateMixerVolumeValue(AC97_VOLUME_MAX, AC97_VOLUME_MAX, false); // Create all needed buffers CreateBuffers(bufferSize); // Initialization done - driver can now be activated by using Enable() }
public RTL8168(PCIDevice device) : base() { if (device == null) { throw new ArgumentException("PCI Device is null. Unable to get Realtek 8168 card"); } pciCard = device; // We are handling this device pciCard.Claimed = true; BaseAddress = this.pciCard.BaseAddressBar[0].BaseAddress; // Enable the card pciCard.EnableDevice(); SetIrqHandler(device.InterruptLine, HandleNetworkInterrupt); Ports.outb((ushort)(BaseAddress + 0xE0), 0x08); Reset(); // Get the MAC Address byte[] eeprom_mac = new byte[6]; for (uint b = 0; b < 6; b++) { eeprom_mac[b] = Ports.inb((ushort)(BaseAddress + b)); } this.mac = new MACAddress(eeprom_mac); InitBuffers(); Console.WriteLine("Init buffers done!"); Ports.outd((ushort)(BaseAddress + 0x44), 0x0000E70F); // Enable RX Ports.outd((ushort)(BaseAddress + 0x37), 0x04); Ports.outd((ushort)(BaseAddress + 0x40), 0x03000700); // Enable TX Ports.outd((ushort)(BaseAddress + 0xDA), 2048); // Max rx packet size Ports.outb((ushort)(BaseAddress + 0xEC), 0x3F); // No early transmit Ports.outd((ushort)(BaseAddress + 0x20), mTxDescriptor.Offset); Console.WriteLine("addresstx desc: 0x" + Utilities.Conversion.DecToHex((int)mTxDescriptor.Offset)); Ports.outd((ushort)(BaseAddress + 0xE4), mRxDescriptor.Offset); Console.WriteLine("addressrx desc: 0x" + Utilities.Conversion.DecToHex((int)mRxDescriptor.Offset)); if (((GetMacVersion() & 0x7cf00000) == 0x54100000) || ((GetMacVersion() & 0x7cf00000) == 0x54000000)) { Console.WriteLine("8168H Detected!"); Ports.outd((ushort)(BaseAddress + 0x40), Ports.ind((ushort)(BaseAddress + 0x40)) | (1 << 7)); // AUTO TX FIFO } Ports.outw((ushort)(BaseAddress + 0x3C), 0xC3FF); //Activating all Interrupts Ports.outb((ushort)(BaseAddress + 0x37), 0x0C); // Enabling receive and transmit Console.WriteLine("Netcard version: 0x" + Utilities.Conversion.DecToHex((int)GetMacVersion() & 0x7cf00000)); Console.WriteLine("Netcard version: 0x" + Utilities.Conversion.DecToHex((int)GetMacVersion() & 0x7c800000)); }
public RTL8168(PCIDevice device) : base() { if (device == null) { throw new ArgumentException("PCI Device is null. Unable to get Realtek 8168 card"); } pciCard = device; // We are handling this device pciCard.Claimed = true; BaseAddress = pciCard.BAR0 & (~0xFU); Console.WriteLine("Amount of bars: " + device.BaseAddressBar.Length); Console.WriteLine("BAR0: " + BaseAddress); // Enable the card pciCard.EnableDevice(); SetIrqHandler(device.InterruptLine, HandleNetworkInterrupt); //Ports.OutB((ushort)(BaseAddress + 0xE0), 0x08); Console.WriteLine("Reset"); Reset(); // Get the MAC Address byte[] eeprom_mac = new byte[6]; for (uint b = 0; b < 6; b++) { eeprom_mac[b] = Ports.InB((ushort)(BaseAddress + b)); } mac = new MACAddress(eeprom_mac); Console.WriteLine("MAC: " + mac.ToString()); Console.WriteLine("Init buffers"); InitBuffers(); Ports.OutD((ushort)(BaseAddress + 0x44), 0x0000E70F); // Enable RX Ports.OutD((ushort)(BaseAddress + 0x37), 0x04); Ports.OutD((ushort)(BaseAddress + 0x40), 0x03000700); // Enable TX Ports.OutD((ushort)(BaseAddress + 0xDA), 2048); // Max rx packet size Ports.OutB((ushort)(BaseAddress + 0xEC), 0x3F); // No early transmit Ports.OutD((ushort)(BaseAddress + 0x20), (uint)mTxDescriptor.Offset); Console.WriteLine("addresstx desc: " + mTxDescriptor.Offset); Ports.OutD((ushort)(BaseAddress + 0xE4), (uint)mRxDescriptor.Offset); Console.WriteLine("addressrx desc: " + mRxDescriptor.Offset); if (((GetMacVersion() & 0x7cf00000) == 0x54100000) || ((GetMacVersion() & 0x7cf00000) == 0x54000000)) { Console.WriteLine("8168H Detected!"); Ports.OutD((ushort)(BaseAddress + 0x40), Ports.InD((ushort)(BaseAddress + 0x40)) | (1 << 7)); // AUTO TX FIFO } Ports.OutW((ushort)(BaseAddress + 0x3C), 0xC3FF); //Activating all Interrupts Ports.OutB((ushort)(BaseAddress + 0x37), 0x0C); // Enabling receive and transmit //Console.WriteLine("Netcard version: 0x" + System.Utils.Conversion.DecToHex((int)GetMacVersion() & 0x7cf00000)); //Console.WriteLine("Netcard version: 0x" + System.Utils.Conversion.DecToHex((int)GetMacVersion() & 0x7c800000)); }
// Initialize a new instance of the AMD PCNet device driver public AMDPCNet(PCIDevice device) { if (device == null) { throw new ArgumentException("PCI Device is null. Unable to get AMD PCNet card"); } pciCard = device; // We are handling this device pciCard.Claimed = true; // Setup interrupt handling //Interrupts.IRQ09 += HandleNetworkInterrupt; //Interrupts.AddIRQHandler(device.InterruptLine, HandleNetworkInterrupt); // Get IO Address from PCI Bus io = (Kernel.IOAddressSpace)pciCard.GetAddressSpace(0); // Enable the card pciCard.EnableDevice(); // Set the device into 32-bit mode io.Write32(0x10, 0); // Get the EEPROM MAC Address and set it as the devices MAC byte[] eeprom_mac = new byte[6]; UInt32 result = io.Read32(0x00); eeprom_mac[0] = BinaryHelper.GetByteFrom32bit(result, 0); eeprom_mac[1] = BinaryHelper.GetByteFrom32bit(result, 8); eeprom_mac[2] = BinaryHelper.GetByteFrom32bit(result, 16); eeprom_mac[3] = BinaryHelper.GetByteFrom32bit(result, 24); result = io.Read32(0x04); eeprom_mac[4] = BinaryHelper.GetByteFrom32bit(result, 0); eeprom_mac[5] = BinaryHelper.GetByteFrom32bit(result, 8); mac = new MACAddress(eeprom_mac); // Allocate 32 bytes for the 28 byte Initialization block that has to be aligned to a 4 byte boundary //UInt32 address = Heap.MemAlloc(0x20); //mInitBlock = new ManagedUInt32Array(7); // 7 UInt32's, aligned on a 4byte boundary mInitBlock = new ManagedMemorySpace(28, 4); /*Console.Write("Allocated 32 bytes for initialization block @ 0x" + address.ToHex(8)); * Console.WriteLine("(Aligned to 0x" + aligned_address.ToHex(8) + ")");*/ // Allocate 80 uints for the 16 RX and TX Descriptor rings. These addresses have to be aligned on a 16-byte boundary mTxDescriptor = new ManagedMemorySpace(256, 16); mRxDescriptor = new ManagedMemorySpace(256, 16); /*Console.Write("Allocated 320 bytes for RX ring descriptors @ 0x" + rd_address.ToHex(8)); * Console.WriteLine("(Aligned to 0x" + mRxDescriptorAddress.ToHex(8) + ")"); * Console.Write("Allocated 320 bytes for TX ring descriptors @ 0x" + tx_address.ToHex(8)); * Console.WriteLine("(Aligned to 0x" + mTxDescriptorAddress.ToHex(8) + ")");*/ // Fill in the Initialization block mInitBlock.Write32(0x00, (0x4 << 28) | (0x4 << 20)); mInitBlock.Write32(0x04, (uint)(eeprom_mac[0] | (eeprom_mac[1] << 8) | (eeprom_mac[2] << 16) | (eeprom_mac[3] << 24))); mInitBlock.Write32(0x08, (uint)(eeprom_mac[4] | (eeprom_mac[5] << 8))); mInitBlock.Write32(0x0C, 0x0); mInitBlock.Write32(0x10, 0x0); mInitBlock.Write32(0x14, mRxDescriptor.Offset); mInitBlock.Write32(0x18, mTxDescriptor.Offset); // Write the Initialization blocks address to the registers on the card InitializationBlockAddress = mInitBlock.Offset; // Set the device to PCNet-PCI II Controller mode (full 32-bit mode) SoftwareStyleRegister = 0x03; /* Initialize the RX and TX buffers, and set up the RX and TX descriptors to point * to the buffers. Also, mark the RX descriptors as being owned by the card so data * can be received in them */ mRxBuffers = new List <ManagedMemorySpace>(); mTxBuffers = new List <ManagedMemorySpace>(); for (uint rxd = 0; rxd < 16; rxd++) { uint xOffset = rxd * 16; ManagedMemorySpace buffer = new ManagedMemorySpace(2048); mRxDescriptor.Write32(xOffset + 8, buffer.Offset); UInt16 buffer_len = (UInt16)(~buffer.Size); buffer_len++; UInt32 flags = (UInt32)(buffer_len & 0x0FFF) | 0xF000 | 0x80000000; mRxDescriptor.Write32(xOffset + 4, flags); mRxBuffers.Add(buffer); } for (uint txd = 0; txd < 16; txd++) { uint xOffset = txd * 16; ManagedMemorySpace buffer = new ManagedMemorySpace(2048); mTxDescriptor.Write32(xOffset + 8, buffer.Offset); mTxBuffers.Add(buffer); } // Set TX Descriptor 0 as the first one to use... Increment this when we use one to use them in a circular fashion mNextTXDesc = 0; // Setup our Receive and Transmit Queues mTransmitBuffer = new Queue <byte[]>(); mRecvBuffer = new Queue <byte[]>(); }
public VT6102(PCIDevice device) { if (device == null) { throw new ArgumentException("PCI Device is null. Unable to get VIA Rhine-II card"); } pciCard = device; // We are handling this device pciCard.Claimed = true; // Setup interrupt handling //Interrupts.IRQ10 += HandleNetworkInterrupt; //Interrupts.AddIRQHandler(device.InterruptLine, HandleNetworkInterrupt); // Get IO Address from PCI Bus io = pciCard.GetAddressSpace(0) as Kernel.IOAddressSpace; // Enable the card pciCard.EnableDevice(); // Get the EEPROM MAC Address and set it as the devices MAC byte[] eeprom_mac = new byte[6]; UInt32 result = io.Read32(0x00); eeprom_mac[0] = BinaryHelper.GetByteFrom32bit(result, 0); eeprom_mac[1] = BinaryHelper.GetByteFrom32bit(result, 8); eeprom_mac[2] = BinaryHelper.GetByteFrom32bit(result, 16); eeprom_mac[3] = BinaryHelper.GetByteFrom32bit(result, 24); result = io.Read32(0x04); eeprom_mac[4] = BinaryHelper.GetByteFrom32bit(result, 0); eeprom_mac[5] = BinaryHelper.GetByteFrom32bit(result, 8); mac = new MACAddress(eeprom_mac); // Software Reset device SoftwareReset(); // Configure Receive Config ReceiveConfigRegister = 0x1C; // Configure Transmit Config TransmitConfigRegister = 0x04; // Setup RX Descriptors mRxDescriptors = new ManagedMemorySpace(256, 16); // Setup TX Descriptors mTxDescriptors = new ManagedMemorySpace(256, 16); /* Initialize the RX and TX buffers, and set up the RX descriptors to point * to the buffers. Also, mark the RX descriptors as being owned by the card so data * can be received in them */ mRxBuffers = new List <ManagedMemorySpace>(); for (uint rxd = 0; rxd < 16; rxd++) { uint xOffset = rxd * 16; ManagedMemorySpace buffer = new ManagedMemorySpace(2048); mRxDescriptors.Write32(xOffset + 12, mRxDescriptors.Offset + xOffset + 16); mRxDescriptors.Write32(xOffset + 8, buffer.Offset); mRxDescriptors.Write32(xOffset + 4, buffer.Size); mRxDescriptors.Write32(xOffset, 0x80000000); mRxBuffers.Add(buffer); } mRxDescriptors.Write32(252, mRxDescriptors.Offset); for (uint txd = 0; txd < 16; txd++) { uint xOffset = txd * 16; mTxDescriptors.Write32(xOffset + 12, mTxDescriptors.Offset + xOffset + 16); mTxDescriptors.Write32(xOffset + 8, 0); mTxDescriptors.Write32(xOffset + 4, 0); mTxDescriptors.Write32(xOffset, 0); } mTxDescriptors.Write32(252, mTxDescriptors.Offset); mNextTXDesc = 0; RxDescAddressRegister = mRxDescriptors.Offset; TxDescAddressRegister = mTxDescriptors.Offset; // Setup and clear interrupts IntMaskRegister = 0xFFFF; IntStatusRegister = 0xFFFF; // Setup our Receive and Transmit Queues mTransmitBuffer = new Queue <byte[]>(); mRecvBuffer = new Queue <byte[]>(); }