From b6008ec2c657b7a06f3f1037218caeb9cc22d9e7 Mon Sep 17 00:00:00 2001 From: Patrick Robbe <robbe@lal.in2p3.fr> Date: Tue, 11 Jun 2019 18:40:12 +0900 Subject: [PATCH] Remove old files --- Driver/common/flags.mk | 41 ----- Driver/common/pcie40.c | 7 - Driver/common/pcie40.h | 8 - Driver/common/rules.mk | 318 --------------------------------------- Driver/pcie40/.gitignore | 6 - Driver/pcie40/Makefile | 40 ----- Driver/pcie40/main.c | 118 --------------- 7 files changed, 538 deletions(-) delete mode 100755 Driver/common/flags.mk delete mode 100644 Driver/common/pcie40.c delete mode 100644 Driver/common/pcie40.h delete mode 100644 Driver/common/rules.mk delete mode 100644 Driver/pcie40/.gitignore delete mode 100644 Driver/pcie40/Makefile delete mode 100644 Driver/pcie40/main.c diff --git a/Driver/common/flags.mk b/Driver/common/flags.mk deleted file mode 100755 index 0b16b68..0000000 --- a/Driver/common/flags.mk +++ /dev/null @@ -1,41 +0,0 @@ -#dg`make.flags` Several variables can be set in order to control what to build and what dependencies to enable, these can be set either in the environment, for example: <? -# ENABLE_XXX=false make # Set flag for single command, or -# export ENABLE_XXX=false # export flag in environment and -# make # reuse exported flags. -#?>Or by directly editing the file ``common/flags.mk``. - -export ENABLE_DIM ?=true -export ENABLE_MON ?=true -export ENABLE_HWLOC ?=true -export ENABLE_DOCRA ?=true -#dg`make.flags`1 _ The following dependency flags are available: _ -# ENABLE_DIM:: -# Whether to include support for http://cern.ch/dim[DIM]. Default: *true*. -# ENABLE_MON:: -# Whether to include the interface for DQMP (Data Quality Monitor and Presenter). Default: *true*. -# ENABLE_HWLOC:: -# Whether to include support for the https://www.open-mpi.org/projects/hwloc[hwloc library] (will try to schedule threads processing data from a PCIe40 board on a core closest to the corresponding PCIe root complex). Default: *true*. -# ENABLE_DOCRA:: -# Whether to generate the documentation (HTML and man pages). Requires docra and asciidoctor installed. Default: *true*. - -export ENABLE_DAQ40 ?=true -export ENABLE_AMC40 ?=true -export ENABLE_CCPC40 ?=false -export ENABLE_PCIE40 ?=true -#dg`make.flags`2 _ The following flags can be used to build only a subset of the targets: _ -# ENABLE_DAQ40:: -# Build tools and libraries that are common to both AMC40 and PCIe40 setups. Default: *true*. -# ENABLE_AMC40:: -# Build tools and libraries specific to the AMC40 board. Default: *true*. -# ENABLE_CCPC40:: -# Build tools and libraries specific to the AMC40 CCPC module. Default: *false*. -# ENABLE_PCIE40:: -# Build tools and libraries specific the the PCIe40 board. Default: *true*. - -export DIM_CXXFLAGS ?=-I/usr/local/include/dim -export DIM_LDFLAGS ?=-L/usr/local/lib64 -ldim -#export DIM_CXXFLAGS=-I$(HOME)/Sources/dim_v20r20/dim -#export DIM_LDFLAGS=-L$(HOME)/Sources/dim_v20r20/linux -ldim - -export PREFIX ?=/usr -export DAQ40_PREFIX ?=/opt/lhcb/daq40 diff --git a/Driver/common/pcie40.c b/Driver/common/pcie40.c deleted file mode 100644 index 862d7ae..0000000 --- a/Driver/common/pcie40.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pcie40.h" -#include <stdio.h> - -int p40_get_devname(int dev, const char* suffix, char *dst, size_t dstlen) -{ - return snprintf(dst, dstlen, "/dev/pcie40_%d_%s", dev, suffix); -} diff --git a/Driver/common/pcie40.h b/Driver/common/pcie40.h deleted file mode 100644 index 9f8430e..0000000 --- a/Driver/common/pcie40.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __PCIE40_H -#define __PCIE40_H - -#include <stdlib.h> - -int p40_get_devname(int dev, const char *suffix, char *dst, size_t dstlen); - -#endif//__PCIE40_H diff --git a/Driver/common/rules.mk b/Driver/common/rules.mk deleted file mode 100644 index f5aa785..0000000 --- a/Driver/common/rules.mk +++ /dev/null @@ -1,318 +0,0 @@ -BUILD_PREFIX ?= -LIBDIR_SUFFIX ?=64 -FLEX ?=flex -LFLAGS ?= -CFLAGS +=-Wall -g -O3 -CXXFLAGS +=-Wall -g -O3 -DOCRA ?=docra -ASCIIDOCTOR ?=asciidoctor - -define INST_template #file, dst, mode -INSTALL +=$(BUILD_PREFIX)$(2)/$(notdir $(1)) -ifeq (,$(wildcard $(HERE)/$(1))) -# Installing using absolute path -$(BUILD_PREFIX)$(2)/$(notdir $(1)): $(1) - @install -m 755 -d $(BUILD_PREFIX)$(2) - install -m $(3) $$< $(BUILD_PREFIX)$(2) -else -# Installing using relative path -$(BUILD_PREFIX)$(2)/$(notdir $(1)): $(HERE)/$(1) - @install -m 755 -d $(BUILD_PREFIX)$(2) - install -m $(3) $$< $(BUILD_PREFIX)$(2) -endif -endef - -%.out/_dir: $(HERE)/Makefile $(TOP)/common/rules.mk $(TOP)/common/flags.mk - mkdir -p $*.out && touch $@ - -define ODIR_template #var, [nodefault] -ifneq ($(2),nodefault) - DEFAULT +=$$($(1)) -endif -$(1)_ODIR :=$$($(1)).out -$(1)_ODOT :=$$($(1)_ODIR)/_dir - --include $$(addprefix $$($(1)_ODIR)/,$$($(1)_OBJS:.o=.d)) - -ODIRS +=$$($(1)_ODIR) - -ifeq (,$(wildcard $(shell pwd)/Makefile)) -# Out-of-tree build, external libraries are built locally -ifdef $(1)_LIBS_S -$$($(1)): $$(notdir $$($(1)_LIBS_S)) -endif -else -# In-tree build, external libraries are in their source dir -$$($(1)): $$($(1)_LIBS_S) -endif - -ifdef $(1)_DEPS -$$($(1)): $$($(1)_DEPS) -endif - -###################### -ifdef $(1)_CXXFLAGS -$(1)_CXXFLAGS +=-I$$($(1)_ODIR) - -$$($(1)_ODIR)/%.d $$($(1)_ODIR)/%.pic.d: $(HERE)/%.cpp $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -MM -MT $$(@:.d=.o) $$< > $$@ - -$$($(1)_ODIR)/%.d $$($(1)_ODIR)/%.pic.d: %.cpp $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -MM -MT $$(@:.d=.o) $$< > $$@ - -$$($(1)_ODIR)/%.d $$($(1)_ODIR)/%.pic.d: $$($(1)_ODIR)/%.cpp $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -MM -MT $$(@:.d=.o) $$< > $$@ - -$$($(1)_ODIR)/%.o: %.cpp $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -c -o $$@ $$< - -$$($(1)_ODIR)/%.pic.o: %.cpp $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -fPIC -c -o $$@ $$< - -$$($(1)_ODIR)/%.o: $(HERE)/%.cpp $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -c -o $$@ $$< - -$$($(1)_ODIR)/%.pic.o: $(HERE)/%.cpp $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -fPIC -c -o $$@ $$< - -$$($(1)_ODIR)/%.o: $$($(1)_ODIR)/%.cpp $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -c -o $$@ $$< - -$$($(1)_ODIR)/%.pic.o: $$($(1)_ODIR)/%.cpp $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -fPIC -c -o $$@ $$< - -$$($(1)_ODIR)/%.o: %.c $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -c -o $$@ $$< - -$$($(1)_ODIR)/%.pic.o: %.c $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -fPIC -c -o $$@ $$< - -$$($(1)_ODIR)/%.o: $(HERE)/%.c $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -c -o $$@ $$< - -$$($(1)_ODIR)/%.pic.o: $(HERE)/%.c $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -fPIC -c -o $$@ $$< - -$$($(1)_ODIR)/%.o: $$($(1)_ODIR)/%.c $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -c -o $$@ $$< - -$$($(1)_ODIR)/%.pic.o: $$($(1)_ODIR)/%.c $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -fPIC -c -o $$@ $$< - -$$($(1)_ODIR)/%.l.cpp $$($(1)_ODIR)/%.l.hpp: $(HERE)/%.lpp $$($(1)_ODOT) - $(FLEX) $(LFLAGS) --outfile=$$($(1)_ODIR)/$$*.l.cpp --header-file=$$($(1)_ODIR)/$$*.l.hpp $$< - -$$($(1)_ODIR)/%.l.o: $$($(1)_ODIR)/%.l.cpp $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -Wno-sign-compare -c -o $$@ $$< - -$$($(1)_ODIR)/%.l.pic.o: $$($(1)_ODIR)/%.l.cpp $$($(1)_ODOT) - $$(CXX) $$($(1)_CXXFLAGS) -fPIC -Wno-sign-compare -c -o $$@ $$< - -ifeq (,$(wildcard $(shell pwd)/Makefile)) -# Out-of-tree build, external libraries are built locally -ifdef $(1)_LIBS_S -$$($(1)): $$(notdir $$($(1)_LIBS_S)) -endif -else -# In-tree build, external libraries are in their source dir -$$($(1)): $$($(1)_LIBS_S) -endif - -ifdef $(1)_DEPS -$$($(1)): $$($(1)_DEPS) -endif - -ifdef $(1)_ARFLAGS -$$($(1)): $$(addprefix $$($(1)_ODIR)/,$$($(1)_OBJS)) - $(AR) $$($(1)_ARFLAGS) $$@ $$(filter %.o %.a,$$^) -else -$$($(1)): $$(addprefix $$($(1)_ODIR)/,$$($(1)_OBJS)) - $(CXX) $$($(1)_CXXFLAGS) $$(filter %.o %.a,$$^) -o $$@ $$($(1)_LDFLAGS) -endif - -###################### -else ifdef $(1)_CFLAGS -$(1)_CFLAGS +=-I$$($(1)_ODIR) - -$$($(1)_ODIR)/%.d $$($(1)_ODIR)/%.pic.d: $(HERE)/%.c $$($(1)_ODOT) - $$(CC) $$($(1)_CFLAGS) -MM -MT $$(@:.d=.o) $$< > $$@ - -$$($(1)_ODIR)/%.d $$($(1)_ODIR)/%.pic.d: %.c $$($(1)_ODOT) - $$(CC) $$($(1)_CFLAGS) -MM -MT $$(@:.d=.o) $$< > $$@ - -$$($(1)_ODIR)/%.d $$($(1)_ODIR)/%.pic.d: $$($(1)_ODIR)/%.c $$($(1)_ODOT) - $$(CC) $$($(1)_CFLAGS) -MM -MT $$(@:.d=.o) $$< > $$@ - -$$($(1)_ODIR)/%.o: %.c $$($(1)_ODOT) - $$(CC) $$($(1)_CFLAGS) -c -o $$@ $$< - -$$($(1)_ODIR)/%.pic.o: %.c $$($(1)_ODOT) - $$(CC) $$($(1)_CFLAGS) -fPIC -c -o $$@ $$< - -$$($(1)_ODIR)/%.o: $(HERE)/%.c $$($(1)_ODOT) - $$(CC) $$($(1)_CFLAGS) -c -o $$@ $$< - -$$($(1)_ODIR)/%.pic.o: $(HERE)/%.c $$($(1)_ODOT) - $$(CC) $$($(1)_CFLAGS) -fPIC -c -o $$@ $$< - -$$($(1)_ODIR)/%.o: $$($(1)_ODIR)/%.c $$($(1)_ODOT) - $$(CC) $$($(1)_CFLAGS) -c -o $$@ $$< - -$$($(1)_ODIR)/%.pic.o: $$($(1)_ODIR)/%.c $$($(1)_ODOT) - $$(CC) $$($(1)_CFLAGS) -fPIC -c -o $$@ $$< - -$$($(1)_ODIR)/%.l.c $$($(1)_ODIR)/%.l.h: $(HERE)/%.lpp $$($(1)_ODOT) - $(FLEX) $(LFLAGS) --outfile=$$($(1)_ODIR)/$$*.l.c --header-file=$$($(1)_ODIR)/$$*.l.h $$< - -$$($(1)_ODIR)/%.l.o: $$($(1)_ODIR)/%.l.c $$($(1)_ODOT) - $$(CC) $$($(1)_CFLAGS) -fPIC -Wno-sign-compare -c -o $$@ $$< - -$$($(1)_ODIR)/%.l.pic.o: $$($(1)_ODIR)/%.l.c $$($(1)_ODOT) - $$(CC) $$($(1)_CFLAGS) -Wno-sign-compare -c -o $$@ $$< - -ifdef $(1)_ARFLAGS -$$($(1)): $$(addprefix $$($(1)_ODIR)/,$$($(1)_OBJS)) - $(AR) $$($(1)_ARFLAGS) $$@ $$^ -else -$$($(1)): $$(addprefix $$($(1)_ODIR)/,$$($(1)_OBJS)) - $(CC) $$($(1)_CFLAGS) $$^ -o $$@ $$($(1)_LDFLAGS) -endif - -###################### -else -#$$(error no compilation flags defined for target $(1)) -endif - -ifdef $(1)_INSTALL -ifdef $(1)_ARFLAGS -$$(eval $$(call INST_template,$($(1)),$($(1)_INSTALL),644)) -else -$$(eval $$(call INST_template,$($(1)),$($(1)_INSTALL),755)) -endif -endif -endef - -define HDRS_template #var - $(foreach hdr,$($(1)_HDRS),$(eval $(call INST_template,$(hdr),$($(1)_HDRS_INSTALL),644))) -endef - -define COPY_template #var, chmod - $(foreach hdr,$($(1)),$(eval $(call INST_template,$(hdr),$($(1)_INSTALL),$(2)))) -endef - -define LINK_template #var -INSTALL +=$(BUILD_PREFIX)$($(1)_INSTALL)/$($(1)) -$(BUILD_PREFIX)$($(1)_INSTALL)/$($(1)): $(BUILD_PREFIX)$($(1)_LINK) - @install -m 755 -d $(BUILD_PREFIX)$($(1)_INSTALL) - ln -s $($(1)_LINK) $$@ -endef - -define DEP_template #file -DEP_DIRS +=$(dir $(1)) - -ifeq (,$(wildcard $(shell pwd)/Makefile)) -# Out-of-tree build, all targets go to the local folder -DEFAULT +=$(notdir $(1)) -$(notdir $(1)): - $(MAKE) $(notdir $(1)) -f $(dir $(1))Makefile -.PHONY: $(notdir $(1)) -else -# In-tree build, each target goes into its source folder -DEFAULT +=$(1) -$(1): - $(MAKE) $(notdir $(1)) -C $(dir $(1)) -.PHONY: $(1) -endif -endef - -define MAN_template #var, mansection -$(1)_ODIR :=$$($(1)).out -$(1)_ODOT :=$$($(1)_ODIR)/_dir -$(1)_MAN.ADOC :=$$($(1)_ODIR)/$$(patsubst %.dcrt,%.adoc,$$(notdir $$($(1)_MAN_DCRT))) -$(1)_MAN :=$$($(1)_ODIR)/$$($(1)).$(2) -$(1)_MAN.GZ :=$$($(1)_ODIR)/$$($(1)).$(2).gz - -MAN +=$$($(1)_MAN.GZ) - -ifeq ($(ENABLE_DOCRA), true) -$$($(1)_MAN.ADOC): $$($(1)_ODOT) - docra -l 0 -o $$($(1)_ODIR) $$($(1)_MAN_FLAGS) $$(dir $$($(1)_MAN_DCRT)) $$($(1)_MAN_DCRT) - -$$($(1)_MAN): $$($(1)_MAN.ADOC) - $(ASCIIDOCTOR) -b manpage $$< - -$$($(1)_MAN.GZ): $$($(1)_MAN) - gzip -f $$^ - -ifdef $(1)_MAN_INSTALL -MANINSTALL +=$(BUILD_PREFIX)$($(1)_MAN_INSTALL)/man$(2)/$$($(1)).$(2).gz -$(BUILD_PREFIX)$$($(1)_MAN_INSTALL)/man$(2)/$$($(1)).$(2).gz: $$($(1)_MAN.GZ) - @install -m 755 -d $(BUILD_PREFIX)$$($(1)_MAN_INSTALL)/man$(2) - @cp -v $$< $$@ -endif - -endif - -.PHONY: $$($(1)_MAN.ADOC) $$($(1)_MAN) $$($(1)_MAN.GZ) -endef - -define ALIAS_template #aliasvar, var, mansection - -ifdef $(2)_INSTALL -INSTALL +=$(BUILD_PREFIX)$($(2)_INSTALL)/$($(1)) -$(BUILD_PREFIX)$$($(2)_INSTALL)/$($(1)): - @install -m 755 -d $(BUILD_PREFIX)$$($(2)_INSTALL) - ln -s $$($(2)_INSTALL)/$$($(2)) $$@ -endif - -ifdef $(2)_MAN_INSTALL -MANINSTALL +=$(BUILD_PREFIX)$($(2)_MAN_INSTALL)/man$(3)/$($(1)).$(3).gz -$(BUILD_PREFIX)$$($(2)_MAN_INSTALL)/man$(3)/$$($(1)).$(3).gz: - @install -m 755 -d $(BUILD_PREFIX)$$($(2)_MAN_INSTALL)/man$(3) - ln -s $$($(2)_MAN_INSTALL)/man$(3)/$$($(2)).$(3).gz $$@ -endif - -endef - -#dg`make.sub` Each subfolder containing a ``Makefile`` can be build individually by simply issuing ``make`` from there. Dependencies on targets built in other subfolders will be built automatically. This can be used during development to quickly iterate on a single subproject. -# By default, a sub-project ``Makefile`` implements at least the following targets: _ -# *default*:: -# Builds all library and executable targets. -# *install*:: -# Copies installable files to their destination. -# *uninstall*:: -# Removes files copied by both *install* and *maninstall*. -# *man*:: -# Builds man pages. -# *maninstall*:: -# Installs man pages under ``$(PREFIX)/share/man``. -# *clean*:: -# Cleans build directory and deletes final targets. -# *depclean*:: -# Makes the *clean* target in every dependency of this subproject. - -define DEFAULT_template -default: $$(DEFAULT) - -install: $$(INSTALL) - -uninstall: - $$(RM) $$(INSTALL) $$(MANINSTALL) - -man: $$(MAN) - -maninstall: $$(MANINSTALL) - -clean: - $(RM) -r *.out/ $(ODIRS) - $(RM) $(DEFAULT) - -depclean: - for dep_dir in ${DEP_DIRS}; do $(MAKE) -C $$$${dep_dir} clean; done - -.PHONY: install uninstall man maninstall clean depclean -endef - -default: - -.PHONY: default diff --git a/Driver/pcie40/.gitignore b/Driver/pcie40/.gitignore deleted file mode 100644 index 15347fa..0000000 --- a/Driver/pcie40/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -libpcie40_ecs.a -libpcie40_ecs.a.out/ -libpcie40_ecs.so -libpcie40_ecs.so.out/ -pcie40_ecs -pcie40_ecs.out/ diff --git a/Driver/pcie40/Makefile b/Driver/pcie40/Makefile deleted file mode 100644 index c71a6be..0000000 --- a/Driver/pcie40/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -HERE :=$(strip $(realpath $(dir $(lastword $(MAKEFILE_LIST))))) -TOP :=$(realpath $(HERE)/..) - -include $(TOP)/common/flags.mk - -LIBPCIE40_ECS.A :=libpcie40_ecs.a -LIBPCIE40_ECS.A_OBJS =pcie40.o ecs.o -LIBPCIE40_ECS.A_CFLAGS =$(CFLAGS) -I$(TOP)/common -I$(TOP)/pcie40_driver -LIBPCIE40_ECS.A_ARFLAGS =rcs -LIBPCIE40_ECS.A_INSTALL =$(PREFIX)/lib$(LIBDIR_SUFFIX) - -LIBPCIE40_ECS.SO :=libpcie40_ecs.so -LIBPCIE40_ECS.SO_OBJS =$(LIBPCIE40_ECS.A_OBJS:.o=.pic.o) -LIBPCIE40_ECS.SO_CFLAGS =$(LIBPCIE40_ECS.A_CFLAGS) -LIBPCIE40_ECS.SO_LDFLAGS =-shared -LIBPCIE40_ECS.SO_INSTALL =$(LIBPCIE40_ECS.A_INSTALL) - -LIBPCIE40_ECS_HDRS :=ecs.h -LIBPCIE40_ECS_HDRS_INSTALL =$(PREFIX)/include/lhcb/pcie40 - -PCIE40_ECS :=pcie40_ecs -PCIE40_ECS_OBJS =main.o -PCIE40_ECS_CFLAGS =$(CFLAGS) -I$(TOP)/common -I$(TOP)/pcie40_driver -PCIE40_ECS_LIBS_S =libpcie40_ecs.a -PCIE40_ECS_INSTALL =$(PREFIX)/bin - -PCIE40_ECS_MAN_DCRT =$(HERE)/man.dcrt -PCIE40_ECS_MAN_INSTALL =$(PREFIX)/share/man - -VPATH :=$(TOP)/common - -include $(TOP)/common/rules.mk -ifeq ($(ENABLE_PCIE40), true) -$(eval $(call ODIR_template,LIBPCIE40_ECS.A)) -$(eval $(call ODIR_template,LIBPCIE40_ECS.SO)) -$(eval $(call HDRS_template,LIBPCIE40_ECS,$(TOP)/pcie40_ecs)) -$(eval $(call ODIR_template,PCIE40_ECS)) -$(eval $(call MAN_template,PCIE40_ECS,1)) -endif -$(eval $(call DEFAULT_template)) diff --git a/Driver/pcie40/main.c b/Driver/pcie40/main.c deleted file mode 100644 index c82c4f2..0000000 --- a/Driver/pcie40/main.c +++ /dev/null @@ -1,118 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include "ecs.h" - -static int flag_devnum = 0; -static int flag_barnum = -1; -static int flag_address = 0; -static uint32_t flag_addroff; -static int flag_write = 0; -static uint32_t flag_writeval; -static int flag_read = 0; - -//ug`pcie40_ecs.synopsis` -// *pcie40_ecs* [-i _interface_] -b _bar_ -a _address_ -w _value_ _ -// *pcie40_ecs* [-i _interface_] -b _bar_ -a _address_ -r -static void usage() -{ - fprintf(stderr, "usage: pcie40_ecs [options]\n"); - fprintf(stderr, " -h Print this message\n"); - fprintf(stderr, " -i {} Interface number (default: 0)\n"); - fprintf(stderr, " -b {} BAR number\n"); - fprintf(stderr, " -a {} Register address\n"); - fprintf(stderr, " -w {} Write value to register\n"); - fprintf(stderr, " -r Read register\n"); -} - -//ug`pcie40_ecs.description` -// Reads and writes PCIe40 BAR0 and BAR2 registers over PCI Express. - -int main(int argc, char *argv[]) -{ - while (argc > 1 && argv[1][0] == '-') { - switch (argv[1][1]) { - - //ug`pcie40_ecs.options`interface - // *-i* _interface_:: - // Bind to PCIe40 interface number _interface_. This is optional and by default the tool will bind to the first interface available (typically 0). - case 'i': - ++argv; - --argc; - flag_devnum = atoi(argv[1]); - break; - - //ug`pcie40_ecs.options`bar - // *-b* _bar_:: - // Access BAR number _bar_. Two PCI BARs are available: - // * 0 for user code (includes registers for DAQ, TFC, SCA...) - // * 2 for the common low-level interface - case 'b': - ++argv; - --argc; - flag_barnum = atoi(argv[1]); - break; - - //ug`pcie40_ecs.options`address - // *-a* _address_:: - // Address to use for BAR access. Can be in decimal, hexadecimal or any other format supported by *strtol(3)*. - case 'a': - ++argv; - --argc; - flag_address = 1; - flag_addroff = strtol(argv[1], NULL, 0); - break; - - //ug`pcie40_ecs.options`write - // *-w* _value_:: - // Write 32-bit _value_ to register at the given address. Same input format considerations apply as for the *-a* option. - case 'w': - ++argv; - --argc; - flag_write = 1; - flag_writeval = strtoul(argv[1], NULL, 0); - break; - - //ug`pcie40_ecs.options`read - // *-r*:: - // Read value of register at given address. Value is printed to stdout in hexadecimal format. - case 'r': - flag_read = 1; - break; - - //ug`pcie40_ecs.options`help - // *-h*:: - // Output short program synopsis and exit. - default: - case 'h': - usage(); - exit(1); - break; - } - --argc; - ++argv; - } - //ug`pcie40_ecs.exit` - // -1 is returned in case of access error or wrong command line options, 0 otherwise. - if (!flag_address || flag_barnum < 0) { - usage(); - exit(-1); - } - if (!flag_read && !flag_write) { - printf("-r and -w are mutually exclusive\n"); - exit(-1); - } - - uint32_t *regs; - int ecs = p40_ecs_open(flag_devnum, flag_barnum, ®s); - - if (flag_write) { - p40_ecs_w32(regs, flag_addroff, flag_writeval); - } else if (flag_read) { - uint32_t reg = p40_ecs_r32(regs, flag_addroff); - printf("0x%08x", reg); - } - p40_ecs_close(ecs, regs); - - return 0; -} -- GitLab