1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-16 00:00:02 +01:00
VILLASnode/src/fpga.c

98 lines
1.9 KiB
C
Raw Normal View History

2016-06-14 01:19:17 +02:00
/** VILLASfpga utility for tests and benchmarks
*
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017, Steffen Vogel
2016-06-14 01:19:17 +02:00
**********************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
2016-06-14 01:19:17 +02:00
#include <getopt.h>
#include <villas/log.h>
#include <villas/cfg.h>
2016-06-14 01:19:17 +02:00
#include <villas/timing.h>
#include <villas/utils.h>
2016-06-19 19:23:19 +02:00
#include <villas/nodes/fpga.h>
#include <villas/kernel/rt.h>
2016-06-14 01:19:17 +02:00
#include <villas/kernel/pci.h>
#include <villas/kernel/kernel.h>
2017-03-03 20:21:33 -04:00
#include <villas/fpga/card.h>
2016-06-14 01:19:17 +02:00
#include "config.h"
/* Declarations */
2017-03-03 20:21:33 -04:00
int fpga_benchmarks(int argc, char *argv[], struct fpga_card *c);
2016-10-22 20:37:02 -04:00
void usage()
2016-06-14 01:19:17 +02:00
{
printf("Usage: villas-fpga CONFIGFILE CARD [OPTIONS]\n\n");
printf(" Options:\n");
printf(" -d Set log level\n\n");
print_copyright();
exit(EXIT_FAILURE);
2016-06-14 01:19:17 +02:00
}
int main(int argc, char *argv[])
{
int ret;
struct cfg cfg;
2017-03-03 20:21:33 -04:00
struct fpga_card *card;
if (argc < 3)
usage(argv[0]);
2016-06-14 01:19:17 +02:00
/* Parse arguments */
char c, *endptr;
while ((c = getopt(argc-1, argv+1, "d:")) != -1) {
2016-06-14 01:19:17 +02:00
switch (c) {
case 'd':
2017-03-03 20:21:33 -04:00
cfg.log.level = strtoul(optarg, &endptr, 10);
2016-06-14 01:19:17 +02:00
break;
case '?':
default:
2016-10-22 20:37:02 -04:00
usage();
2016-06-14 01:19:17 +02:00
}
}
info("Parsing configuration");
2017-03-03 20:21:33 -04:00
cfg_parse(&cfg, argv[1]);
info("Initialize logging system");
log_init(&cfg.log, cfg.log.level, cfg.log.facilities);
info("Initialize real-time system");
rt_init(cfg.priority, cfg.affinity);
info("Initialize memory system");
memory_init();
/* Initialize VILLASfpga card */
ret = fpga_init(argc, argv, config_root_setting(&cfg.cfg));
2016-06-14 01:19:17 +02:00
if (ret)
error("Failed to initialize FPGA card");
2017-03-03 20:21:33 -04:00
card = fpga_lookup_card(argv[2]);
if (!card)
error("FPGA card '%s' does not exist", argv[2]);
fpga_card_dump(card);
2016-06-14 01:19:17 +02:00
/* Run benchmarks */
fpga_benchmarks(argc-optind-1, argv+optind+1, card);
2016-06-14 01:19:17 +02:00
/* Shutdown */
2017-03-03 20:21:33 -04:00
ret = fpga_deinit();
2016-06-14 01:19:17 +02:00
if (ret)
2017-03-03 20:21:33 -04:00
error("Failed to de-initialize FPGA card");
2017-03-03 20:21:33 -04:00
cfg_destroy(&cfg);
2016-06-14 01:19:17 +02:00
return 0;
}