/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool
7.1.6 by Suren A. Chilingaryan
Provide single header for library
1
#ifndef _PCITOOL_PCI_H
2
#define _PCITOOL_PCI_H
3
126 by Suren A. Chilingaryan
multithread preprocessing of ipecamera frames and code reorganization
4
#define PCILIB_DEFAULT_CPU_COUNT 2
119 by Suren A. Chilingaryan
Initial support of event streaming in cli
5
#define PCILIB_EVENT_TIMEOUT 1000000		/**< us */
6
#define PCILIB_TRIGGER_TIMEOUT 100000		/**< us */
45 by root
North West Logick DMA implementation
7
#define PCILIB_DMA_TIMEOUT 10000		/**< us */
70 by Suren A. Chilingaryan
Support modifications of DMA engine and allow DMA customizations by Event engine
8
#define PCILIB_DMA_SKIP_TIMEOUT 1000000		/**< us */
236 by Suren A. Chilingaryan
Big redign of model structures
9
#define PCILIB_MAX_BARS 6			/**< this is defined by PCI specification */
10
#define PCILIB_DEFAULT_REGISTER_SPACE 1024	/**< number of registers to allocate on init */
305.1.6 by nicolas.zilio at hotmail
more towards views
11
#define PCILIB_DEFAULT_VIEW_SPACE 128    	/**< number of views to allocate on init */
307 by Suren A. Chilingaryan
Finalyze XML support and provide initial support for views (only descriptions so far)
12
#define PCILIB_DEFAULT_UNIT_SPACE 128           /**< number of units to allocate on init */
236 by Suren A. Chilingaryan
Big redign of model structures
13
#define PCILIB_MAX_REGISTER_BANKS 32		/**< maximum number of register banks to allocate space for */
14
#define PCILIB_MAX_REGISTER_RANGES 32		/**< maximum number of register ranges to allocate space for */
15
#define PCILIB_MAX_REGISTER_PROTOCOLS 32	/**< maximum number of register protocols to support */
16
#define PCILIB_MAX_DMA_ENGINES 32		/**< maximum number of supported DMA engines */
7.1.6 by Suren A. Chilingaryan
Provide single header for library
17
307 by Suren A. Chilingaryan
Finalyze XML support and provide initial support for views (only descriptions so far)
18
#include <uthash.h>
19
236 by Suren A. Chilingaryan
Big redign of model structures
20
#include "linux-3.10.h"
365 by Suren A. Chilingaryan
Restructure driver headers
21
#include "driver/ioctl.h"
41 by root
A bit of DMA infrastructure
22
330 by Suren A. Chilingaryan
Support for 64-bit registes
23
#include "timing.h"
24
#include "cpu.h"
331 by Suren A. Chilingaryan
Provide pcilib_get_bar_info & pcilib_get_bar_list API calls, remove obsolete pcilib_resolve_register_address
25
#include "bar.h"
7.1.6 by Suren A. Chilingaryan
Provide single header for library
26
#include "pcilib.h"
47 by Suren A. Chilingaryan
Support FIFO reading/writting, code restructurization, few fixes
27
#include "register.h"
45 by root
North West Logick DMA implementation
28
#include "kmem.h"
55 by Suren A. Chilingaryan
IRQ support in NWL DMA engine
29
#include "irq.h"
47 by Suren A. Chilingaryan
Support FIFO reading/writting, code restructurization, few fixes
30
#include "dma.h"
31
#include "event.h"
236 by Suren A. Chilingaryan
Big redign of model structures
32
#include "model.h"
241 by Suren A. Chilingaryan
Further adjustments to get ready for independent event plugins
33
#include "export.h"
280 by Suren A. Chilingaryan
Integrate locking subsystem from Nicolas Zilio
34
#include "locking.h"
277.2.16 by zilio nicolas
end of modifications
35
#include "xml.h"
309 by Suren A. Chilingaryan
Base functions for views
36
#include "py.h"
307 by Suren A. Chilingaryan
Finalyze XML support and provide initial support for views (only descriptions so far)
37
#include "view.h"
330 by Suren A. Chilingaryan
Support for 64-bit registes
38
#include "memcpy.h"
45 by root
North West Logick DMA implementation
39
267 by Suren A. Chilingaryan
Provide PCIe link information in pcilib
40
typedef struct {
41
    uint8_t max_link_speed, link_speed;
42
    uint8_t max_link_width, link_width;
43
    uint8_t max_payload, payload;
44
} pcilib_pcie_link_info_t;
45
307 by Suren A. Chilingaryan
Finalyze XML support and provide initial support for views (only descriptions so far)
46
45 by root
North West Logick DMA implementation
47
struct pcilib_s {
236 by Suren A. Chilingaryan
Big redign of model structures
48
    int handle;										/**< file handle of device */
352.1.3 by Suren A. Chilingaryan
Detect page mask before any kmem operations (locks, softregs, etc.)
49
50
    pcilib_driver_version_t driver_version;						/**< Version reported by the driver */
51
236 by Suren A. Chilingaryan
Big redign of model structures
52
    uintptr_t page_mask;								/**< Selects bits which define offset within the page */
352.1.3 by Suren A. Chilingaryan
Detect page mask before any kmem operations (locks, softregs, etc.)
53
    int board_info_ready;								/**< Flag indicating if board info is already requested and populated */
236 by Suren A. Chilingaryan
Big redign of model structures
54
    pcilib_board_info_t board_info;							/**< The mandatory information about board as defined by PCI specification */
267 by Suren A. Chilingaryan
Provide PCIe link information in pcilib
55
    pcilib_pcie_link_info_t link_info;							/**< Infomation about PCIe connection */
236 by Suren A. Chilingaryan
Big redign of model structures
56
    char *bar_space[PCILIB_MAX_BARS];							/**< Pointers to the mapped BARs in virtual address space */
331 by Suren A. Chilingaryan
Provide pcilib_get_bar_info & pcilib_get_bar_list API calls, remove obsolete pcilib_resolve_register_address
57
    pcilib_bar_info_t bar_info[PCILIB_MAX_BARS + 1];					/**< NULL terminated list of PCI bar descriptions */
236 by Suren A. Chilingaryan
Big redign of model structures
58
267 by Suren A. Chilingaryan
Provide PCIe link information in pcilib
59
    int pci_cfg_space_fd;								/**< File descriptor linking to PCI configuration space in sysfs */
60
    uint32_t pci_cfg_space_cache[64];							/**< Cached PCI configuration space */
298 by Suren A. Chilingaryan
Do not fail if PCI configuration is not fully available to unprivileged user
61
    size_t pci_cfg_space_size;								/**< Size of the cached PCI configuration space, sometimes not fully is available for unpriveledged user */
267 by Suren A. Chilingaryan
Provide PCIe link information in pcilib
62
    const uint32_t *pcie_capabilities;							/**< PCI Capbility structure (just a pointer at appropriate place in the pci_cfg_space) */
63
236 by Suren A. Chilingaryan
Big redign of model structures
64
    int reg_bar_mapped;									/**< Indicates that all BARs used to access registers are mapped */
65
    pcilib_bar_t reg_bar;								/**< Default BAR to look for registers, other BARs will be looked as well */
66
    int data_bar_mapped;								/**< Indicates that a BAR for large PIO is mapped */
67
    pcilib_bar_t data_bar;								/**< BAR for large PIO operations */
68
69
    pcilib_kmem_list_t *kmem_list;							/**< List of currently allocated kernel memory */
70
71
    char *model;									/**< Requested model */
242 by Suren A. Chilingaryan
Initial support for event engines
72
    void *event_plugin;									/**< Currently loaded event engine */
236 by Suren A. Chilingaryan
Big redign of model structures
73
    pcilib_model_description_t model_info;						/**< Current model description combined from the information returned by the event plugin and all dynamic sources (XML, DMA registers, etc.). Contains only pointers, no deep copy of information returned by event plugin */
74
75
    size_t num_banks_init;								/**< Number of initialized banks */
76
    size_t num_reg, alloc_reg;								/**< Number of registered and allocated registers */
242 by Suren A. Chilingaryan
Initial support for event engines
77
    size_t num_banks, num_protocols, num_ranges;					/**< Number of registered banks, protocols, and register ranges */
303 by Suren A. Chilingaryan
Initial integration of XML support
78
    size_t num_engines;									/**< Number of configured DMA engines */
79
    size_t dyn_banks;									/**< Number of configured dynamic banks */
236 by Suren A. Chilingaryan
Big redign of model structures
80
    pcilib_register_description_t *registers;						/**< List of currently defined registers (from all sources) */
81
    pcilib_register_bank_description_t banks[PCILIB_MAX_REGISTER_BANKS + 1];		/**< List of currently defined register banks (from all sources) */
82
    pcilib_register_range_t ranges[PCILIB_MAX_REGISTER_RANGES + 1];			/**< List of currently defined register ranges (from all sources) */
83
    pcilib_register_protocol_description_t protocols[PCILIB_MAX_REGISTER_PROTOCOLS + 1];/**< List of currently defined register protocols (from all sources) */
84
    pcilib_dma_description_t dma;							/**< Configuration of used DMA implementation */
85
    pcilib_dma_engine_description_t engines[PCILIB_MAX_DMA_ENGINES +  1];		/**< List of engines defined by the DMA implementation */
86
249 by Suren A. Chilingaryan
Create dummy register context
87
    pcilib_register_context_t *register_ctx;						/**< Contexts for registers */
236 by Suren A. Chilingaryan
Big redign of model structures
88
    pcilib_register_bank_context_t *bank_ctx[PCILIB_MAX_REGISTER_BANKS];		/**< Contexts for registers banks if required by register protocol */
89
    pcilib_dma_context_t *dma_ctx;							/**< DMA context */
90
    pcilib_context_t *event_ctx;							/**< Implmentation context */
280 by Suren A. Chilingaryan
Integrate locking subsystem from Nicolas Zilio
91
307 by Suren A. Chilingaryan
Finalyze XML support and provide initial support for views (only descriptions so far)
92
    size_t num_views, alloc_views;							/**< Number of configured and allocated  views*/
93
    size_t num_units, alloc_units;							/**< Number of configured and allocated  units*/
94
    pcilib_view_description_t **views;							/**< list of currently defined views */
95
    pcilib_unit_description_t *units;							/**< list of currently defined units */
96
310 by Suren A. Chilingaryan
Introduce hashes
97
    pcilib_unit_context_t *unit_hash;                                                   /**< Hash of units */
98
    pcilib_view_context_t *view_hash;                                                   /**< Hash of views */
99
    pcilib_register_context_t *reg_hash;                                                /**< Hash of registers */
100
292 by Suren A. Chilingaryan
Protect access to the DMA engine with locks
101
    pcilib_lock_t *dma_rlock[PCILIB_MAX_DMA_ENGINES];					/**< Per-engine locks to serialize streaming and read operations */
102
    pcilib_lock_t *dma_wlock[PCILIB_MAX_DMA_ENGINES];					/**< Per-engine locks to serialize write operations */
103
280 by Suren A. Chilingaryan
Integrate locking subsystem from Nicolas Zilio
104
    struct pcilib_locking_s locks;							/**< Context of locking subsystem */
303 by Suren A. Chilingaryan
Initial integration of XML support
105
    struct pcilib_xml_s xml;                                                    	/**< XML context */
309 by Suren A. Chilingaryan
Base functions for views
106
    struct pcilib_py_s *py;                                                              /**< Python execution context */
280 by Suren A. Chilingaryan
Integrate locking subsystem from Nicolas Zilio
107
45 by root
North West Logick DMA implementation
108
#ifdef PCILIB_FILE_IO
109
    int file_io_handle;
110
#endif /* PCILIB_FILE_IO */
111
};
7.1.6 by Suren A. Chilingaryan
Provide single header for library
112
277 by Suren A. Chilingaryan
Keep C++ compilers happy
113
#ifdef __cplusplus
114
extern "C" {
115
#endif
116
236 by Suren A. Chilingaryan
Big redign of model structures
117
pcilib_context_t *pcilib_get_implementation_context(pcilib_t *ctx);
337 by Suren A. Chilingaryan
Driver versioning
118
119
const pcilib_driver_version_t *pcilib_get_driver_version(pcilib_t *ctx);
45 by root
North West Logick DMA implementation
120
const pcilib_board_info_t *pcilib_get_board_info(pcilib_t *ctx);
267 by Suren A. Chilingaryan
Provide PCIe link information in pcilib
121
const pcilib_pcie_link_info_t *pcilib_get_pcie_link_info(pcilib_t *ctx);
337 by Suren A. Chilingaryan
Driver versioning
122
int pcilib_get_device_state(pcilib_t *ctx, pcilib_device_state_t *state);
123
45 by root
North West Logick DMA implementation
124
125
int pcilib_map_register_space(pcilib_t *ctx);
126
int pcilib_map_data_space(pcilib_t *ctx, uintptr_t addr);
127
335 by Suren A. Chilingaryan
Enforce 64-bit dma mask from IPEDMA if supported
128
int pcilib_set_dma_mask(pcilib_t *ctx, int mask);
338 by Suren A. Chilingaryan
Support setting payload size
129
int pcilib_set_mps(pcilib_t *ctx, int mps);
335 by Suren A. Chilingaryan
Enforce 64-bit dma mask from IPEDMA if supported
130
277 by Suren A. Chilingaryan
Keep C++ compilers happy
131
#ifdef __cplusplus
132
}
133
#endif
134
7.1.6 by Suren A. Chilingaryan
Provide single header for library
135
#endif /* _PCITOOL_PCI_H */