/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pci.h

  • Committer: Suren A. Chilingaryan
  • Date: 2015-04-20 20:01:04 UTC
  • Revision ID: csa@suren.me-20150420200104-b5xny65io8lvoz3w
Big redign of model structures

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#define PCILIB_DMA_TIMEOUT 10000                /**< us */
8
8
#define PCILIB_DMA_SKIP_TIMEOUT 1000000         /**< us */
9
9
#define PCILIB_REGISTER_TIMEOUT 10000           /**< us */
 
10
#define PCILIB_MAX_BARS 6                       /**< this is defined by PCI specification */
 
11
#define PCILIB_DEFAULT_REGISTER_SPACE 1024      /**< number of registers to allocate on init */
 
12
#define PCILIB_MAX_REGISTER_BANKS 32            /**< maximum number of register banks to allocate space for */
 
13
#define PCILIB_MAX_REGISTER_RANGES 32           /**< maximum number of register ranges to allocate space for */
 
14
#define PCILIB_MAX_REGISTER_PROTOCOLS 32        /**< maximum number of register protocols to support */
 
15
#define PCILIB_MAX_DMA_ENGINES 32               /**< maximum number of supported DMA engines */
10
16
 
 
17
#include "linux-3.10.h"
11
18
#include "driver/pciDriver.h"
12
 
#include "pcilib_types.h"
13
19
 
14
20
#include "pcilib.h"
15
21
#include "register.h"
17
23
#include "irq.h"
18
24
#include "dma.h"
19
25
#include "event.h"
 
26
#include "model.h"
 
27
#include "config.h"
20
28
 
21
29
struct pcilib_s {
22
 
    int handle;
23
 
    
24
 
    uintptr_t page_mask;
25
 
    pcilib_board_info_t board_info;
26
 
    pcilib_dma_info_t dma_info;
27
 
    pcilib_model_t model;
28
 
    
29
 
    char *bar_space[PCILIB_MAX_BANKS];
30
 
 
31
 
    int reg_bar_mapped;
32
 
    pcilib_bar_t reg_bar;
33
 
//    char *reg_space;
34
 
 
35
 
    int data_bar_mapped;
36
 
    pcilib_bar_t data_bar;
37
 
//    char *data_space;
38
 
//    size_t data_size;
39
 
    
40
 
    pcilib_kmem_list_t *kmem_list;
41
 
 
42
 
    size_t num_reg, alloc_reg;
43
 
    pcilib_model_description_t model_info;
44
 
    
45
 
    pcilib_dma_context_t *dma_ctx;
46
 
    pcilib_context_t *event_ctx;
47
 
    
 
30
    int handle;                                                                         /**< file handle of device */
 
31
    
 
32
    uintptr_t page_mask;                                                                /**< Selects bits which define offset within the page */
 
33
    pcilib_board_info_t board_info;                                                     /**< The mandatory information about board as defined by PCI specification */
 
34
    char *bar_space[PCILIB_MAX_BARS];                                                   /**< Pointers to the mapped BARs in virtual address space */
 
35
 
 
36
    int reg_bar_mapped;                                                                 /**< Indicates that all BARs used to access registers are mapped */
 
37
    pcilib_bar_t reg_bar;                                                               /**< Default BAR to look for registers, other BARs will be looked as well */
 
38
    int data_bar_mapped;                                                                /**< Indicates that a BAR for large PIO is mapped */
 
39
    pcilib_bar_t data_bar;                                                              /**< BAR for large PIO operations */
 
40
 
 
41
    pcilib_kmem_list_t *kmem_list;                                                      /**< List of currently allocated kernel memory */
 
42
 
 
43
    char *model;                                                                        /**< Requested model */
 
44
    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 */
 
45
 
 
46
    size_t num_banks_init;                                                              /**< Number of initialized banks */
 
47
    size_t num_reg, alloc_reg;                                                          /**< Number of registered and allocated registers */
 
48
    size_t num_banks, num_ranges;                                                       /**< Number of registered banks and register ranges */
 
49
    size_t num_engines;                                                                 /**> Number of configured DMA engines */
 
50
    pcilib_register_description_t *registers;                                           /**< List of currently defined registers (from all sources) */
 
51
    pcilib_register_bank_description_t banks[PCILIB_MAX_REGISTER_BANKS + 1];            /**< List of currently defined register banks (from all sources) */
 
52
    pcilib_register_range_t ranges[PCILIB_MAX_REGISTER_RANGES + 1];                     /**< List of currently defined register ranges (from all sources) */
 
53
    pcilib_register_protocol_description_t protocols[PCILIB_MAX_REGISTER_PROTOCOLS + 1];/**< List of currently defined register protocols (from all sources) */
 
54
    pcilib_dma_description_t dma;                                                       /**< Configuration of used DMA implementation */
 
55
    pcilib_dma_engine_description_t engines[PCILIB_MAX_DMA_ENGINES +  1];               /**< List of engines defined by the DMA implementation */
 
56
 
 
57
//    pcilib_register_context_t *register_ctx;                                          /**< Contexts for registers */
 
58
    pcilib_register_bank_context_t *bank_ctx[PCILIB_MAX_REGISTER_BANKS];                /**< Contexts for registers banks if required by register protocol */
 
59
    pcilib_dma_context_t *dma_ctx;                                                      /**< DMA context */
 
60
    pcilib_context_t *event_ctx;                                                        /**< Implmentation context */
 
61
 
 
62
//    pcilib_dma_info_t dma_info;
 
63
 
48
64
#ifdef PCILIB_FILE_IO
49
65
    int file_io_handle;
50
66
#endif /* PCILIB_FILE_IO */
51
67
};
52
68
 
53
 
#ifdef _PCILIB_PCI_C
54
 
# include "ipecamera/model.h"
55
 
# include "kapture/model.h"
56
 
# include "dma/nwl.h"
57
 
# include "dma/ipe.h"
58
 
# include "default.h"
59
 
 
60
 
pcilib_model_description_t pcilib_model[4] = {
61
 
    { 4, PCILIB_HOST_ENDIAN,    NULL, NULL, NULL, NULL, NULL, NULL },
62
 
    { 4, PCILIB_HOST_ENDIAN,    NULL, NULL, NULL, NULL, NULL, NULL },
63
 
    { 4, PCILIB_LITTLE_ENDIAN,  ipecamera_registers, ipecamera_register_banks, ipecamera_register_ranges, ipecamera_events, ipecamera_data_types, &nwl_dma_api, &ipecamera_image_api },
64
 
    { 4, PCILIB_LITTLE_ENDIAN,  kapture_registers, kapture_register_banks, kapture_register_ranges, kapture_events, kapture_data_types, &ipe_dma_api, &kapture_api },
65
 
};
66
 
 
67
 
pcilib_protocol_description_t pcilib_protocol[3] = {
68
 
    { pcilib_default_read, pcilib_default_write },
69
 
    { ipecamera_read, ipecamera_write },
70
 
    { NULL, NULL }
71
 
};
72
 
#else
73
 
extern pcilib_model_description_t pcilib_model[];
74
 
extern pcilib_protocol_description_t pcilib_protocol[];
75
 
#endif /* _PCILIB_PCI_C */
76
 
 
 
69
 
 
70
pcilib_context_t *pcilib_get_implementation_context(pcilib_t *ctx);
77
71
const pcilib_board_info_t *pcilib_get_board_info(pcilib_t *ctx);
78
 
const pcilib_dma_info_t *pcilib_get_dma_info(pcilib_t *ctx);
79
72
 
80
73
int pcilib_map_register_space(pcilib_t *ctx);
81
74
int pcilib_map_data_space(pcilib_t *ctx, uintptr_t addr);
82
75
int pcilib_detect_address(pcilib_t *ctx, pcilib_bar_t *bar, uintptr_t *addr, size_t size);
83
76
 
84
 
 
85
77
#endif /* _PCITOOL_PCI_H */