]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - include/pci.h
actual license now
[netwatch.git] / include / pci.h
... / ...
CommitLineData
1/* pci.h
2 * Definitions for PCI access
3 * NetWatch system management mode administration console
4 *
5 * Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved.
6 * This program is free software; you can redistribute and/or modify it under
7 * the terms found in the file LICENSE in the root of this source tree.
8 *
9 */
10
11
12#ifndef PCI_H
13#define PCI_H
14
15#include <stdint.h>
16
17/* General PCI functions. This is implemented by pci-linux.c and pci-raw.c; the
18 * former uses Linux's /proc/bus/pci interface for access from userspace, while
19 * the latter accesses the PCI hardware directly.
20 */
21
22void pci_write32(int bus, int slot, int fn, int addr, uint32_t data);
23void pci_write16(int bus, int slot, int fn, int addr, uint16_t data);
24void pci_write8(int bus, int slot, int fn, int addr, uint8_t data);
25
26uint32_t pci_read32(int bus, int slot, int fn, int addr);
27uint16_t pci_read16(int bus, int slot, int fn, int addr);
28uint8_t pci_read8(int bus, int slot, int fn, int addr);
29
30/* Hardware-agnostic functions implemented by pci.c */
31typedef enum {
32 PCI_BAR_NONE = 0,
33 PCI_BAR_MEMORY32,
34 PCI_BAR_MEMORY64,
35 PCI_BAR_IO
36} pci_bar_type_t;
37
38typedef struct pci_bar {
39 pci_bar_type_t type;
40 unsigned char prefetchable;
41 unsigned long addr;
42} pci_bar_t;
43
44typedef struct pci_dev {
45 unsigned short vid, did;
46 int bus, dev, fn;
47 pci_bar_t bars[6];
48} pci_dev_t;
49
50typedef int (*pci_probe_fn_t)(pci_dev_t *, void *data);
51
52void pci_bus_enum();
53int pci_probe(pci_probe_fn_t probe, void *data);
54
55typedef struct pci_id {
56 unsigned short vid, did;
57 const char *name, *friendlyname;
58} pci_id_t;
59
60#define PCI_ROM(a,b,c,d) {(a),(b),(c),(d)}
61
62typedef struct pci_driver {
63 const char *name;
64 pci_probe_fn_t probe;
65 pci_id_t *ids;
66 int id_count;
67} pci_driver_t;
68
69int pci_probe_driver(pci_driver_t *driver);
70
71#endif
This page took 0.025022 seconds and 4 git commands to generate.