Ejemplo n.º 1
0
        private ushort PrepareAccess(PciDevice d, ushort pos)
        {
            if (pos >= 256)
            {
                throw new ArgumentOutOfRangeException(nameof(pos));
            }

            var code = GetConfigAddress(d.Bus, d.Dev, d.Func, pos);

            DirectIo.Write(code, 0xcf8);

            var addr = (ushort)(0xcfc + (ushort)(pos & 3));

            return(addr);
        }
Ejemplo n.º 2
0
        public bool Detect()
        {
            if (!DirectIo.Startup())
            {
                return(false);
            }

            DirectIo.Write(1, 0xCFB);
            var tmp = DirectIo.ReadUInt32(0xCF8);

            DirectIo.Write(0x80000000, 0xCF8);
            var result = DirectIo.ReadUInt32(0xCF8) == 0x80000000;

            DirectIo.Write(tmp, 0xCF8);

            return(result && Check());
        }
Ejemplo n.º 3
0
        public void Write(PciDevice device, ushort offset, uint value)
        {
            var ptr = PrepareAccess(device, offset);

            DirectIo.Write(value, ptr);
        }
Ejemplo n.º 4
0
        public byte ReadByte(PciDevice device, ushort offset)
        {
            var ptr = PrepareAccess(device, offset);

            return(DirectIo.ReadByte(ptr));
        }
Ejemplo n.º 5
0
        public ushort ReadUint16(PciDevice device, ushort offset)
        {
            var ptr = PrepareAccess(device, offset);

            return(DirectIo.ReadUInt16(ptr));
        }