|
|
1.1 ! root 1: /* Simplistic PCI support. ! 2: ! 3: Copyright (C) 2011 Richard Henderson ! 4: ! 5: This file is part of QEMU PALcode. ! 6: ! 7: This program is free software; you can redistribute it and/or modify ! 8: it under the terms of the GNU General Public License as published by ! 9: the Free Software Foundation; either version 2 of the License or ! 10: (at your option) any later version. ! 11: ! 12: This program is distributed in the hope that it will be useful, ! 13: but WITHOUT ANY WARRANTY; without even the implied warranty of ! 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the text ! 15: of the GNU General Public License for more details. ! 16: ! 17: You should have received a copy of the GNU General Public License ! 18: along with this program; see the file COPYING. If not see ! 19: <http://www.gnu.org/licenses/>. */ ! 20: ! 21: /* This header is intended to be compatible with the pci.h from SeaBIOS. ! 22: Their header, however, is too PC specific to be of use. */ ! 23: ! 24: #ifndef PCI_H ! 25: #define PCI_H 1 ! 26: ! 27: extern void *pci_conf_base; ! 28: ! 29: static inline void pci_config_writel(int bdf, uint8_t addr, uint32_t val) ! 30: { ! 31: *(volatile uint32_t *)(pci_conf_base + bdf * 256 + addr) = val; ! 32: } ! 33: ! 34: static inline void pci_config_writew(int bdf, uint8_t addr, uint16_t val) ! 35: { ! 36: *(volatile uint16_t *)(pci_conf_base + bdf * 256 + addr) = val; ! 37: } ! 38: ! 39: static inline void pci_config_writeb(int bdf, uint8_t addr, uint8_t val) ! 40: { ! 41: *(volatile uint8_t *)(pci_conf_base + bdf * 256 + addr) = val; ! 42: } ! 43: ! 44: static inline uint32_t pci_config_readl(int bdf, uint8_t addr) ! 45: { ! 46: return *(volatile uint32_t *)(pci_conf_base + bdf * 256 + addr); ! 47: } ! 48: ! 49: static inline uint16_t pci_config_readw(int bdf, uint8_t addr) ! 50: { ! 51: return *(volatile uint16_t *)(pci_conf_base + bdf * 256 + addr); ! 52: } ! 53: ! 54: static inline uint8_t pci_config_readb(int bdf, uint8_t addr) ! 55: { ! 56: return *(volatile uint8_t *)(pci_conf_base + bdf * 256 + addr); ! 57: } ! 58: ! 59: extern void pci_config_maskw(int bdf, int addr, uint16_t off, uint16_t on); ! 60: ! 61: extern int pci_next(int bdf, int *pmax); ! 62: ! 63: #define foreachpci(BDF, MAX) \ ! 64: for (MAX = 0x0100, BDF = pci_next(0, &MAX); \ ! 65: BDF >= 0; \ ! 66: BDF = pci_next(BDF+1, &MAX)) ! 67: ! 68: #endif /* PCI_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.