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

  • Committer: Suren A. Chilingaryan
  • Date: 2015-04-20 20:01:04 UTC
  • Revision ID: csa@suren.me-20150420200104-b5xny65io8lvoz3w
Big redign of model structures

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 "pcilib.h"
5
 
 
6
 
struct pcilib_protocol_description_s {
7
 
    int (*read)(pcilib_t *ctx, pcilib_register_bank_description_t *bank, pcilib_register_addr_t addr, pcilib_register_value_t *value);
8
 
    int (*write)(pcilib_t *ctx, pcilib_register_bank_description_t *bank, pcilib_register_addr_t addr, pcilib_register_value_t value);
9
 
};
10
 
 
11
 
    // we don't copy strings, they should be statically allocated
12
 
int pcilib_add_registers(pcilib_t *ctx, size_t n, pcilib_register_description_t *registers);
 
4
#include <pcilib.h>
 
5
#include <bank.h>
 
6
 
 
7
typedef enum {
 
8
    PCILIB_REGISTER_R = 1,                      /**< reading from register is allowed */
 
9
    PCILIB_REGISTER_W = 2,                      /**< normal writting to register is allowed */
 
10
    PCILIB_REGISTER_RW = 3,
 
11
    PCILIB_REGISTER_W1C = 4,                    /**< writting 1 resets the bit, writting 0 keeps the value */
 
12
    PCILIB_REGISTER_RW1C = 5,
 
13
    PCILIB_REGISTER_W1I = 8,                    /**< writting 1 inversts the bit, writting 0 keeps the value */
 
14
    PCILIB_REGISTER_RW1I = 9,
 
15
} pcilib_register_mode_t;
 
16
 
 
17
typedef enum {
 
18
    PCILIB_REGISTER_STANDARD = 0,
 
19
    PCILIB_REGISTER_FIFO,
 
20
    PCILIB_REGISTER_BITS
 
21
} pcilib_register_type_t;
 
22
 
 
23
typedef struct {
 
24
    pcilib_register_addr_t addr;                /**< Register address in the bank */
 
25
    pcilib_register_size_t offset;              /**< Register offset in the byte (in bits) */
 
26
    pcilib_register_size_t bits;                /**< Register size in bits */
 
27
    pcilib_register_value_t defvalue;           /**< Default register value (some protocols, i.e. software registers, may set it during the initialization) */
 
28
    pcilib_register_value_t rwmask;             /**< Used to define how external bits of PCILIB_REGISTER_BITS registers are treated. 
 
29
                                                To keep bit value unchanged, we need to observe the following behavior depending on status of corresponding bit in this field:
 
30
                                                1 - standard bit (i.e. if we want to keep the bit value we need to read it, and, the write back), 
 
31
                                                0 - non-standard bit which behavior is defined by mode (only partially implemented. 
 
32
                                                    so far only 1C/1I modes (zero should be written to preserve the value) are supported */
 
33
    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
 
34
                                                are on in the value are cleared/inverted). For information only, no preprocessing on bits is performed. */
 
35
    pcilib_register_type_t type;                /**< Defines type of register is it standard register, subregister for bit fields or view, fifo */
 
36
    pcilib_register_bank_addr_t bank;           /**< Specified the address of the bank this register belongs to */
 
37
    
 
38
    const char *name;                           /**< The access name of the register */
 
39
    const char *description;                    /**< Brief description of the register */
 
40
} pcilib_register_description_t;
 
41
 
 
42
/*
 
43
typedef struct {
 
44
    pcilib_register_bank_t bank;
 
45
} pcilib_register_context_t;
 
46
*/
 
47
 
 
48
int pcilib_add_registers(pcilib_t *ctx, size_t n, const pcilib_register_description_t *registers);
 
49
 
13
50
 
14
51
#endif /* _PCILIB_REGISTER_H */