예제 #1
0
        /// <summary>
        /// Write data to PCI
        /// </summary>
        /// <param name="bus">Bus</param>
        /// <param name="slot">Slot</param>
        /// <param name="function">Function</param>
        /// <param name="offset">Offset</param>
        /// <param name="value">The value to write</param>
        /// <param name="size">The size of the data to write</param>
        public static void Write(ushort bus, ushort slot, ushort function, ushort offset, uint value, uint size)
        {
            uint address = generateAddress(bus, slot, function, offset);

            PortIO.Out32(CONFIG_ADR, address);

            if (size == 4)
            {
                PortIO.Out32(DATA_ADR, value);
            }
            else if (size == 2)
            {
                PortIO.Out16((ushort)(DATA_ADR + (offset & 0x02)), (ushort)value);
            }
            else if (size == 1)
            {
                PortIO.Out8((ushort)(DATA_ADR + (offset & 0x03)), (byte)value);
            }
        }
예제 #2
0
        /// <summary>
        /// Read data from PCI
        /// </summary>
        /// <param name="bus">Bus</param>
        /// <param name="slot">Slot</param>
        /// <param name="function">Function</param>
        /// <param name="offset">Offset</param>
        /// <param name="size">The size of the data to read</param>
        /// <returns>The read data</returns>
        public static uint Read(ushort bus, ushort slot, ushort function, ushort offset, uint size)
        {
            uint address = generateAddress(bus, slot, function, offset);

            PortIO.Out32(CONFIG_ADR, address);

            if (size == 4)
            {
                return(PortIO.In32(DATA_ADR) & 0xFFFFFFFF);
            }
            else if (size == 2)
            {
                return((uint)PortIO.In16((ushort)(DATA_ADR + (offset & 0x02))) & 0xFFFF);
            }
            else if (size == 1)
            {
                return((uint)PortIO.In8((ushort)(DATA_ADR + (offset & 0x03))) & 0xFF);
            }

            return(0xFFFFFFFF);
        }