1
0
mirror of https://github.com/bmartini/zynq-axis.git synced 2024-09-05 19:19:27 +08:00

Stub of an axis interface library

Attempts to mmap the axis AXI4Lite memory region.
This commit is contained in:
Berin Martini 2014-12-31 11:49:12 -05:00
parent fc6b0b2dc6
commit 11ec4ddca7
3 changed files with 73 additions and 0 deletions

34
lib/Makefile Normal file
View File

@ -0,0 +1,34 @@
CC = gcc
CFLAGS := -c -fpic -Wall -Werror
INCLUDES := -I.
LIBOPTS := -shared
.PHONY : all
all : interface
interface.o :
$(CC) $(CFLAGS) $(INCLUDES) interface.c
interface : interface.o
$(CC) *.o $(LIBOPTS) -o libinterface.so
install :
sudo cp ${PWD}/libinterface.so /usr/lib
sudo cp ${PWD}/interface.h /usr/include
sudo chmod 0755 /usr/lib/libinterface.so
sudo ldconfig
uninstall :
sudo rm /usr/lib/libinterface.so
sudo rm /usr/include/interface.h
sudo ldconfig
.PHONY : clean
clean :
rm -f *.o libinterface.so

24
lib/interface.c Normal file
View File

@ -0,0 +1,24 @@
#include "interface.h"
#include <assert.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.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; // failure
}
return 0;
}

15
lib/interface.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef INTERFACE_H
#define INTERFACE_H
#ifdef __cplusplus
extern "C" {
#endif
#define REGISTER_NB 32
int axis_init(const char *path);
#ifdef __cplusplus
}
#endif
#endif /* INTERFACE_H */