/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 bank.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:
 
1
#ifndef _PCILIB_BANK_H
 
2
#define _PCILIB_BANK_H
 
3
 
 
4
#include <pcilib.h>
 
5
 
 
6
#define PCILIB_REGISTER_BANK_INVALID            ((pcilib_register_bank_t)-1)
 
7
#define PCILIB_REGISTER_BANK0                   0                                       /**< First BANK to be used in the event engine */
 
8
#define PCILIB_REGISTER_BANK1                   1
 
9
#define PCILIB_REGISTER_BANK2                   2
 
10
#define PCILIB_REGISTER_BANK3                   3
 
11
#define PCILIB_REGISTER_BANK_DMA                64                                      /**< First BANK address to be used by DMA engines */
 
12
#define PCILIB_REGISTER_BANK_DYNAMIC            128                                     /**< First BANK address to map dynamic XML configuration */
 
13
#define PCILIB_REGISTER_PROTOCOL_INVALID        ((pcilib_register_protocol_t)-1)
 
14
#define PCILIB_REGISTER_PROTOCOL0               0                                       /**< First PROTOCOL address to be used in the event engine */
 
15
#define PCILIB_REGISTER_PROTOCOL_DEFAULT        64                                      /**< Default memmap based protocol */
 
16
#define PCILIB_REGISTER_PROTOCOL_DMA            96                                      /**< First PROTOCOL address to be used by DMA engines */
 
17
#define PCILIB_REGISTER_PROTOCOL_DYNAMIC        128                                     /**< First PROTOCOL address to be used by plugins */
 
18
 
 
19
#define PCILIB_REGISTER_NO_BITS                 0
 
20
#define PCILIB_REGISTER_ALL_BITS                ((pcilib_register_value_t)-1)
 
21
 
 
22
typedef uint8_t pcilib_register_bank_t;                                         /**< Type holding the bank position within the field listing register banks in the model */
 
23
typedef uint8_t pcilib_register_bank_addr_t;                                    /**< Type holding the bank address number */
 
24
typedef uint8_t pcilib_register_protocol_t;                                     /**< Type holding the protocol position within the field listing register protocols in the model */
 
25
typedef uint8_t pcilib_register_protocol_addr_t;                                /**< Type holding the protocol address */
 
26
 
 
27
 
 
28
typedef struct pcilib_register_bank_context_s pcilib_register_bank_context_t;
 
29
 
 
30
typedef struct {
 
31
    pcilib_register_bank_context_t *(*init)(pcilib_t *ctx, pcilib_register_bank_t bank, const char *model, const void *args);
 
32
    void (*free)(pcilib_register_bank_context_t *ctx);
 
33
    int (*read)(pcilib_t *pcilib, pcilib_register_bank_context_t *ctx, pcilib_register_addr_t addr, pcilib_register_value_t *value);
 
34
    int (*write)(pcilib_t *pcilib, pcilib_register_bank_context_t *ctx, pcilib_register_addr_t addr, pcilib_register_value_t value);
 
35
} pcilib_register_protocol_api_description_t;
 
36
 
 
37
typedef struct {
 
38
    pcilib_register_protocol_addr_t addr;
 
39
    const pcilib_register_protocol_api_description_t *api;
 
40
    const char *model;
 
41
    const void *args;
 
42
    const char *name;
 
43
    const char *description;
 
44
} pcilib_register_protocol_description_t;
 
45
 
 
46
typedef struct {
 
47
    pcilib_register_bank_addr_t addr;
 
48
 
 
49
    pcilib_bar_t bar;                           // optional
 
50
    size_t size;
 
51
    
 
52
    pcilib_register_protocol_addr_t protocol;
 
53
 
 
54
    uintptr_t read_addr;                        // or offset if bar specified
 
55
    uintptr_t write_addr;                       // or offset if bar specified
 
56
    pcilib_endianess_t raw_endianess;
 
57
 
 
58
    uint8_t access;
 
59
    pcilib_endianess_t endianess;
 
60
    
 
61
    const char *format;
 
62
    const char *name;
 
63
    const char *description;
 
64
} pcilib_register_bank_description_t;
 
65
 
 
66
/**
 
67
  * Default mappings
 
68
  */
 
69
typedef struct {
 
70
    uintptr_t start;
 
71
    uintptr_t end;
 
72
    pcilib_register_bank_addr_t bank;
 
73
    long addr_shift;
 
74
} pcilib_register_range_t;
 
75
 
 
76
 
 
77
 
 
78
struct pcilib_register_bank_context_s {
 
79
    const pcilib_register_bank_description_t *bank;
 
80
    const pcilib_register_protocol_api_description_t *api;
 
81
};
 
82
 
 
83
 
 
84
    // we don't copy strings, they should be statically allocated
 
85
int pcilib_init_register_banks(pcilib_t *ctx);
 
86
void pcilib_free_register_banks(pcilib_t *ctx);
 
87
int pcilib_add_register_banks(pcilib_t *ctx, size_t n, const pcilib_register_bank_description_t *banks);
 
88
 
 
89
pcilib_register_bank_t pcilib_find_register_bank_by_addr(pcilib_t *ctx, pcilib_register_bank_addr_t bank);
 
90
pcilib_register_bank_t pcilib_find_register_bank_by_name(pcilib_t *ctx, const char *bankname);
 
91
pcilib_register_bank_t pcilib_find_register_bank(pcilib_t *ctx, const char *bank);
 
92
 
 
93
pcilib_register_protocol_t pcilib_find_register_protocol_by_addr(pcilib_t *ctx, pcilib_register_protocol_addr_t protocol);
 
94
pcilib_register_protocol_t pcilib_find_register_protocol_by_name(pcilib_t *ctx, const char *name);
 
95
pcilib_register_protocol_t pcilib_find_register_protocol(pcilib_t *ctx, const char *name);
 
96
 
 
97
#endif /* _PCILIB_BANK_H */