event.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef _PCILIB_EVENT_H
  2. #define _PCILIB_EVENT_H
  3. #include <pcilib.h>
  4. #include <pcilib/version.h>
  5. #include <pcilib/dma.h>
  6. #define PCILIB_EVENT_INTERFACE_VERSION PCILIB_VERSION
  7. typedef struct {
  8. size_t max_events;
  9. pcilib_timeout_t duration;
  10. } pcilib_autostop_parameters_t;
  11. typedef struct {
  12. pcilib_event_rawdata_callback_t callback;
  13. void *user;
  14. } pcilib_rawdata_parameters_t;
  15. typedef struct {
  16. size_t max_threads;
  17. } pcilib_parallel_parameters_t;
  18. typedef struct {
  19. pcilib_autostop_parameters_t autostop;
  20. pcilib_rawdata_parameters_t rawdata;
  21. pcilib_parallel_parameters_t parallel;
  22. } pcilib_event_parameters_t;
  23. struct pcilib_event_context_s {
  24. pcilib_event_parameters_t params;
  25. pcilib_t *pcilib;
  26. };
  27. typedef struct {
  28. pcilib_event_t evid;
  29. const char *name;
  30. const char *description;
  31. } pcilib_event_description_t;
  32. typedef struct {
  33. pcilib_event_data_type_t data_type;
  34. pcilib_event_t evid;
  35. const char *name;
  36. const char *description;
  37. } pcilib_event_data_type_description_t;
  38. typedef enum {
  39. PCILIB_STREAMING_STOP = 0, /**< stop streaming */
  40. PCILIB_STREAMING_CONTINUE = 1, /**< wait the default DMA timeout for a new data */
  41. PCILIB_STREAMING_WAIT = 2, /**< wait the specified timeout for a new data */
  42. PCILIB_STREAMING_CHECK = 3, /**< do not wait for the data, bail out imideatly if no data ready */
  43. PCILIB_STREAMING_FAIL = 4, /**< fail if data is not available on timeout */
  44. PCILIB_STREAMING_REQ_FRAGMENT = 5, /**< only fragment of a packet is read, wait for next fragment and fail if no data during DMA timeout */
  45. PCILIB_STREAMING_REQ_PACKET = 6, /**< wait for next packet and fail if no data during the specified timeout */
  46. PCILIB_STREAMING_TIMEOUT_MASK = 3 /**< mask specifying all timeout modes */
  47. } pcilib_streaming_action_t;
  48. /*
  49. * get_data: This call is used by get_data and copy_data functions of public
  50. * interface. When copy_data is the caller, the data parameter will be passed.
  51. * Therefore, depending on data the parameter, the function should behave
  52. * diferently. If get get_data function is used (buf == NULL), the caller is
  53. * expected to call return_data afterwards. Otherwise, if buf != NULL and
  54. * copy_data is used, the return call will not be executed.
  55. * Still, the get_data function is not obliged to return the data in the
  56. * passed buf, but a reference to the staticaly allocated memory may be
  57. * returned instead. The copy can be managed by the envelope function.
  58. */
  59. typedef struct {
  60. pcilib_version_t version;
  61. pcilib_context_t *(*init)(pcilib_t *ctx);
  62. void (*free)(pcilib_context_t *ctx);
  63. pcilib_dma_context_t *(*init_dma)(pcilib_context_t *ctx);
  64. int (*reset)(pcilib_context_t *ctx);
  65. int (*start)(pcilib_context_t *ctx, pcilib_event_t event_mask, pcilib_event_flags_t flags);
  66. int (*stop)(pcilib_context_t *ctx, pcilib_event_flags_t flags);
  67. int (*trigger)(pcilib_context_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data);
  68. int (*stream)(pcilib_context_t *ctx, pcilib_event_callback_t callback, void *user);
  69. int (*next_event)(pcilib_context_t *ctx, pcilib_timeout_t timeout, pcilib_event_id_t *evid, size_t info_size, pcilib_event_info_t *info);
  70. int (*get_data)(pcilib_context_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t *size, void **data);
  71. int (*return_data)(pcilib_context_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, void *data);
  72. } pcilib_event_api_description_t;
  73. int pcilib_init_event_engine(pcilib_t *ctx);
  74. #endif /* _PCILIB_EVENT_H */