]> Joshua Wise's Git repositories - netwatch.git/blame - include/pci.h
Fix 'i r retard' bug in timer
[netwatch.git] / include / pci.h
CommitLineData
7e16b8e6
JP
1#ifndef PCI_H
2#define PCI_H
3
81148fa1
JW
4#include <stdint.h>
5
7e16b8e6
JP
6/* General PCI functions. This is implemented by pci-linux.c and pci-raw.c; the
7 * former uses Linux's /proc/bus/pci interface for access from userspace, while
8 * the latter accesses the PCI hardware directly.
9 */
10
11void pci_write32(int bus, int slot, int fn, int addr, uint32_t data);
12void pci_write16(int bus, int slot, int fn, int addr, uint16_t data);
13void pci_write8(int bus, int slot, int fn, int addr, uint8_t data);
14
15uint32_t pci_read32(int bus, int slot, int fn, int addr);
16uint16_t pci_read16(int bus, int slot, int fn, int addr);
17uint8_t pci_read8(int bus, int slot, int fn, int addr);
18
83a02556
JW
19/* Hardware-agnostic functions implemented by pci.c */
20typedef enum {
21 PCI_BAR_NONE = 0,
22 PCI_BAR_MEMORY32,
23 PCI_BAR_MEMORY64,
24 PCI_BAR_IO
25} pci_bar_type_t;
26
27typedef struct pci_bar {
28 pci_bar_type_t type;
29 unsigned char prefetchable;
30 unsigned long addr;
31} pci_bar_t;
32
33typedef struct pci_dev {
34 unsigned short vid, did;
35 int bus, dev, fn;
36 pci_bar_t bars[6];
37} pci_dev_t;
38
e9d467b3 39typedef int (*pci_probe_fn_t)(pci_dev_t *, void *data);
83a02556
JW
40
41void pci_bus_enum();
e9d467b3
JW
42int pci_probe(pci_probe_fn_t probe, void *data);
43
44typedef struct pci_id {
45 unsigned short vid, did;
46 const char *name, *friendlyname;
47} pci_id_t;
48
49#define PCI_ROM(a,b,c,d) {(a),(b),(c),(d)}
50
51typedef struct pci_driver {
52 const char *name;
53 pci_probe_fn_t probe;
54 pci_id_t *ids;
55 int id_count;
56} pci_driver_t;
57
58int pci_probe_driver(pci_driver_t driver);
83a02556 59
7e16b8e6 60#endif
This page took 0.023923 seconds and 4 git commands to generate.