diff options
| author | Burt P <pburt0@gmail.com> | 2018-03-17 15:48:47 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2018-04-24 07:43:43 -0700 | 
| commit | dffc0b9dd005015f5df36448b1f2952493f5fc1e (patch) | |
| tree | 8d8b21ecd24d33e62f69c3f2c1db8952073b3887 /includes | |
| parent | 7bec02cb303c7fc096cdb91d5ef5d9323d728a37 (diff) | |
[new] pci_util: functions and data structures for pci information
Based on usb_util. Only current method is via lspci, but framework
exists to add other methods.
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'includes')
| -rw-r--r-- | includes/pci_util.h | 72 | 
1 files changed, 72 insertions, 0 deletions
| diff --git a/includes/pci_util.h b/includes/pci_util.h new file mode 100644 index 00000000..827f6197 --- /dev/null +++ b/includes/pci_util.h @@ -0,0 +1,72 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2017 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#ifndef __PCI_UTIL_H__ +#define __PCI_UTIL_H__ + +#include <stdint.h> + +#define SYSFS_PCI_ROOT "/sys/bus/pci/devices" + +char *pci_address_str(uint32_t dom, uint32_t bus, uint32_t  dev, uint32_t func); + +typedef struct pcid { +    uint32_t domain; +    uint32_t bus; +    uint32_t device; +    uint32_t function; +    uint32_t class; +    uint32_t vendor_id; +    uint32_t device_id; +    uint32_t sub_vendor_id; +    uint32_t sub_device_id; +    uint32_t revision; +    char *slot_str; +    char *class_str; +    char *vendor_id_str; +    char *device_id_str; +    char *sub_vendor_id_str; +    char *sub_device_id_str; + +    char *driver; /* Kernel driver in use */ +    char *driver_list; /* Kernel modules */ + +    float pcie_speed_max;   /* GT/s */ +    float pcie_speed_curr;  /* GT/s */ +    uint32_t pcie_width_max; +    uint32_t pcie_width_curr; + +    /* ... */ + +    struct pcid *next; /* this is a linked list */ +} pcid; + +/* examples: + * to get all pci devices: + *    pcid *list = pci_get_device_list(0, 0); + * to get all display controllers: + *    pcid *list = pci_get_device_list(0x300, 0x3ff); + */ +pcid *pci_get_device_list(uint32_t class_min, uint32_t class_max); +int pcid_list_count(pcid *); +void pcid_list_free(pcid *); + +pcid *pci_get_device(uint32_t dom, uint32_t bus, uint32_t dev, uint32_t func); +void pcid_free(pcid *); + +#endif | 
