[LinuxBIOS] regarding pci sement num and extend reg

yhlu yinghailu at gmail.com
Sun Dec 25 00:19:57 CET 2005


I suggest to change PCI_ADDR and PCI_DEV to followings

#define PCI_ADDR(SEGBUS, DEV, FN, WHERE) ( \
        (((SEGBUS) & 0xFFF) << 20) | \
        (((DEV) & 0x1F) << 15) | \
        (((FN) & 0x07) << 12) | \
        ((WHERE) & 0xFFF))

#define PCI_DEV(SEGBUS, DEV, FN) ( \
        (((SEGBUS) & 0xFFF) << 20) | \
        (((DEV) & 0x1F) << 15) | \
        (((FN)  & 0x07) << 12))

So we can put extened reg pos together...

pci read will become

static inline __attribute__((always_inline)) uint32_t
pci_read_config32(device_t dev, unsigned where)
{
        unsigned addr;
        addr = (dev>>4) | (where & 0xff) | ((where & 0xf00)<<16);
        outl(0x80000000 | (addr & ~3), 0xCF8);
        return inl(0xCFC);
}

static inline __attribute__((always_inline)) uint32_t
pci_mmio_read_config32(device_t dev, unsigned where)
{
        unsigned addr;
        addr = dev | where;
        return read32(addr);
}

static inline __attribute__((always_inline)) uint32_t
pci_read_config32x(device_t dev, unsigned where)
{
        if(dev & 0xf0000000) {
                return pci_mmio_read_config32(dev, where);
        } else {
                return pci_read_config32(dev, where);
        }
}

YH




More information about the coreboot mailing list