/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 pcilib/dma.h

  • Committer: Suren A. Chilingaryan
  • Date: 2015-04-24 03:35:48 UTC
  • Revision ID: csa@suren.me-20150424033548-7xhacqq2s8s1t2fp
More structural changes to get ready for stand-alone event engines

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
#define PCILIB_DMA_BUFFER_INVALID ((size_t)-1)
5
5
 
 
6
typedef struct {
 
7
    int used;                                   /**< Indicates if buffer has unread data or empty and ready for DMA */
 
8
    int error;                                  /**< Indicates if data is complete and correctly transfered or some error occured during the DMA transfer */
 
9
    int first;                                  /**< Indicates the first buffer of the packet */
 
10
    int last;                                   /**< Indicates the last buffer of the packet */
 
11
    size_t size;                                /**< Indicates number of bytes actually written to the buffer */
 
12
} pcilib_dma_buffer_status_t;
6
13
 
7
14
typedef struct {
8
 
    int started;
9
 
    size_t ring_size, buffer_size;
10
 
    size_t ring_head, ring_tail;
 
15
    int started;                                /**< Informs if the engine is currently started or not */
 
16
    size_t ring_size, buffer_size;              /**< The number of allocated DMA buffers and size of each buffer in bytes */
 
17
    size_t ring_head, ring_tail;                /**< The first and the last buffer containing the data */
11
18
} pcilib_dma_engine_status_t;
12
19
 
13
20
typedef enum {
14
 
    PCILIB_DMA_TYPE_BLOCK,
15
 
    PCILIB_DMA_TYPE_PACKET,
 
21
    PCILIB_DMA_TYPE_BLOCK,                      /**< Simple DMA engine */
 
22
    PCILIB_DMA_TYPE_PACKET,                     /**< Streaming (scatter-gather) DMA engine */
16
23
    PCILIB_DMA_TYPE_UNKNOWN
17
24
} pcilib_dma_engine_type_t;
18
25
 
19
26
typedef struct {
20
 
    pcilib_dma_engine_addr_t addr;
21
 
    pcilib_dma_engine_type_t type;
22
 
    pcilib_dma_direction_t direction;
23
 
    size_t addr_bits;
 
27
    pcilib_dma_engine_addr_t addr;              /**< Address of DMA engine (from 0) */
 
28
    pcilib_dma_engine_type_t type;              /**< Type of DMA engine */
 
29
    pcilib_dma_direction_t direction;           /**< Defines which kind of transfer does engine support: C2S, S2C, or both */
 
30
    size_t addr_bits;                           /**< Number of addressable bits in the system memory (we currently work with 32-bits only) */
24
31
 
25
 
    const char *name;
26
 
    const char *description;
 
32
    const char *name;                           /**< Defines a short name of engine (its main use, i.e. main, auxilliary, etc.) */
 
33
    const char *description;                    /**< Defines a longer description of the engine */
27
34
} pcilib_dma_engine_description_t;
28
35
 
29
 
typedef struct {
30
 
    int used;
31
 
    int error;
32
 
    int first;
33
 
    int last;
34
 
    size_t size;
35
 
} pcilib_dma_buffer_status_t;
36
 
 
37
36
/*
38
37
typedef struct {
39
38
    int ignore_eop;
42
41
 
43
42
typedef struct {
44
43
//    pcilib_dma_parameters_t params;
45
 
    pcilib_t *pcilib;
 
44
    pcilib_t *pcilib;                           /**< Reference to the pcilib context */
46
45
} pcilib_dma_context_t;
47
46
 
48
47
typedef struct {
66
65
 
67
66
 
68
67
typedef struct {
69
 
    const pcilib_dma_api_description_t *api;
70
 
    const pcilib_register_bank_description_t *banks;
71
 
    const pcilib_register_description_t *registers;
72
 
    const pcilib_dma_engine_description_t *engines;
73
 
    const char *model;
74
 
    const void *args;
75
 
    const char *name;
76
 
    const char *description;
 
68
    const pcilib_dma_api_description_t *api;                            /**< Defines all API functions for DMA operation */
 
69
    const pcilib_register_bank_description_t *banks;                    /**< Pre-defined register banks exposed by DMA interface, additional banks can be defined during DMA initialization */
 
70
    const pcilib_register_description_t *registers;                     /**< Pre-defined registers exposed by DMA interface, additional registers can be defined during DMA initialization */
 
71
    const pcilib_dma_engine_description_t *engines;                     /**< List of DMA engines exposed by DMA interface, alternatively engines can be added during DMA initialization */
 
72
    const char *model;                                                  /**< If NULL, the actually used event model is used instead */
 
73
    const void *args;                                                   /**< Custom DMA-specific arguments. The actual structure may depend on the specified model */
 
74
    const char *name;                                                   /**< Short name of DMA interface */
 
75
    const char *description;                                            /**< A bit longer description of DMA interface */
77
76
} pcilib_dma_description_t;
78
77
 
79
78
 
80
 
const pcilib_dma_description_t *pcilib_get_dma_info(pcilib_t *ctx);
 
79
const pcilib_dma_description_t *pcilib_get_dma_description(pcilib_t *ctx);
81
80
pcilib_dma_engine_t pcilib_add_dma_engine(pcilib_t *ctx, pcilib_dma_engine_description_t *desc);
82
81
int pcilib_get_dma_status(pcilib_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_engine_status_t *status, size_t n_buffers, pcilib_dma_buffer_status_t *buffers);
83
82
int pcilib_init_dma(pcilib_t *ctx);