28
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);
31
pcilib_register_bank_context_t *(*init)(pcilib_t *ctx, pcilib_register_bank_t bank, const char *model, const void *args); /**< Optional API call to initialize bank context */
32
void (*free)(pcilib_register_bank_context_t *ctx); /**< Optional API call to cleanup bank context */
33
int (*read)(pcilib_t *pcilib, pcilib_register_bank_context_t *ctx, pcilib_register_addr_t addr, pcilib_register_value_t *value); /**< Read from register, mandatory for RO/RW registers */
34
int (*write)(pcilib_t *pcilib, pcilib_register_bank_context_t *ctx, pcilib_register_addr_t addr, pcilib_register_value_t value); /**< Write to register, mandatory for WO/RW registers */
35
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;
38
pcilib_register_protocol_addr_t addr; /**< Protocol address used in model for addressing the described protocol */
39
const pcilib_register_protocol_api_description_t *api; /**< Defines all API functions for protocol */
40
const char *model; /**< If NULL, the actually used model is used instead */
41
const void *args; /**< Custom protocol-specific arguments. The actual structure may depend on the specified model */
42
const char *name; /**< Short protocol name */
43
const char *description; /**< A bit longer protocol description */
44
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;
47
pcilib_register_bank_addr_t addr; /**< Bank address used in model for addressing the described register bank */
49
pcilib_register_protocol_addr_t protocol; /**< Defines a protocol to access registers */
50
pcilib_bar_t bar; /**< Specifies the PCI BAR through which an access to the registers is provided (autodetcted if PCILIB_BAR_DETECT is specified) */
51
uintptr_t read_addr; /**< protocol specific (normally offset in the BAR of the first address used to read registers) */
52
uintptr_t write_addr; /**< protocol specific (normally offset in the BAR of the first address used to write registers) */
54
uint8_t access; /**< Default register size in bits (or word-size in plain addressing mode) */
55
size_t size; /**< Number of register addresses (plain addressing) in the bank (more register names can be defined if bit-fields/views are used) */
56
pcilib_endianess_t raw_endianess; /**< Specifies endianess in the plain-addressing mode, PCILIB_HOST_ENDIAN have to be specified if no conversion desired.
57
Conversion applied after protocol. This value does not get into the account in register-access mode */
58
pcilib_endianess_t endianess; /**< Specifies endianess in the register-access mode, this may differ from raw_endianess if multi-word registers are used.
59
This is fully independent from raw_endianess. No double conversion is either performed */
61
const char *format; /**< printf format for the registers, either %lu for decimal output or 0x%lx for hexdecimal */
62
const char *name; /**< short bank name */
63
const char *description; /**< longer bank description */
64
64
} pcilib_register_bank_description_t;
67
* Default mappings: defines virtual address to register mappings, i.e. how 0x9000 in the following command
68
* will be mapped to the actual register. By comparing with start and end-addresses, we find to which range
69
* 0x9000 belongs to and detect actual bank and offset in it.
70
* Simple example: pci -r 0x9000
71
* if we specify range { 0x9000, 0x9100, 10, -0x9000}, the example command we print the value of the first
72
* register in the bank 10.
72
pcilib_register_bank_addr_t bank;
75
uintptr_t start; /**< The first virtual address of the register range */
76
uintptr_t end; /**< The last virtual address of the register range */
77
pcilib_register_bank_addr_t bank; /**< The bank mapped to the specified range */
78
long addr_shift; /**< Address shift, i.e. how much we should add/substract to the virtual address to get address in the register bank */
74
79
} pcilib_register_range_t;
78
83
struct pcilib_register_bank_context_s {
79
const pcilib_register_bank_description_t *bank;
80
const pcilib_register_protocol_api_description_t *api;
84
const pcilib_register_bank_description_t *bank; /**< Corresponding bank description */
85
const pcilib_register_protocol_api_description_t *api; /**< API functions */