Blame external/opae-test/framework/mock/test_fpgad/fpgad/fpgad.h

Packit 534379
// Copyright(c) 2018-2020, Intel Corporation
Packit 534379
//
Packit 534379
// Redistribution  and  use  in source  and  binary  forms,  with  or  without
Packit 534379
// modification, are permitted provided that the following conditions are met:
Packit 534379
//
Packit 534379
// * Redistributions of  source code  must retain the  above copyright notice,
Packit 534379
//   this list of conditions and the following disclaimer.
Packit 534379
// * Redistributions in binary form must reproduce the above copyright notice,
Packit 534379
//   this list of conditions and the following disclaimer in the documentation
Packit 534379
//   and/or other materials provided with the distribution.
Packit 534379
// * Neither the name  of Intel Corporation  nor the names of its contributors
Packit 534379
//   may be used to  endorse or promote  products derived  from this  software
Packit 534379
//   without specific prior written permission.
Packit 534379
//
Packit 534379
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit 534379
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,  BUT NOT LIMITED TO,  THE
Packit 534379
// IMPLIED WARRANTIES OF  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit 534379
// ARE DISCLAIMED.  IN NO EVENT  SHALL THE COPYRIGHT OWNER  OR CONTRIBUTORS BE
Packit 534379
// LIABLE  FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR
Packit 534379
// CONSEQUENTIAL  DAMAGES  (INCLUDING,  BUT  NOT LIMITED  TO,  PROCUREMENT  OF
Packit 534379
// SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE,  DATA, OR PROFITS;  OR BUSINESS
Packit 534379
// INTERRUPTION)  HOWEVER CAUSED  AND ON ANY THEORY  OF LIABILITY,  WHETHER IN
Packit 534379
// CONTRACT,  STRICT LIABILITY,  OR TORT  (INCLUDING NEGLIGENCE  OR OTHERWISE)
Packit 534379
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  EVEN IF ADVISED OF THE
Packit 534379
// POSSIBILITY OF SUCH DAMAGE.
Packit 534379
Packit 534379
#ifndef __FPGAD_FPGAD_H__
Packit 534379
#define __FPGAD_FPGAD_H__
Packit 534379
Packit 534379
#ifndef __USE_GNU
Packit 534379
#define __USE_GNU
Packit 534379
#endif
Packit 534379
#ifndef _GNU_SOURCE
Packit 534379
#define _GNU_SOURCE
Packit 534379
#endif
Packit 534379
#include <stdio.h>
Packit 534379
#include <stdlib.h>
Packit 534379
#include <stdbool.h>
Packit 534379
#include <stdint.h>
Packit 534379
#include <string.h>
Packit 534379
#include <pthread.h>
Packit 534379
#include <stdarg.h>
Packit 534379
#include <errno.h>
Packit 534379
#include <sys/types.h>
Packit 534379
#include <sys/stat.h>
Packit 534379
#include <unistd.h>
Packit 534379
#include <fcntl.h>
Packit 534379
#include <signal.h>
Packit 534379
#include <linux/limits.h>
Packit 534379
#include <opae/fpga.h>
Packit 534379
Packit 534379
#include "libbitstream/bitstream.h"
Packit 534379
Packit 534379
//#include "opae_int.h"
Packit 534379
Packit 534379
//#include "api/logging.h"
Packit 534379
//#include "command_line.h"
Packit 534379
Packit 534379
//int daemonize(void (*hndlr)(int, siginfo_t *, void *),
Packit 534379
//	      mode_t mask,
Packit 534379
//	      const char *dir);
Packit 534379
Packit 534379
#define fpgad_mutex_lock(__res, __mtx_ptr)                                     \
Packit 534379
	({                                                                     \
Packit 534379
		(__res) = pthread_mutex_lock(__mtx_ptr);                       \
Packit 534379
		if (__res)                                                     \
Packit 534379
			LOG("pthread_mutex_lock failed: %s",                   \
Packit 534379
				strerror(errno));                              \
Packit 534379
		__res;                                                         \
Packit 534379
	})
Packit 534379
Packit 534379
#define fpgad_mutex_unlock(__res, __mtx_ptr)                                   \
Packit 534379
	({                                                                     \
Packit 534379
		(__res) = pthread_mutex_unlock(__mtx_ptr);                     \
Packit 534379
		if (__res)                                                     \
Packit 534379
			LOG("pthread_mutex_unlock failed: %s",                 \
Packit 534379
					strerror(errno));                      \
Packit 534379
		__res;                                                         \
Packit 534379
	})
Packit 534379
Packit 534379
struct _fpgad_supported_device;
Packit 534379
Packit 534379
struct fpgad_config {
Packit 534379
	useconds_t poll_interval_usec;
Packit 534379
Packit 534379
	bool daemon;
Packit 534379
	char directory[PATH_MAX];
Packit 534379
	char logfile[PATH_MAX];
Packit 534379
	char pidfile[PATH_MAX];
Packit 534379
	char cfgfile[PATH_MAX];
Packit 534379
	mode_t filemode;
Packit 534379
Packit 534379
	bool running;
Packit 534379
Packit 534379
	const char *api_socket;
Packit 534379
Packit 534379
#define MAX_NULL_GBS 32
Packit 534379
	opae_bitstream_info null_gbs[MAX_NULL_GBS];
Packit 534379
	unsigned num_null_gbs;
Packit 534379
Packit 534379
	pthread_t bmc_monitor_thr;
Packit 534379
	pthread_t monitor_thr;
Packit 534379
	pthread_t event_dispatcher_thr;
Packit 534379
	pthread_t events_api_thr;
Packit 534379
Packit 534379
	struct _fpgad_supported_device *supported_devices;
Packit 534379
};
Packit 534379
Packit 534379
extern struct fpgad_config global_config;
Packit 534379
Packit 534379
fpga_result fpgaDestroyToken(fpga_token *token);
Packit 534379
Packit 534379
#endif /* __FPGAD_FPGAD_H__ */