event.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. /*
  39. * get_data: This call is used by get_data and copy_data functions of public
  40. * interface. When copy_data is the caller, the data parameter will be passed.
  41. * Therefore, depending on data the parameter, the function should behave
  42. * diferently. If get get_data function is used (buf == NULL), the caller is
  43. * expected to call return_data afterwards. Otherwise, if buf != NULL and
  44. * copy_data is used, the return call will not be executed.
  45. * Still, the get_data function is not obliged to return the data in the
  46. * passed buf, but a reference to the staticaly allocated memory may be
  47. * returned instead. The copy can be managed by the envelope function.
  48. */
  49. typedef struct {
  50. pcilib_version_t version;
  51. pcilib_context_t *(*init)(pcilib_t *ctx);
  52. void (*free)(pcilib_context_t *ctx);
  53. pcilib_dma_context_t *(*init_dma)(pcilib_context_t *ctx);
  54. int (*reset)(pcilib_context_t *ctx);
  55. int (*start)(pcilib_context_t *ctx, pcilib_event_t event_mask, pcilib_event_flags_t flags);
  56. int (*stop)(pcilib_context_t *ctx, pcilib_event_flags_t flags);
  57. int (*trigger)(pcilib_context_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data);
  58. int (*stream)(pcilib_context_t *ctx, pcilib_event_callback_t callback, void *user);
  59. 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);
  60. 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);
  61. int (*return_data)(pcilib_context_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, void *data);
  62. } pcilib_event_api_description_t;
  63. #ifdef __cplusplus
  64. extern "C" {
  65. #endif
  66. int pcilib_init_event_engine(pcilib_t *ctx);
  67. /*
  68. * Configures maximal number of preprocessing threads. Actual amount of threads
  69. * may be bigger. For instance, additionaly a real-time reader thread will be
  70. * executed for most of hardware
  71. */
  72. int pcilib_configure_preprocessing_threads(pcilib_t *ctx, size_t max_threads);
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #endif /* _PCILIB_EVENT_H */