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 */
19
#define PCILIB_REGISTER_NO_BITS 0
20
#define PCILIB_REGISTER_ALL_BITS ((pcilib_register_value_t)-1)
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 */
28
typedef struct pcilib_register_bank_context_s pcilib_register_bank_context_t;
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;
38
pcilib_register_protocol_addr_t addr;
39
const pcilib_register_protocol_api_description_t *api;
43
const char *description;
44
} pcilib_register_protocol_description_t;
47
pcilib_register_bank_addr_t addr;
49
pcilib_bar_t bar; // optional
52
pcilib_register_protocol_addr_t protocol;
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;
59
pcilib_endianess_t endianess;
63
const char *description;
64
} pcilib_register_bank_description_t;
72
pcilib_register_bank_addr_t bank;
74
} pcilib_register_range_t;
78
struct pcilib_register_bank_context_s {
79
const pcilib_register_bank_description_t *bank;
80
const pcilib_register_protocol_api_description_t *api;
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);
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);
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);
97
#endif /* _PCILIB_BANK_H */