|
Packit |
6639f8 |
// Copyright(c) 2018-2019, Intel Corporation
|
|
Packit |
6639f8 |
//
|
|
Packit |
6639f8 |
// Redistribution and use in source and binary forms, with or without
|
|
Packit |
6639f8 |
// modification, are permitted provided that the following conditions are met:
|
|
Packit |
6639f8 |
//
|
|
Packit |
6639f8 |
// * Redistributions of source code must retain the above copyright notice,
|
|
Packit |
6639f8 |
// this list of conditions and the following disclaimer.
|
|
Packit |
6639f8 |
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
Packit |
6639f8 |
// this list of conditions and the following disclaimer in the documentation
|
|
Packit |
6639f8 |
// and/or other materials provided with the distribution.
|
|
Packit |
6639f8 |
// * Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
6639f8 |
// may be used to endorse or promote products derived from this software
|
|
Packit |
6639f8 |
// without specific prior written permission.
|
|
Packit |
6639f8 |
//
|
|
Packit |
6639f8 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
6639f8 |
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
6639f8 |
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
6639f8 |
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
Packit |
6639f8 |
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit |
6639f8 |
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit |
6639f8 |
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit |
6639f8 |
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit |
6639f8 |
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
6639f8 |
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
Packit |
6639f8 |
// POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#ifndef __FPGAD_MONITORED_DEVICE_H__
|
|
Packit |
6639f8 |
#define __FPGAD_MONITORED_DEVICE_H__
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#include "fpgad.h"
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
typedef struct _fpgad_supported_device {
|
|
Packit |
6639f8 |
uint16_t vendor_id;
|
|
Packit |
6639f8 |
uint16_t device_id;
|
|
Packit |
6639f8 |
const char *library_path;
|
|
Packit |
6639f8 |
uint32_t flags;
|
|
Packit |
6639f8 |
#define FPGAD_DEV_DETECTED 0x00000001
|
|
Packit |
6639f8 |
#define FPGAD_DEV_LOADED 0x00000002
|
|
Packit |
6639f8 |
void *dl_handle;
|
|
Packit |
6639f8 |
const char *config;
|
|
Packit |
6639f8 |
} fpgad_supported_device;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
typedef enum _fpgad_plugin_type {
|
|
Packit |
6639f8 |
FPGAD_PLUGIN_TYPE_CALLBACK = 1,
|
|
Packit |
6639f8 |
FPGAD_PLUGIN_TYPE_THREAD
|
|
Packit |
6639f8 |
} fpgad_plugin_type;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
struct _fpgad_monitored_device;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
typedef enum _fpgad_detection_status {
|
|
Packit |
6639f8 |
FPGAD_STATUS_NOT_DETECTED = 0, // no detection
|
|
Packit |
6639f8 |
FPGAD_STATUS_DETECTED, // detected (normal priority)
|
|
Packit |
6639f8 |
FPGAD_STATUS_DETECTED_HIGH // detected (high priority)
|
|
Packit |
6639f8 |
} fpgad_detection_status;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
typedef fpgad_detection_status
|
|
Packit |
6639f8 |
(*fpgad_detect_event_t)(struct _fpgad_monitored_device *dev,
|
|
Packit |
6639f8 |
void *context);
|
|
Packit |
6639f8 |
typedef void (*fpgad_respond_event_t)(struct _fpgad_monitored_device *dev,
|
|
Packit |
6639f8 |
void *context);
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
typedef void * (*fpgad_plugin_thread_t)(void *context);
|
|
Packit |
6639f8 |
typedef void (*fpgad_plugin_thread_stop_t)(void);
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
typedef struct _fpgad_monitored_device {
|
|
Packit |
6639f8 |
struct fpgad_config *config;
|
|
Packit |
6639f8 |
fpgad_supported_device *supported;
|
|
Packit |
6639f8 |
fpga_token token;
|
|
Packit |
6639f8 |
uint64_t object_id;
|
|
Packit |
6639f8 |
fpga_objtype object_type;
|
|
Packit |
6639f8 |
opae_bitstream_info *bitstr;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
fpgad_plugin_type type;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
// for type FPGAD_PLUGIN_TYPE_CALLBACK {
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
// must be NULL-terminated
|
|
Packit |
6639f8 |
fpgad_detect_event_t *detections;
|
|
Packit |
6639f8 |
void **detection_contexts;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
fpgad_respond_event_t *responses;
|
|
Packit |
6639f8 |
void **response_contexts;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
// }
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
// for type FPGAD_PLUGIN_TYPE_THREAD {
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
fpgad_plugin_thread_t thread_fn;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
// The parameter to thread_fn will be the address
|
|
Packit |
6639f8 |
// of this fpgad_monitored_device. Use the
|
|
Packit |
6639f8 |
// following member to pass a thread-specific
|
|
Packit |
6639f8 |
// context:
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
void *thread_context;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
// This routine is called to make the plugin
|
|
Packit |
6639f8 |
// thread stop execution in preparation for
|
|
Packit |
6639f8 |
// being joined.
|
|
Packit |
6639f8 |
fpgad_plugin_thread_stop_t thread_stop_fn;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
pthread_t thread;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
// }
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#define MAX_DEV_ERROR_OCCURRENCES 64
|
|
Packit |
6639f8 |
void *error_occurrences[MAX_DEV_ERROR_OCCURRENCES];
|
|
Packit |
6639f8 |
unsigned num_error_occurrences;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#define MAX_DEV_SCRATCHPAD 2
|
|
Packit |
6639f8 |
uint64_t scratchpad[MAX_DEV_SCRATCHPAD];
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
struct _fpgad_monitored_device *next;
|
|
Packit |
6639f8 |
} fpgad_monitored_device;
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#define FPGAD_PLUGIN_CONFIGURE "fpgad_plugin_configure"
|
|
Packit |
6639f8 |
typedef int (*fpgad_plugin_configure_t)(fpgad_monitored_device *d,
|
|
Packit |
6639f8 |
const char *cfg);
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#define FPGAD_PLUGIN_DESTROY "fpgad_plugin_destroy"
|
|
Packit |
6639f8 |
typedef void (*fpgad_plugin_destroy_t)(fpgad_monitored_device *d);
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#endif /* __FPGAD_MONITORED_DEVICE_H__ */
|