mirror of
https://github.com/bmartini/zynq-axis.git
synced 2024-09-05 19:19:27 +08:00
36 lines
509 B
C
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;
|
|
}
|