event.h 3.4 KB

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