Skip to content

Commit

Permalink
Add PCIe Linux kernel driver and library
Browse files Browse the repository at this point in the history
  • Loading branch information
abyszuk committed Nov 9, 2012
1 parent 7674167 commit f2e78f8
Show file tree
Hide file tree
Showing 36 changed files with 5,514 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,31 @@
Folder containing all of the Beam Position Monitor software.

==========================================================

1. PCIE driver for FPGA device

1.1. Overview

This driver is based on original driver for the PCIe SG DMA project
placed at the opencores.org
As of now, the changes are mostly reworked Makefiles to fit into the
directory structure at the OHWR repo; also, with present makefiles
it's easier to cross-compile code (e.g. using buildroot).

It consists of two parts:
- kernel driver at driver/pcie
- c/c++ library at lib/pcie
All relevant includes are in include/pcie folder.

1.2. INSTALL

To compile and install kernel driver go to driver/pcie and issue 'make && make install'

To install library go to lib/pcie and type 'make && make install'

1.3. TODO

- review and commit original test units
- port to PowerPC
- any changes that will be required

25 changes: 25 additions & 0 deletions drivers/pcie/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# Main Makefile for the pciDriver

#helpful in case of buildroot crosscompiling
ROOTDIR :=
CURDIR := $(shell pwd)

export SRCDIR := $(CURDIR)/src

default:
$(Q)$(MAKE) -C $(SRCDIR)

install:
$(Q)$(MAKE) -C $(SRCDIR) install
@echo "INSTALL 60-udev_fpga.rules"
-$(Q)install -m 644 etc/udev/rules.d/60-udev_fpga.rules $(ROOTDIR)/etc/udev/rules.d/

uninstall:
$(Q)$(MAKE) -C $(SRCDIR) uninstall
@echo "UNINSTALL 60-udev_fpga.rules"
-$(Q)rm -f $(ROOTDIR)/etc/udev/rules.d/60-udev_fpga.rules

clean:
@echo "Cleaning..."
-$(Q)$(MAKE) -C $(SRCDIR) clean
3 changes: 3 additions & 0 deletions drivers/pcie/etc/udev/rules.d/60-udev_fpga.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Permissions for the fpga devices

KERNEL="fpga*", OWNER="root", GROUP="users", MODE="660"
21 changes: 21 additions & 0 deletions drivers/pcie/make_with_buildroot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

#add relevant overrides to make use of buildroot toolchain
BUILDROOT_DIR="/home/adrian/praca/buildroot/buildroot"

KERNELDIR="$BUILDROOT_DIR/output/build/linux-3.4.7"
INSTALLDIR="$BUILDROOT_DIR/output/target"

export ARCH=x86_64
export CROSS_COMPILE=x86_64-linux-
export PATH="$PATH:$BUILDROOT_DIR/output/host/usr/bin"

EXTRA_CFLAGS="-D VERBOSE"

cd src && make KERNELDIR=$KERNELDIR

cd ..
echo "Copying to $INSTALLDIR"
cp src/pciDriver.ko $INSTALLDIR/opt/
cp etc/udev/rules.d/60-udev_fpga.rules $INSTALLDIR/etc/udev/rules.d/
echo "DONE"
14 changes: 14 additions & 0 deletions drivers/pcie/src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#makefile symbolic link
pciDriver.h

#editor backup files
*~

#Kbuild files
*.o
*.ko
*.mod.c
Module.symvers
modules.order
.tmp_versions/
.*.cmd
32 changes: 32 additions & 0 deletions drivers/pcie/src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

obj-m := pciDriver.o
pciDriver-objs := base.o int.o umem.o kmem.o sysfs.o ioctl.o

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
INSTALLDIR ?= /lib/modules/$(shell uname -r)/extra
INSTALLHDRDIR ?= /usr/include/pciDriver/driver
PWD := $(shell pwd)

default: dolink
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules

dolink:
@ln -sf ../../../include/pcie/driver/pciDriver.h

install:
@mkdir -p $(INSTALLDIR)
@echo "INSTALL $(INSTALLDIR)/pciDriver.ko"
@install -m 755 pciDriver.ko $(INSTALLDIR)
@echo "INSTALL $(INSTALLHDRDIR)/pciDriver.h"
@mkdir -p $(INSTALLHDRDIR)
@install -m 644 pciDriver.h $(INSTALLHDRDIR)

uninstall:
@echo "UNINSTALL $(INSTALLDIR)/pciDriver.ko"
@rm -f $(INSTALLDIR)/pciDriver.ko
@echo "UNINSTALL $(INSTALLHDRDIR)/pciDriver.h"
@rm -rf /usr/include/pciDriver/driver

clean:
rm -f *.o *.ko *.mod.c .*.cmd Module.symvers modules.order
rm -rf .tmp_versions
Loading

0 comments on commit f2e78f8

Please sign in to comment.