register.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef _PCILIB_REGISTER_H
  2. #define _PCILIB_REGISTER_H
  3. #include <pcilib.h>
  4. #include <pcilib/bank.h>
  5. #define PCILIB_REGISTER_NO_BITS 0
  6. #define PCILIB_REGISTER_ALL_BITS ((pcilib_register_value_t)-1)
  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. typedef enum {
  17. PCILIB_REGISTER_STANDARD = 0,
  18. PCILIB_REGISTER_FIFO,
  19. PCILIB_REGISTER_BITS
  20. } pcilib_register_type_t;
  21. typedef struct {
  22. const char *name;
  23. const char *view;
  24. } pcilib_view_reference_t;
  25. typedef struct {
  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 */
  39. const char *name; /**< The access name of the register */
  40. const char *description; /**< Brief description of the register */
  41. pcilib_view_reference_t *views; /**< List of supported views for this register */
  42. } pcilib_register_description_t;
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. 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);
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50. #endif /* _PCILIB_REGISTER_H */