Example #1
0
        /// <summary>
        /// Performs the LBA28.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="drive">The drive NBR.</param>
        /// <param name="lba">The lba.</param>
        /// <param name="data">The data.</param>
        /// <param name="offset">The offset.</param>
        /// <returns></returns>
        protected bool PerformLBA28(SectorOperation operation, uint drive, uint lba, byte[] data, uint offset)
        {
            if (drive >= MaximunDriveCount || !driveInfo[drive].Present)
            {
                return(false);
            }

            DeviceHeadPort.Write8((byte)(0xE0 | (drive << 4) | ((lba >> 24) & 0x0F)));
            FeaturePort.Write8(0);
            SectorCountPort.Write8(1);
            LBAHighPort.Write8((byte)((lba >> 16) & 0xFF));
            LBAMidPort.Write8((byte)((lba >> 8) & 0xFF));
            LBALowPort.Write8((byte)(lba & 0xFF));

            CommandPort.Write8((operation == SectorOperation.Write) ? IDECommand.WriteSectorsWithRetry : IDECommand.ReadSectorsWithRetry);

            if (!WaitForReadyStatus())
            {
                return(false);
            }

            var sector = new DataBlock(data);

            //TODO: Don't use PIO
            if (operation == SectorOperation.Read)
            {
                for (uint index = 0; index < 256; index++)
                {
                    sector.SetUShort(offset + (index * 2), DataPort.Read16());
                }
            }
            else
            {
                //NOTE: Transfering 16bits at a time seems to fail(?) to write each second 16bits - transfering 32bits seems to fix this (???)
                for (uint index = 0; index < 128; index++)
                {
                    DataPort.Write32(sector.GetUInt(offset + (index * 4)));
                }

                //Cache flush
                DoCacheFlush();
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Probes for this device.
        /// </summary>
        /// <returns></returns>
        public override void Probe()
        {
            configAddress.Write32(BaseValue);

            var found = configAddress.Read32() == BaseValue;

            Device.Status = (found) ? DeviceStatus.Available : DeviceStatus.NotFound;
        }
Example #3
0
        /// <summary>
        /// Probes for this device.
        /// </summary>
        /// <returns></returns>
        public override void Probe()
        {
            configAddress.Write32(BaseValue);

            var found = configAddress.Read32() == BaseValue;

            if (!found)
            {
                Device.Status = DeviceStatus.NotFound;
            }
        }
Example #4
0
        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;
        }
Example #5
0
 /// <summary>
 /// Sends the command.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="value">The value.</param>
 protected void SendCommand(uint command, uint value)
 {
     indexPort.Write32(command);
     valuePort.Write32(value);
 }
Example #6
0
        /// <summary>
        /// Probes for this device.
        /// </summary>
        /// <returns></returns>
        public override bool Probe()
        {
            configAddress.Write32(BaseValue);

            return(configAddress.Read32() == BaseValue);
        }
Example #7
0
 /// <summary>
 /// Writes to configuration space
 /// </summary>
 /// <param name="bus">The bus.</param>
 /// <param name="slot">The slot.</param>
 /// <param name="function">The function.</param>
 /// <param name="register">The register.</param>
 /// <param name="value">The value.</param>
 public void WriteConfig32(byte bus, byte slot, byte function, byte register, uint value)
 {
     configAddress.Write32(GetIndex(bus, slot, function, register));
     configData.Write32(value);
 }