16
16
} pcilib_view_flags_t;
19
pcilib_version_t version;
20
size_t description_size;
21
pcilib_view_context_t *(*init)(pcilib_t *ctx);
22
void (*free)(pcilib_t *ctx, pcilib_view_context_t *view);
23
void (*free_description)(pcilib_t *ctx, pcilib_view_description_t *view);
24
int (*read_from_reg)(pcilib_t *ctx, pcilib_view_context_t *view, pcilib_register_value_t regval, pcilib_value_t *val);
25
int (*write_to_reg)(pcilib_t *ctx, pcilib_view_context_t *view, pcilib_register_value_t *regval, const pcilib_value_t *val);
19
pcilib_version_t version; /**< Version */
20
size_t description_size; /**< The actual size of the description */
21
pcilib_view_context_t *(*init)(pcilib_t *ctx); /**< Optional function which should allocated context used by read/write functions */
22
void (*free)(pcilib_t *ctx, pcilib_view_context_t *view); /**< Optional function which should clean context */
23
void (*free_description)(pcilib_t *ctx, pcilib_view_description_t *view); /**< Optional function which shoud clean required parts of the extended description if non-static memory was used to initialize it */
24
int (*read_from_reg)(pcilib_t *ctx, pcilib_view_context_t *view, pcilib_register_value_t regval, pcilib_value_t *val); /**< Function which computes view value based on the passed the register value (view-based properties should not use register value) */
25
int (*write_to_reg)(pcilib_t *ctx, pcilib_view_context_t *view, pcilib_register_value_t *regval, const pcilib_value_t *val); /**< Function which computes register value based on the passed value (view-based properties are not required to set the register value) */
26
26
} pcilib_view_api_description_t;
28
28
struct pcilib_view_description_s {
29
29
const pcilib_view_api_description_t *api;
30
30
pcilib_value_type_t type; /**< The default data type returned by operation, PCILIB_VIEW_TYPE_STRING is supported by all operations */
31
pcilib_view_flags_t flags; /**< Flags specifying type of the view */
31
pcilib_access_mode_t mode; /**< Specifies if the view is read/write-only */
32
32
const char *unit; /**< Returned unit (if any) */
33
33
const char *name; /**< Name of the view */
34
34
const char *description; /**< Short description */
49
* Use this function to add new view definitions into the model. It is error to re-register
50
* already registered view. The function will copy the context of unit description, but name,
51
* transform, and other strings in the structure are considered to have static duration
52
* and will not be copied. On error no new views are initalized.
53
* @param[in,out] ctx - pcilib context
54
* @param[in] n - number of views to initialize. It is OK to pass 0 if protocols variable is NULL terminated (last member of protocols array have all members set to 0)
55
* @param[in] desc - view descriptions
56
* @return - error or 0 on success
47
58
int pcilib_add_views(pcilib_t *ctx, size_t n, const pcilib_view_description_t *desc);
48
void pcilib_clean_views(pcilib_t *ctx);
61
* Destroys data associated with views. This is an internal function and will
62
* be called during clean-up.
63
* @param[in,out] ctx - pcilib context
64
* @param[in] start - specifies first view to clean (used to clean only part of the views to keep the defined state if pcilib_add_views has failed)
66
void pcilib_clean_views(pcilib_t *ctx, pcilib_view_t start);
50
68
pcilib_view_context_t *pcilib_find_view_context_by_name(pcilib_t *ctx, const char *view);
51
69
pcilib_view_context_t *pcilib_find_register_view_context_by_name(pcilib_t *ctx, pcilib_register_t reg, const char *name);