1
0
mirror of https://github.com/bmartini/zynq-axis.git synced 2024-09-05 19:19:27 +08:00
zynq-axis/lib/interface.c
Berin Martini f553747076 Add exit function to interface library
Include usage of new exit function in the test-cfg application.
2014-12-31 13:16:19 -05:00

36 lines
509 B
C

#include "interface.h"
#include <assert.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <stdio.h>
static void *cfg;
int axis_init(const char *path)
{
int fd;
assert((fd = open(path, O_RDWR)) >= 0);
cfg =
mmap(NULL, REGISTER_NB, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
close(fd);
if (cfg == MAP_FAILED) {
return -1;
}
return 0;
}
int axis_exit()
{
if (munmap(cfg, REGISTER_NB) != 0) {
perror("Error un-mmapping the axis cfg");
return -1;
}
return 0;
}