From 6f4af841f6fdd099b97d071ae64c8be60f809456 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 25 May 2023 22:41:04 +0200 Subject: A sample event engine for pcitool (not requiring any PCIe hardware). Initial (barely tested and intended only as an example) release --- model.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 model.c (limited to 'model.c') diff --git a/model.c b/model.c new file mode 100644 index 0000000..28391a2 --- /dev/null +++ b/model.c @@ -0,0 +1,78 @@ +#define _PCIDEV_MODEL_C + +#include +#include + +#include +#include + +#include "version.h" + +#include "registers.h" +#include "dma.h" +#include "events.h" +#include "model.h" + + + + +static const pcilib_event_description_t pcidev_events[] = { + {PCILIB_EVENT0, "new_event", ""}, + {0, NULL, NULL} +}; + +static const pcilib_event_data_type_description_t pcidev_data_types[] = { + {PCIDEV_RAW_DATA, PCILIB_EVENT0, "raw", "raw data from device" }, + {PCIDEV_STANDARD_DATA, PCILIB_EVENT0, "std", "processed data" }, + {0, 0, NULL, NULL} +}; + + +pcilib_event_api_description_t pcidev_event_api = { + PCIDEV_VERSION, + + pcidev_init, + pcidev_free, + + pcidev_init_dma, + + pcidev_reset, + pcidev_start, + pcidev_stop, + pcidev_trigger, + + pcidev_stream, + NULL, + pcidev_get_data, + pcidev_return_data +}; + + +static const pcilib_model_description_t pcidev_models[] = {{ + PCILIB_EVENT_INTERFACE_VERSION, + &pcidev_event_api, + &pcidev_dma, + NULL, // Registers are defined in XML + NULL, // Banks are defined in XML + &pcidev_protocols, + NULL, // Register ranges are defined in XML + NULL, + NULL, + pcidev_events, + pcidev_data_types, + "pcidev", + "Sample Plugin" +}, { 0 }}; + + +const pcilib_model_description_t *pcilib_get_event_model(pcilib_t *pcilib, unsigned short vendor_id, unsigned short device_id, const char *model) { + // Enumeration call + if ((!vendor_id)&&(!device_id)&&(!model)) { + return pcidev_models; + } + + if ((model)&&(strcasecmp(model, "pcidev"))) + return NULL; + + return &pcidev_models[0]; +} -- cgit v1.2.3