1 #ifndef PCI_H 2 #define PCI_H 3 /* 4 * API for scanning a PCI bus for a given device, as well to access 5 * BAR registers. 6 * 7 * Copyright (C) 2013, Red Hat Inc, Michael S. Tsirkin <mst@redhat.com> 8 * 9 * This work is licensed under the terms of the GNU LGPL, version 2. 10 */ 11 #include "libcflat.h" 12 13 typedef uint16_t pcidevaddr_t; 14 enum { 15 PCIDEVADDR_INVALID = 0xffff, 16 }; 17 18 extern pcidevaddr_t pci_find_dev(uint16_t vendor_id, uint16_t device_id); 19 extern unsigned long pci_bar_addr(pcidevaddr_t dev, int bar_num); 20 extern bool pci_bar_is_memory(pcidevaddr_t dev, int bar_num); 21 extern bool pci_bar_is_valid(pcidevaddr_t dev, int bar_num); 22 23 /* 24 * pci-testdev is a driver for the pci-testdev qemu pci device. The 25 * device enables testing mmio and portio exits, and measuring their 26 * speed. 27 */ 28 #define PCI_VENDOR_ID_REDHAT 0x1b36 29 #define PCI_DEVICE_ID_REDHAT_TEST 0x0005 30 31 #define PCI_TESTDEV_NUM_BARS 2 32 33 struct pci_test_dev_hdr { 34 uint8_t test; 35 uint8_t width; 36 uint8_t pad0[2]; 37 uint32_t offset; 38 uint32_t data; 39 uint32_t count; 40 uint8_t name[]; 41 }; 42 43 #endif /* PCI_H */ 44