software.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * @file software.h
  3. * @brief header file for implementation of the protocol with software registers allocated in the kernel space, for parameters sharing between concurrent pcitool instances
  4. */
  5. #ifndef _PCILIB_PROTOCOL_SOFTWARE_H
  6. #define _PCILIB_PROTOCOL_SOFTWARE_H
  7. #include "pcilib.h"
  8. #include "version.h"
  9. #include "model.h"
  10. /**
  11. * this function initialize the kernel space memory for the use of software register. it initializes the kernel space memory and stores in it the default values of the registers of the given bank index, if it was not initialized by a concurrent process, and return a bank context containing the adress of this kernel space. If the kernel space memory was already initialized by a concurrent process, then this function just return the bank context with the adress of this kernel space already used
  12. * @param[in] - ctx the pcilib_t structure running
  13. * @param[in] - bank the bank index that will permits to get the bank we want registers from
  14. * @param[in] - model not used
  15. * @param[in] - args not used
  16. * @return a bank context with the adress of the kernel space memory related to it, as we could have for BAR
  17. */
  18. pcilib_register_bank_context_t* pcilib_software_registers_open(pcilib_t *ctx, pcilib_register_bank_t bank, const char* model, const void *args);
  19. /**
  20. * this function clear the kernel memory space that could have been allocated for software registers and the bank context that correspond to it too
  21. * @param[in] ctx - the pcilib_t structure runnning
  22. * @param[in] bank_ctx - the bank context running that we get from the initialisation function
  23. */
  24. void pcilib_software_registers_close(pcilib_t *ctx, pcilib_register_bank_context_t *bank_ctx);
  25. /**
  26. * this function resolve the virtual address of the register for direct access
  27. * @param[in] - ctx the pcilib_t structure runnning
  28. * @param[in] - bank_ctx the bank context that was returned by the initialisation function
  29. * @param[in] - flags
  30. * @param[in] - addr the adress of the register we want to read
  31. * @return virtual address or PCILIB_ADDRESS_INVALID on error
  32. */
  33. uintptr_t pcilib_software_registers_resolve(pcilib_t *ctx, pcilib_register_bank_context_t *bank_ctx, pcilib_address_resolution_flags_t flags, pcilib_register_addr_t addr);
  34. /**
  35. * this function read the value of a said register in the kernel space.
  36. * @param[in] - ctx the pcilib_t structure runnning
  37. * @param[in] - bank_ctx the bank context that was returned by the initialisation function
  38. * @param[in] - addr the adress of the register we want to read
  39. * @param[out] - value the value of the register
  40. * @return error code : 0 in case of success
  41. */
  42. int pcilib_software_registers_read(pcilib_t *ctx, pcilib_register_bank_context_t* bank_ctx, pcilib_register_addr_t addr, pcilib_register_value_t *value);
  43. /**
  44. * this function write the given value to a given register in the kernel space
  45. * @param[in] ctx - the pcilib_t structure runnning
  46. * @param[in] bank_ctx - the bank context that was returned by the initialisation function
  47. * @param[in] addr - the adress of the register we want to write in
  48. * @param[in] value - the value we want to write in the register
  49. * @return error code : 0 in case of success
  50. */
  51. int pcilib_software_registers_write(pcilib_t *ctx,pcilib_register_bank_context_t* bank_ctx, pcilib_register_addr_t addr, pcilib_register_value_t value);
  52. #ifdef _PCILIB_EXPORT_C
  53. /**
  54. * software protocol addition to the protocol api.
  55. */
  56. const pcilib_register_protocol_api_description_t pcilib_software_protocol_api =
  57. { PCILIB_VERSION, pcilib_software_registers_open, pcilib_software_registers_close, pcilib_software_registers_resolve, pcilib_software_registers_read, pcilib_software_registers_write };
  58. #endif /* _PCILIB_EXPORT_C */
  59. #endif /* _PCILIB_PROTOCOL_SOFTWARE_H */