1 /* This file is part of the coreboot project. */
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; version 2 of the License.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
15 #include "pci-userspace.h"
19 static struct pci_access
*pacc
;
21 int pci_initialize(void)
29 for (dev
= pacc
->devices
; dev
; dev
= dev
->next
) {
30 pci_fill_info(dev
, PCI_FILL_IDENT
| PCI_FILL_BASES
);
41 u8
pci_read_config8(struct device
*dev
, unsigned int where
)
44 if ((d
= pci_get_dev(pacc
, 0, dev
->busno
, dev
->slot
, dev
->func
)))
45 return pci_read_byte(d
, where
);
47 printf("PCI: device not found while read byte (%x:%x.%x)\n",
48 dev
->busno
, dev
->slot
, dev
->func
);
53 u16
pci_read_config16(struct device
*dev
, unsigned int where
)
56 if ((d
= pci_get_dev(pacc
, 0, dev
->busno
, dev
->slot
, dev
->func
)))
57 return pci_read_word(d
, where
);
59 printf("PCI: device not found while read word (%x:%x.%x)\n",
60 dev
->busno
, dev
->slot
, dev
->func
);
65 u32
pci_read_config32(struct device
*dev
, unsigned int where
)
68 if ((d
= pci_get_dev(pacc
, 0, dev
->busno
, dev
->slot
, dev
->func
)))
69 return pci_read_long(d
, where
);
71 printf("PCI: device not found while read dword (%x:%x.%x)\n",
72 dev
->busno
, dev
->slot
, dev
->func
);
77 void pci_write_config8(struct device
*dev
, unsigned int where
, u8 val
)
80 if ((d
= pci_get_dev(pacc
, 0, dev
->busno
, dev
->slot
, dev
->func
)))
81 pci_write_byte(d
, where
, val
);
84 printf("PCI: device not found while write byte (%x:%x.%x)\n",
85 dev
->busno
, dev
->slot
, dev
->func
);
89 void pci_write_config16(struct device
*dev
, unsigned int where
, u16 val
)
92 if ((d
= pci_get_dev(pacc
, 0, dev
->busno
, dev
->slot
, dev
->func
)))
93 pci_write_word(d
, where
, val
);
96 printf("PCI: device not found while write word (%x:%x.%x)\n",
97 dev
->busno
, dev
->slot
, dev
->func
);
101 void pci_write_config32(struct device
*dev
, unsigned int where
, u32 val
)
104 if ((d
= pci_get_dev(pacc
, 0, dev
->busno
, dev
->slot
, dev
->func
)))
105 pci_write_long(d
, where
, val
);
108 printf("PCI: device not found while write dword (%x:%x.%x)\n",
109 dev
->busno
, dev
->slot
, dev
->func
);