diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2023-05-25 22:41:04 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2023-05-25 22:41:04 +0200 |
commit | 6f4af841f6fdd099b97d071ae64c8be60f809456 (patch) | |
tree | d4f9a18b38e1ce3cfc0a5336215d5ce3afe830d2 /model.c | |
download | pcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.tar.gz pcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.tar.bz2 pcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.tar.xz pcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.zip |
A sample event engine for pcitool (not requiring any PCIe hardware). Initial (barely tested and intended only as an example) release
Diffstat (limited to 'model.c')
-rw-r--r-- | model.c | 78 |
1 files changed, 78 insertions, 0 deletions
@@ -0,0 +1,78 @@ +#define _PCIDEV_MODEL_C + +#include <stdio.h> +#include <strings.h> + +#include <pcilib.h> +#include <pcilib/model.h> + +#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]; +} |