Commit 79fe79d8 authored by Lucas Russo's avatar Lucas Russo

all: initial commit

parents
*~
*.swp
*.orig
*.bak
*.o
*.d
dev_mngr
dev_io
valgrind_report.txt
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>
import os
import ycm_core
# These are the compilation flags that will be used in case there's no
# compilation database set (by default, one is not set).
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wno-long-long',
'-fexceptions',
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
# language to use when compiling headers. So it will guess. Badly. So C++
# headers will be compiled as C headers. You don't want that so ALWAYS specify
# a "-std=<something>".
# For a C project, you would set this to something like 'c99' instead of
# 'c++11'.
'-std=gnuc99',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x',
'c',
'-isystem',
'../BoostParts',
# This path will only work on OS X, but extra paths that don't exist are not
# harmful
'-isystem',
'../llvm/include',
'-isystem',
'../llvm/tools/clang/include',
'-I',
'.',
'-I',
'./ClangCompleter',
'-isystem',
'./tests/gmock/gtest',
'-isystem',
'./tests/gmock/gtest/include',
'-isystem',
'./tests/gmock',
'-isystem',
'./tests/gmock/include',
'-isystem',
'/usr/include',
'-isystem',
'/usr/local/include',
'-I',
'hal/include',
'-I',
'hal/dev_mngr',
'-I',
'hal/dev_io',
'-I',
'hal/debug',
'-I',
'hal/hal_utils',
'-I',
'hal/ll_io',
'-I',
'hal/ll_io/ops',
'-I',
'hal/sdb',
'-I',
'hal/sm_io',
'-I',
'hal/sm_io/modules',
'-I',
'hal/sm_io/modules/fmc130m_4ch',
'-I',
'hal/msg',
'-I',
'hal/msg/smio_thsafe_ops',
'-I',
'hal/msg/exp_ops',
'-I',
'kernel/include/pcie',
'-g',
'-DDBE_DEBUG=1',
'-lzmq',
'-lczmq',
'-lmdp',
]
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''
if os.path.exists( compilation_database_folder ):
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
if not working_directory:
return list( flags )
new_flags = []
make_next_absolute = False
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = False
if not flag.startswith( '/' ):
new_flag = os.path.join( working_directory, flag )
for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break
if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
break
if new_flag:
new_flags.append( new_flag )
return new_flags
def IsHeaderFile( filename ):
extension = os.path.splitext( filename )[ 1 ]
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
def GetCompilationInfoForFile( filename ):
# The compilation_commands.json file generated by CMake does not have entries
# for header files. So we do our best by asking the db for flags for a
# corresponding source file, if any. If one exists, the flags for that file
# should be good enough.
if IsHeaderFile( filename ):
basename = os.path.splitext( filename )[ 0 ]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists( replacement_file ):
compilation_info = database.GetCompilationInfoForFile(
replacement_file )
if compilation_info.compiler_flags_:
return compilation_info
return None
return database.GetCompilationInfoForFile( filename )
def FlagsForFile( filename, **kwargs ):
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile( filename )
if not compilation_info:
return None
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
try:
final_flags.remove( '-stdlib=libc++' )
except ValueError:
pass
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
return {
'flags': final_flags,
'do_cache': True
}
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
# Set your cross compile prefix with CROSS_COMPILE variable
CROSS_COMPILE ?=
CMDSEP = ;
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
LD = $(CROSS_COMPILE)ld
OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size
MAKE = make
INSTALL_DIR ?= /usr/lib
export INSTALL_DIR
# Kernel stuff (pcie driver and library) relative
# directory
KERNEL_DIR = kernel
# General C flags
CFLAGS = -std=gnu99 -O2
LOCAL_MSG_DBG ?= n
DBE_DBG ?= n
CFLAGS_DEBUG =
ifeq ($(LOCAL_MSG_DBG),y)
CFLAGS_DEBUG += -DLOCAL_MSG_DBG=1
endif
ifeq ($(DBE_DBG),y)
CFLAGS_DEBUG += -DDBE_DBG=1
endif
# Debug flags -D<flasg_name>=<value>
CFLAGS_DEBUG += -g
# Specific platform Flags
CFLAGS_PLATFORM = -Wall -Wextra -Werror
LDFLAGS_PLATFORM =
# Libraries
LIBS = -lzmq -lczmq -lmdp -lpcidriver
# General library flags -L<libdir>
LFLAGS =
# Specific platform objects
OBJS_PLATFORM =
# Include other Makefiles as needed here
#include services/services.mk
#include clients/clients.mk
include hal/hal.mk
# Include directories
INCLUDE_DIRS = $(hal_INCLUDE_DIRS) \
-I$(KERNEL_DIR)/include/pcie
# Merge all flags. Optimize for size (-Os)
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
#-Os
LDFLAGS = $(LDFLAGS_PLATFORM)
#-ffunction-sections -fdata-sections -Wl,--gc-sections
# Output modules
OUT = $(hal_OUT)
.SECONDEXPANSION:
# Save a git repository description
#REVISION = $(shell git describe --dirty --always)
#REVISION_NAME = revision
#OBJ_REVISION = $(addsuffix .o, $(REVISION_NAME))
OBJS_all = $(hal_OBJS) $(OBJ_REVISION)
.PHONY: all kernel_check clean mrproper install uninstall tests examples
# Avoid deletion of intermediate files, such as objects
.SECONDARY: $(OBJS_all)
# Makefile rules
all: kernel_check $(OUT)
# Output Rule
$(OUT): $$($$@_OBJS)
#$(REVISION_NAME).o
$(CC) $(LFLAGS) $(CFLAGS) $(INCLUDE_DIRS) -o $@ $^ $(LDFLAGS) $(LIBS)
#$(SIZE) $@
#$(REVISION_NAME).o: $(REVISION_NAME).c
# $(CC) $(CFLAGS) $(INCLUDE_DIRS) -DGIT_REVISION=\"$(REVISION)\" -c $<
# $(SIZE) -t $@
# Pull in dependency info for *existing* .o files and don't complain if the
# corresponding .d file is not found
-include $(OBJS_all:.o=.d)
# Autodependencies generatation by Scott McPeak, November 2001,
# from article "Autodependencies with GNU make"
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@
# create the dependency files "target: pre-requisites"
${CC} -MM $(CFLAGS) $(INCLUDE_DIRS) $*.c > $*.d
# Workaround to make objects in different folders have
# the correct target path. e.g., "dir/bar.o: dir/bar.c dir/foo.h"
# instead of "bar.o: dir/bar.c dir/foo.h"
@mv -f $*.d $*.d.tmp
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
# All prereqs listed will also become command-less,
# prereq-less targets. In this way, the prereq file will be
# treated as changed and the target will be rebuilt
# sed: strip the target (everything before colon)
# sed: remove any continuation backslashes
# fmt -1: list words one per line
# sed: strip leading spaces
# sed: add trailing colons
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@rm -f $*.d.tmp
kernel_check:
# Check for libraries and issue warning!!!
# $(MAKE) -C $(KERNEL_DIR) all
tests:
$(MAKE) -C $@ all
examples:
$(MAKE) -C $@ all
#install:
# @install -m 755 $(TARGET_SHARED_VER) $(INSTALL_DIR)
# $(foreach lib,$(TARGET_SHARED),ln -sf $(lib).$(LIB_VER) $(INSTALL_DIR)/$(lib) $(CMDSEP))
#
#uninstall:
# $(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/$(lib).$(LIB_VER) $(CMDSEP))
# $(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/$(lib) $(CMDSEP))
clean:
rm -f $(OBJS_all) $(OBJS_all:.o=.d)
$(MAKE) -C tests clean
$(MAKE) -C examples clean
$(MAKE) -C $(KERNEL_DIR) clean
mrproper: clean
rm -f $(OUT)
$(MAKE) -C examples mrproper
==============================================================================
Repository containing the Beam Position Monitor Software
==============================================================================
Prerequisites:
-> Make sure you have the following libraries installed:
* zeromq-4.0.4 (http://zeromq.org/area:download)
* czmq-2.1.0 (http://czmq.zeromq.org/page:get-the-software)
-> Cloning this repository
1 - git clone --recursive https://github.com/lerwys/bpm-software.git
==============================================================================
PCIe Installation Instructions:
1 - sudo apt-get install linux-headers-generic
-> Install the GIT package
2 - sudo apt-get install binutils gcc
-> Change folder to the pcie driver location
4 - cd kernel
-> Compile the PCIe driver and its tests
5 - make
-> Install the PCIe drivers and libraries
6 - sudo make install
-> Load the Driver module
7 - sudo insmod /lib/modules/$(uname -r)/extra/PciDriver.ko
-> After this the kernel should have found the FPGA board and
initialized it. Run the following command and check its output
8 - dmesg | tail
-> You should see something like the excerpt below:
"
[267002.495109] pciDriver - pcidriver_init :
Major 250 allocated to nodename 'fpga'
[267002.495130] pciDriver - pcidriver_probe :
Found ML605 board at 0000:01:00.0
[267002.495224] pciDriver - pcidriver_probe :
Device /dev/fpga0 added
[267002.495434] pciDriver - pcidriver_probe_irq :
Registered Interrupt Handler at pin 1, line 11, IRQ 16
[267002.495450] pciDriver - pcidriver_init :
Module loaded
"
==============================================================================
Running the PCIe self-test:
-> After the installation of the PCIe driver (see above) it is possible to run
a self test to check if everything is setup properly. For this run the following:
-> Change to the "compiled tests folder"
1 - cd tests/pcie/bin
-> Run the test entitled "testPciDriverMod"
2 - sudo ./testPciDriverMod
-> You should get an output like the following, if everythig is ok:
"
Testing OPEN DEVICE... PASSED!
Testing PCIDRIVER_IOC_MMAP_MODE... PASSED!
Testing PCIDRIVER_IOC_MMAP_AREA... PASSED!
Testing PCIDRIVER_IOC_PCI_INFO... PASSED!
Testing PCI CONFIG...
Reading PCI config area in byte mode ... PASSED!
Reading PCI config area in word mode ... PASSED!
Reading PCI config area in double-word mode ... PASSED!
Testing PCI mmap...
Reading PCI info... PASSED!
Setting mmap mode... PASSED!
Setting mmap area... PASSED!
MMAP'ing BAR0... PASSED!
Setting mmap area... PASSED!
MMAP'ing BAR2... PASSED!
Setting mmap area... PASSED!
MMAP'ing BAR4... PASSED!
Testing PCIDRIVER_IOC_KMEM_ALLOC...
alloc size 1024 : PASSED!
alloc size 2048 : PASSED!
alloc size 4096 : PASSED!
alloc size 8192 : PASSED!
alloc size 16384 : PASSED!
alloc size 32768 : PASSED!
alloc size 65536 : PASSED!
alloc size 131072 : PASSED!
alloc size 262144 : PASSED!
alloc size 524288 : PASSED!
alloc size 1048576 : PASSED!
alloc size 2097152 : PASSED!
alloc size 4194304 : PASSED!
alloc size 8388608 : FAILED (maybe size is just too big)!
Testing PCIDRIVER_IOC_KMEM_SYNC...
Setting KMEM SYNC to write mode... PASSED!
Setting KMEM SYNC to read mode... PASSED!
Setting KMEM SYNC to read/write mode... PASSED!
Testing PCIDRIVER_IOC_KMEM_FREE... PASSED!
Testing Kernel Buffer mmap...
Setting MMAP mode to KMEM... PASSED!
Allocing size 1024 : PASSED!
MMAPing size 1024 : PASSED!
Allocing size 2048 : PASSED!
MMAPing size 2048 : PASSED!
Allocing size 4096 : PASSED!
MMAPing size 4096 : PASSED!
Allocing size 8192 : PASSED!
MMAPing size 8192 : PASSED!
Allocing size 16384 : PASSED!
MMAPing size 16384 : PASSED!
Allocing size 32768 : PASSED!
MMAPing size 32768 : PASSED!
Allocing size 65536 : PASSED!
MMAPing size 65536 : PASSED!
Allocing size 131072 : PASSED!
MMAPing size 131072 : PASSED!
Allocing size 262144 : PASSED!
MMAPing size 262144 : PASSED!
Allocing size 524288 : PASSED!
MMAPing size 524288 : PASSED!
Allocing size 1048576 : PASSED!
MMAPing size 1048576 : PASSED!
Allocing size 2097152 : PASSED!
MMAPing size 2097152 : PASSED!
Allocing size 4194304 : PASSED!
MMAPing size 4194304 : PASSED!
Allocing size 8388608 : FAILED (maybe size is just too big)!
Freeing Kernel buffers...
Buffer index 0... PASSED!
Buffer index 1... PASSED!
Buffer index 2... PASSED!
Buffer index 3... PASSED!
Buffer index 4... PASSED!
Buffer index 5... PASSED!
Buffer index 6... PASSED!
Buffer index 7... PASSED!
Buffer index 8... PASSED!
Buffer index 9... PASSED!
Buffer index 10... PASSED!
Buffer index 11... PASSED!
Buffer index 12... PASSED!
Testing PCIDRIVER_IOC_UMEM_SGMAP ... PASSED!
Testing PCIDRIVER_IOC_UMEM_SGGET ... PASSED!
Testing PCIDRIVER_IOC_UMEM_SYNC ...
Setting UMEM SYNC to write mode... PASSED!
Setting UMEM SYNC to read mode... PASSED!
Setting UMEM SYNC to read/write mode... PASSED!
Testing PCIDRIVER_IOC_UMEM_SGUNMAP ... PASSED!
-------------------------------------
| All tests PASSED! |
-------------------------------------
"
-> Notice that some tests that try to evaluate the limits of a current
Linux Kernel may fail in some cases. In the example above,