/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 pcilib/register.h

  • Committer: Suren A. Chilingaryan
  • Date: 2015-10-18 01:47:47 UTC
  • Revision ID: csa@suren.me-20151018014747-9ji2ygdhz1l9wnt5
Support properties of arbitrary type

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef _PCILIB_REGISTER_H
2
2
#define _PCILIB_REGISTER_H
3
3
 
 
4
#include <uthash.h>
 
5
 
4
6
#include <pcilib.h>
5
7
#include <pcilib/bank.h>
6
8
 
49
51
    pcilib_view_reference_t *views;             /**< List of supported views for this register */
50
52
} pcilib_register_description_t;
51
53
 
 
54
typedef struct {
 
55
    const char *name;                                                                   /**< Register name */
 
56
    pcilib_register_t reg;                                                              /**< Register index */
 
57
    pcilib_register_bank_t bank;                                                        /**< Reference to bank containing the register */
 
58
    pcilib_register_value_t min, max;                                                   /**< Minimum & maximum allowed values */
 
59
    pcilib_xml_node_t *xml;                                                             /**< Additional XML properties */
 
60
    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) */
 
61
    UT_hash_handle hh;
 
62
} pcilib_register_context_t;
52
63
 
53
64
#ifdef __cplusplus
54
65
extern "C" {
55
66
#endif
56
67
 
 
68
/**
 
69
 * Use this function to add new registers into the model. Currently, it is considered a error
 
70
 * to re-add already defined register. If it will turn out to be useful to redefine some registers 
 
71
 * from the model, it may change in the future. However, we should think how to treat bit-registers
 
72
 * in this case. The function will copy the context of registers structure, but name, 
 
73
 * description, and other strings in the structure are considered to have static duration 
 
74
 * and will not be copied. On error no new registers are initalized.
 
75
 * @param[in,out] ctx - pcilib context
 
76
 * @param[in] flags - not used now, but in future may instruct if existing registers should be reported as error (default), overriden or ignored
 
77
 * @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)
 
78
 * @param[in] registers - register descriptions
 
79
 * @param[out] ids - if specified will contain the ids of the newly registered and overriden registers
 
80
 * @return - error or 0 on success
 
81
 */
57
82
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);
58
 
void pcilib_clean_registers(pcilib_t *ctx);
 
83
 
 
84
/**
 
85
 * Destroys data associated with registers. This is an internal function and will
 
86
 * be called during clean-up.
 
87
 * @param[in,out] ctx - pcilib context
 
88
 * @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)
 
89
 */
 
90
void pcilib_clean_registers(pcilib_t *ctx, pcilib_register_t start);
59
91
 
60
92
#ifdef __cplusplus
61
93
}