register.h 2.5 KB

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