bzr branch
http://suren.me/webbzr/alps/pcitool
47
by Suren A. Chilingaryan
Support FIFO reading/writting, code restructurization, few fixes |
1 |
#ifndef _PCILIB_REGISTER_H
|
2 |
#define _PCILIB_REGISTER_H
|
|
3 |
||
315
by Suren A. Chilingaryan
Support properties of arbitrary type |
4 |
#include <uthash.h> |
5 |
||
236
by Suren A. Chilingaryan
Big redign of model structures |
6 |
#include <pcilib.h> |
240
by Suren A. Chilingaryan
More structural changes to get ready for stand-alone event engines |
7 |
#include <pcilib/bank.h> |
236
by Suren A. Chilingaryan
Big redign of model structures |
8 |
|
242
by Suren A. Chilingaryan
Initial support for event engines |
9 |
#define PCILIB_REGISTER_NO_BITS 0
|
10 |
#define PCILIB_REGISTER_ALL_BITS ((pcilib_register_value_t)-1)
|
|
11 |
||
236
by Suren A. Chilingaryan
Big redign of model structures |
12 |
|
13 |
typedef enum { |
|
321
by Suren A. Chilingaryan
Support computed (property-based) registers |
14 |
PCILIB_REGISTER_STANDARD = 0, /**< Standard register */ |
15 |
PCILIB_REGISTER_FIFO, /**< FIFO register */ |
|
16 |
PCILIB_REGISTER_BITS, /**< Besides a big standard register, the register bit-fields may be described by bit registers */ |
|
17 |
PCILIB_REGISTER_PROPERTY /**< A special register bound to a property and gettings/setting it value through it */ |
|
236
by Suren A. Chilingaryan
Big redign of model structures |
18 |
} pcilib_register_type_t; |
19 |
||
20 |
typedef struct { |
|
307
by Suren A. Chilingaryan
Finalyze XML support and provide initial support for views (only descriptions so far) |
21 |
const char *name; |
22 |
const char *view; |
|
23 |
} pcilib_view_reference_t; |
|
24 |
||
25 |
typedef struct { |
|
236
by Suren A. Chilingaryan
Big redign of model structures |
26 |
pcilib_register_addr_t addr; /**< Register address in the bank */ |
27 |
pcilib_register_size_t offset; /**< Register offset in the byte (in bits) */ |
|
28 |
pcilib_register_size_t bits; /**< Register size in bits */ |
|
29 |
pcilib_register_value_t defvalue; /**< Default register value (some protocols, i.e. software registers, may set it during the initialization) */ |
|
30 |
pcilib_register_value_t rwmask; /**< Used to define how external bits of PCILIB_REGISTER_BITS registers are treated. |
|
31 |
To keep bit value unchanged, we need to observe the following behavior depending on status of corresponding bit in this field:
|
|
32 |
1 - standard bit (i.e. if we want to keep the bit value we need to read it, and, the write back),
|
|
33 |
0 - non-standard bit which behavior is defined by mode (only partially implemented.
|
|
34 |
so far only 1C/1I modes (zero should be written to preserve the value) are supported */
|
|
35 |
pcilib_register_mode_t mode; /**< Register access (ro/wo/rw) and how writting to register works (if value just set as specified or, for instance, the bits which |
|
36 |
are on in the value are cleared/inverted). For information only, no preprocessing on bits is performed. */
|
|
37 |
pcilib_register_type_t type; /**< Defines type of register is it standard register, subregister for bit fields or view, fifo */ |
|
38 |
pcilib_register_bank_addr_t bank; /**< Specified the address of the bank this register belongs to */ |
|
307
by Suren A. Chilingaryan
Finalyze XML support and provide initial support for views (only descriptions so far) |
39 |
|
236
by Suren A. Chilingaryan
Big redign of model structures |
40 |
const char *name; /**< The access name of the register */ |
41 |
const char *description; /**< Brief description of the register */ |
|
307
by Suren A. Chilingaryan
Finalyze XML support and provide initial support for views (only descriptions so far) |
42 |
|
43 |
pcilib_view_reference_t *views; /**< List of supported views for this register */ |
|
236
by Suren A. Chilingaryan
Big redign of model structures |
44 |
} pcilib_register_description_t; |
45 |
||
315
by Suren A. Chilingaryan
Support properties of arbitrary type |
46 |
typedef struct { |
47 |
const char *name; /**< Register name */ |
|
48 |
pcilib_register_t reg; /**< Register index */ |
|
49 |
pcilib_register_bank_t bank; /**< Reference to bank containing the register */ |
|
319
by Suren A. Chilingaryan
Provide register listings in public API |
50 |
pcilib_register_value_range_t range; /**< Minimum & maximum allowed values */ |
315
by Suren A. Chilingaryan
Support properties of arbitrary type |
51 |
pcilib_xml_node_t *xml; /**< Additional XML properties */ |
52 |
pcilib_view_reference_t *views; /**< For non-static list of views, this vairables holds a copy of a NULL-terminated list from model (if present, memory should be de-allocated) */ |
|
53 |
UT_hash_handle hh; |
|
54 |
} pcilib_register_context_t; |
|
249
by Suren A. Chilingaryan
Create dummy register context |
55 |
|
277
by Suren A. Chilingaryan
Keep C++ compilers happy |
56 |
#ifdef __cplusplus
|
57 |
extern "C" { |
|
58 |
#endif
|
|
59 |
||
315
by Suren A. Chilingaryan
Support properties of arbitrary type |
60 |
/**
|
61 |
* Use this function to add new registers into the model. Currently, it is considered a error
|
|
62 |
* to re-add already defined register. If it will turn out to be useful to redefine some registers
|
|
63 |
* from the model, it may change in the future. However, we should think how to treat bit-registers
|
|
64 |
* in this case. The function will copy the context of registers structure, but name,
|
|
65 |
* description, and other strings in the structure are considered to have static duration
|
|
66 |
* and will not be copied. On error no new registers are initalized.
|
|
67 |
* @param[in,out] ctx - pcilib context
|
|
68 |
* @param[in] flags - not used now, but in future may instruct if existing registers should be reported as error (default), overriden or ignored
|
|
69 |
* @param[in] n - number of registers to initialize. It is OK to pass 0 if registers array is NULL terminated (last member of the array have all members set to 0)
|
|
70 |
* @param[in] registers - register descriptions
|
|
71 |
* @param[out] ids - if specified will contain the ids of the newly registered and overriden registers
|
|
72 |
* @return - error or 0 on success
|
|
73 |
*/
|
|
303
by Suren A. Chilingaryan
Initial integration of XML support |
74 |
int pcilib_add_registers(pcilib_t *ctx, pcilib_model_modification_flags_t flags, size_t n, const pcilib_register_description_t *registers, pcilib_register_t *ids); |
315
by Suren A. Chilingaryan
Support properties of arbitrary type |
75 |
|
76 |
/**
|
|
77 |
* Destroys data associated with registers. This is an internal function and will
|
|
78 |
* be called during clean-up.
|
|
79 |
* @param[in,out] ctx - pcilib context
|
|
80 |
* @param[in] start - specifies first register to clean (used to clean only part of the registers to keep the defined state if pcilib_add_registers has failed)
|
|
81 |
*/
|
|
82 |
void pcilib_clean_registers(pcilib_t *ctx, pcilib_register_t start); |
|
236
by Suren A. Chilingaryan
Big redign of model structures |
83 |
|
277
by Suren A. Chilingaryan
Keep C++ compilers happy |
84 |
#ifdef __cplusplus
|
85 |
}
|
|
86 |
#endif
|
|
54
by Suren A. Chilingaryan
Support dynamic registers, support register offsets and multiregisters (bitmasks), list NWL DMA registers |
87 |
|
47
by Suren A. Chilingaryan
Support FIFO reading/writting, code restructurization, few fixes |
88 |
#endif /* _PCILIB_REGISTER_H */ |