determine all six IO base addresses
This commit is contained in:
parent
29ac8511c7
commit
b49f2ef08a
1 changed files with 12 additions and 11 deletions
|
@ -36,7 +36,6 @@
|
|||
#define PCI_CFRV 0x08 /* Configuration Revision */
|
||||
#define PCI_CFLT 0x0c /* Configuration Latency Timer */
|
||||
#define PCI_CBIO 0x10 /* Configuration Base IO Address */
|
||||
#define PCI_CBMA 0x14 /* Configuration Base Memory Address */
|
||||
#define PCI_CFIT 0x3c /* Configuration Interrupt */
|
||||
#define PCI_CFDA 0x40 /* Configuration Driver Area */
|
||||
|
||||
|
@ -98,24 +97,24 @@ static inline uint32_t pci_what_irq(uint32_t bus, uint32_t slot)
|
|||
return pci_conf_read(bus, slot, PCI_CFIT) & 0xFF;
|
||||
}
|
||||
|
||||
static inline uint32_t pci_what_iobase(uint32_t bus, uint32_t slot)
|
||||
static inline uint32_t pci_what_iobase(uint32_t bus, uint32_t slot, uint32_t nr)
|
||||
{
|
||||
return pci_conf_read(bus, slot, PCI_CBIO) & 0xFFFFFFFC;
|
||||
return pci_conf_read(bus, slot, PCI_CBIO + nr*4) & 0xFFFFFFFC;
|
||||
}
|
||||
|
||||
static inline uint32_t pci_what_size(uint32_t bus, uint32_t slot)
|
||||
static inline uint32_t pci_what_size(uint32_t bus, uint32_t slot, uint32_t nr)
|
||||
{
|
||||
uint32_t tmp, ret;
|
||||
|
||||
// backup the original value
|
||||
tmp = pci_conf_read(bus, slot, PCI_CBIO);
|
||||
tmp = pci_conf_read(bus, slot, PCI_CBIO + nr*4);
|
||||
|
||||
// determine size
|
||||
pci_conf_write(bus, slot, PCI_CBIO, 0xFFFFFFFF);
|
||||
ret = ~pci_conf_read(bus, slot, PCI_CBIO) + 1;
|
||||
pci_conf_write(bus, slot, PCI_CBIO + nr*4, 0xFFFFFFFF);
|
||||
ret = ~pci_conf_read(bus, slot, PCI_CBIO + nr*4) + 1;
|
||||
|
||||
// restore original value
|
||||
pci_conf_write(bus, slot, PCI_CBIO, tmp);
|
||||
pci_conf_write(bus, slot, PCI_CBIO + nr*4, tmp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -133,7 +132,7 @@ int pci_init(void)
|
|||
|
||||
int pci_get_device_info(uint32_t vendor_id, uint32_t device_id, pci_info_t* info)
|
||||
{
|
||||
uint32_t slot, bus;
|
||||
uint32_t slot, bus, i;
|
||||
|
||||
if (!info)
|
||||
return -EINVAL;
|
||||
|
@ -146,8 +145,10 @@ int pci_get_device_info(uint32_t vendor_id, uint32_t device_id, pci_info_t* info
|
|||
if (adapters[bus][slot] != -1) {
|
||||
if (((adapters[bus][slot] & 0xffff) == vendor_id) &&
|
||||
(((adapters[bus][slot] & 0xffff0000) >> 16) == device_id)) {
|
||||
info->base[0] = pci_what_iobase(bus, slot);
|
||||
info->size[0] = pci_what_size(bus, slot);
|
||||
for(i=0; i<6; i++) {
|
||||
info->base[i] = pci_what_iobase(bus, slot, i);
|
||||
info->size[i] = (info->base[i]) ? pci_what_size(bus, slot, i) : 0;
|
||||
}
|
||||
info->irq = pci_what_irq(bus, slot);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue