Example #1
0
def PciEmulate():

    _p = pci.PCI_TYPE00()
    _r = []

    for Bus in range(pci.PCI_MAX_BUS + 1):
        for Dev in range(pci.PCI_MAX_DEVICE + 1):
            for Func in range(pci.PCI_MAX_FUNC + 1):

                _p.Hdr.VendorId = _PciIoR16(Bus, Dev, Func, 0x00)

                if _p.Hdr.VendorId == 0xFFFF and Func == 0:
                    break
                if _p.Hdr.VendorId == 0xFFFF:
                    continue

                # _classcode = _PciIoR32 (Bus, Dev, Func, 0x08)
                # if _classcode == 0xFFFFFFFF:
                #   continue

                _r.append((Bus, Dev, Func))

                _p.Hdr.HeaderType = _PciIoR8(Bus, Dev, Func, 0x0E)
                if Func == 0 and not pci.IS_PCI_MULTI_FUNC(_p):
                    break

    return _r
Example #2
0
    def scan(self, Bus=0, Dev=0, Func=0, Reg=0):

        reg = pci.PCI_CONFIG_ACCESS_CF8((Reg & 0xFC, Func, Dev, Bus, 0, 1))

        self.params.p1 = reg.Uint32
        ret = self.proc.execute(self.code, params=self.params, mode='int')

        return ret
Example #3
0
def PciIo16(Bus, Dev, Func):

    try:
        return PciIo16Cache[(Bus, Dev, Func)]
    except:
        pass

    if PciMmioBase != 0:
        PciIoCellExt["CellBase"] = lambda Reg: PciMmioBase + (Bus << 20) + (
            Dev << 15) + (Func << 12) + Reg
        PciIo16CellClass = _Mem16
    else:
        PciIoCellExt["CellBase"] = lambda Reg: pci.PCI_CONFIG_ACCESS_CF8(
            (Reg, Func, Dev, Bus, 0, 1)).Uint32
        PciIo16CellClass = _PciIo16Cell

    _PciIo16Obj = _MemArray("PciIo16(%02X:%02X:%02X)" % (Bus, Dev, Func),
                            16,
                            CellClass=PciIo16CellClass,
                            CellExt=PciIoCellExt)
    PciIo16Cache[(Bus, Dev, Func)] = _PciIo16Obj
    return _PciIo16Obj
Example #4
0
def PciIo32(Bus, Dev, Func):

    try:
        return PciIo32Cache[(Bus, Dev, Func)]
    except:
        pass

    if PciMmioBase != 0:
        PciIoCellExt["CellBase"] = lambda Reg: PciMmioBase + (Bus << 20) + (
            Dev << 15) + (Func << 12) + Reg
        PciIo32CellClass = _Mem32
    else:
        PciIoCellExt["CellBase"] = lambda Reg: pci.PCI_CONFIG_ACCESS_CF8(
            (Reg, Func, Dev, Bus, 0, 1)).Uint32
        PciIo32CellClass = _PciIo32Cell

    _PciIo32Obj = _MemArray("PciIo32(%02X:%02X:%02X)" % (Bus, Dev, Func),
                            32,
                            CellClass=PciIo32CellClass,
                            CellExt=PciIoCellExt,
                            DictKey=PciHeaderS)
    PciIo32Cache[(Bus, Dev, Func)] = _PciIo32Obj
    return _PciIo32Obj
Example #5
0
def _PciIoW8(Bus, Dev, Func, Reg, Val):

    reg = pci.PCI_CONFIG_ACCESS_CF8((Reg, Func, Dev, Bus, 0, 1))
    Io32[0xCF8] = reg.Uint32
    Io8[0xCFC + (Reg & 3)] = Val
Example #6
0
def _PciIoR8(Bus, Dev, Func, Reg):

    reg = pci.PCI_CONFIG_ACCESS_CF8((Reg, Func, Dev, Bus, 0, 1))
    Io32[0xCF8] = reg.Uint32
    return int(Io8[0xCFC + (Reg & 3)])
Example #7
0

if __name__ == '__main__':

    PciDev = PciScan()
    PciData = PciDevUnion()
    _p = PciData.PciReg.Device

    for Bus in range(pci.PCI_MAX_BUS):
        for Dev in range(pci.PCI_MAX_DEVICE):
            for Func in range(pci.PCI_MAX_FUNC):

                PciData.PciRaw[0] = PciDev.scan(Bus, Dev, Func, 0)

                if _p.Hdr.VendorId == 0xFFFF and Func == 0:
                    break

                if _p.Hdr.VendorId == 0xFFFF:
                    continue

                for idx in range(4, EfiPy.sizeof(pci.PCI_TYPE_GENERIC), 4):
                    ret = PciDev.scan(Bus, Dev, Func, idx)
                    PciData.PciRaw[idx / 4] = ret

                print "Bus: %d, Dev: %d, Func: %d" % (Bus, Dev, Func)
                print "  VendorID: 0x%04X, DeviceID: 0x%04X" % (
                    _p.Hdr.VendorId, _p.Hdr.DeviceId)

                if Func == 0 and not pci.IS_PCI_MULTI_FUNC(_p):
                    break
Example #8
0

def PciIo32(Bus, Dev, Func):

    try:
        return PciIo32Cache[(Bus, Dev, Func)]
    except:
        pass

    if PciMmioBase != 0:
        PciIoCellExt["CellBase"] = lambda Reg: PciMmioBase + (Bus << 20) + (
            Dev << 15) + (Func << 12) + Reg
        PciIo32CellClass = _Mem32
    else:
        PciIoCellExt["CellBase"] = lambda Reg: pci.PCI_CONFIG_ACCESS_CF8(
            (Reg, Func, Dev, Bus, 0, 1)).Uint32
        PciIo32CellClass = _PciIo32Cell

    _PciIo32Obj = _MemArray("PciIo32(%02X:%02X:%02X)" % (Bus, Dev, Func),
                            32,
                            CellClass=PciIo32CellClass,
                            CellExt=PciIoCellExt,
                            DictKey=PciHeaderS)
    PciIo32Cache[(Bus, Dev, Func)] = _PciIo32Obj
    return _PciIo32Obj


PciIoConfigAddress = lambda Bus, Dev, Func, Reg: pci.PCI_CONFIG_ACCESS_CF8(
    (Reg, Func, Dev, Bus, 0, 1)).Uint32
PciMmioConfigOffset = lambda Bus, Dev, Func, Reg: (Bus << 20) + (Dev << 15) + (
    Func << 12) + Reg