Commit 03eeb819 authored by Marek Gumiński's avatar Marek Gumiński Committed by Jacek Kołodziejski

Replaced old zio repo with submodule of latest commit

parent 70f80683
......@@ -16,3 +16,6 @@
[submodule "software/fpga-config-space"]
path = software/fpga-config-space
url = git://ohwr.org/hdl-core-lib/fpga-config-space.git
[submodule "software/fmc-adc-100m14b4cha-sw/zio"]
path = software/fmc-adc-100m14b4cha-sw/zio
url = git://ohwr.org/misc/zio.git
zio @ 0aea6955
Subproject commit 0aea6955d010ac9f4e5983cad36bdfa438b63888
*~
.*cmd
.*ersions
*.o
*.ko
*.order
*.symvers
*.mod.c
\#*\#
*.sh
# eclipse files
.cproject
.project
.settings
.*.d
TAGS*
\ No newline at end of file
This diff is collapsed.
Where: /sys/bus/zio/version
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute return the version of the ZIO framework in use.
Users:
Where: /sys/bus/zio/available_buffers
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute return the list of available buffer types.
Users:
Where: /sys/bus/zio/available_triggers
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute return the list of available trigger types.
Users:
Where: /sys/bus/zio/devices/hw-<zdev>/
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This directory represents a fake instance of a device the
real device (<zdev>). Once the device match with a ZIO
driver, then it creates the real device directory.
Users:
Where: /sys/bus/zio/devices/<zdev>/
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This directory represents a real device; it is child of
the fake device. This is the highest level of the device
hierarchy.
Users:
Where: /sys/bus/zio/devices/<zdev>/name
/sys/bus/zio/devices/<zdev>/<cset>/name
/sys/bus/zio/devices/<zdev>/<cset>/<chan>/name
/sys/bus/zio/devices/<zdev>/<cset>/trigger/name
/sys/bus/zio/devices/<zdev>/<cset>/<chan>/buffer/name
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute returns the name of a ZIO object. It is a
read only attribute.
Users:
Where: /sys/bus/zio/devices/<zdev>/enable
/sys/bus/zio/devices/<zdev>/<cset>/enable
/sys/bus/zio/devices/<zdev>/<cset>/<chan>/enable
/sys/bus/zio/devices/<zdev>/<cset>/trigger/enable
/sys/bus/zio/devices/<zdev>/<cset>/<chan>/buffer/enable
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute enable/disable a ZIO object. To enable a
ZIO object you must write '1', to disable '0'
Users:
Where: /sys/bus/zio/devices/<zdev>/<cset>/current_buffer
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute return the current buffer in use by the
channel within the channel-set. You can change the kind of
buffer by writing its name in this attribute.
Users:
Where: /sys/bus/zio/devices/<zdev>/<cset>/current_trigger
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute return the current trigger in use by the
channel-set. You can change the kind of trigger by writing
its name in this attribute.
Users:
Where: /sys/bus/zio/devices/<zdev>/<cset>/<chan>/buffer/
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This is a collection of ZIO buffer attributes. It
contains both: standard attributes (described later) and
extended attributes defined by each driver (not described
in this document). This collection refers to a single
instance of a buffer implementation. Each buffer
implementation can decide to support or not the standard
attributes; if it supports the standard attributes it
works as described in this document.
Finally, remember that there is a buffer instance of the
same implementation for each channel within the same
channel-set of your devices
Note: The permission on the standard attributes depend on
the buffer implementation
Users:
Where: /sys/bus/zio/devices/<zdev>/<cset>/<chan>/buffer/version
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the version of the collection of
attributes that a buffer implementation exports. A
collection can change during the time. This attribute allow
an user-space program to recognize if it can work with a
particular version or not
Users:
Where: /sys/bus/zio/devices/<zdev>/<cset>/<chan>/buffer/max-buffer-len
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the maximum number of blocks that
the buffer instance can store.
Users:
Where: /sys/bus/zio/devices/<zdev>/<cset>/<chan>/buffer/max-buffer-kb
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the maximum kilo-byte of data (only
data not block) that the buffer instance can store.
Users:
Where: /sys/bus/zio/devices/<zdev>/
/sys/bus/zio/devices/<zdev>/<cset>/
/sys/bus/zio/devices/<zdev>/<cset>/<chan>/
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: These are collections of attributes of the ZIO device
hierarchy. Each collection contains both: standard
attributes (described later) and extended attributes
defined by each driver (not described in this document).
A standard attribute can appear *only* one time in the
device hierarchy (e.g. The attribute X can be in a <cset>,
but it cannot be, at the same time, in a <chan> or a <zdev>
level). In this documentation we indicate each attribute
at all level, but remember that it can be available only
in one level. If an attribute appears only on a single
level it means that it can leave only there.
Attributes that live in an high level automatically apply
the configuration on all lower levels.
This collection refers to a single instance of a device.
Each driver can decide to support or not the standard
attributes; if it supports the standard attributes it works
as described in this document.
Note: The permission on the standard attributes depend on
the driver implementation
Users:
Where: /sys/bus/zio/devices/<zdev>/version
/sys/bus/zio/devices/<zdev>/<cset>/version
/sys/bus/zio/devices/<zdev>/<cset>/<chan>/version
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the version of the collection of
attributes that a device driver exports. A
collection can change during the time. This attribute allow
an user-space program to recognize if it can work with a
particular version or not
Users:
Where: /sys/bus/zio/devices/<zdev>/gain_factor
/sys/bus/zio/devices/<zdev>/<cset>/gain_factor
/sys/bus/zio/devices/<zdev>/<cset>/<chan>/gain_factor
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the gain factor of an I/O signal.
Users:
Where: /sys/bus/zio/devices/<zdev>/offset
/sys/bus/zio/devices/<zdev>/<cset>/offset
/sys/bus/zio/devices/<zdev>/<cset>/<chan>/offset
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the offset to apply on an I/O
signal.
Users:
Where: /sys/bus/zio/devices/<zdev>/resolution-bits
/sys/bus/zio/devices/<zdev>/<cset>/resolution-bits
/sys/bus/zio/devices/<zdev>/<cset>/<chan>/resolution-bits
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the resolution bit of a digitalized
I/O signal.
Users:
Where: /sys/bus/zio/devices/<zdev>/max-sample-rate
/sys/bus/zio/devices/<zdev>/<cset>/max-sample-rate
/sys/bus/zio/devices/<zdev>/<cset>/<chan>/max-sample-rate
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the maximum sample rate of the I/O
signal.
Users:
Where: /sys/bus/zio/devices/<zdev>/vref-src
/sys/bus/zio/devices/<zdev>/<cset>/vref-src
/sys/bus/zio/devices/<zdev>/<cset>/<chan>/vref-src
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the Volt reference source for the I/O
signal.
Users:
Where: /sys/bus/zio/devices/<zdev>/<cset>/trigger/
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This is a collection of ZIO trigger attributes. It
contains both: standard attributes (described later) and
extended attributes defined by each driver (not described
in this document). This collection refers to a single
instance of a trigger implementation. Each trigger
implementation can decide to support or not the standard
attributes; if it supports the standard attributes it
works as described in this document.
Finally, remember that there is a trigger instance of the
same implementation for each channel-set of your devices
Note: The permission on the standard attributes depend on
the trigger implementation
Users:
Where: /sys/bus/zio/devices/<zdev>/<cset>/trigger/version
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the version of the collection of
attributes that a trigger implementation exports. A
collection can change during the time. This attribute allow
an user-space program to recognize if it can work with a
particular version or not
Users:
Where: /sys/bus/zio/devices/<zdev>/<cset>/trigger/nshots
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the number of consecutive shots that
a trigger must perform. The value '0' mean infinite; not
all trigger implementation supports this feature. If a
trigger does not support infinite shots, it must prevents
the user to set '0' in this attribute.
Users:
Where: /sys/bus/zio/devices/<zdev>/<cset>/trigger/pre-samples
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the number of pre-samples acquire for
each programmed shots.
Users:
Where: /sys/bus/zio/devices/<zdev>/<cset>/trigger/post-samples
Date: April 2013
Kernel Version: 3.x
Contact: zio@ohwr.org (mailing list)
Description: This attribute define the number of post-samples acquire for
each programmed shots.
Users:
LINUX ?= /lib/modules/$(shell uname -r)/build
zio-y := core.o chardev.o sysfs.o misc.o
zio-y += bus.o objects.o helpers.o dma.o
zio-y += buffers/zio-buf-kmalloc.o triggers/zio-trig-user.o
# Waiting for Kconfig...
CONFIG_ZIO_SNIFF_DEV:=y
zio-$(CONFIG_ZIO_SNIFF_DEV) += sniff-dev.o
obj-m = zio.o
obj-m += drivers/
obj-m += buffers/
obj-m += triggers/
GIT_VERSION = $(shell cd $(src); git describe --dirty --long --tags)
# For this CSM_VERSION, please see ohwr.org/csm documentation
ifdef CONFIG_CSM_VERSION
ccflags-y += -D"CERN_SUPER_MODULE=MODULE_VERSION(\"$(CONFIG_CSM_VERSION)\")"
else
ccflags-y += -DCERN_SUPER_MODULE=""
endif
# WARNING: the line below doesn't work in-kernel if you compile with O=
ccflags-y += -I$(src)/include/ -DGIT_VERSION=\"$(GIT_VERSION)\"
ccflags-$(CONFIG_ZIO_DEBUG) += -DDEBUG
all: modules tools
modules:
$(MAKE) -C $(LINUX) M=$(shell /bin/pwd)
modules_install:
$(MAKE) -C $(LINUX) M=$(shell /bin/pwd) $@
coccicheck:
$(MAKE) -C $(LINUX) M=$(shell /bin/pwd) coccicheck
.PHONY: tools
tools:
$(MAKE) -C tools M=$(shell /bin/pwd)
# this make clean is ugly, I'm aware...
clean:
rm -rf `find . -name \*.o -o -name \*.ko -o -name \*~ `
rm -rf `find . -name Module.\* -o -name \*.mod.c`
rm -rf .tmp_versions modules.order
$(MAKE) -C tools clean
Zio is "the ultimate I/O framework". It is being developed on the open
hardware repository at http://www.ohwr.org/projects/zio .
This version is known to compile and run with kernels 3.3 onwards
(it used to work from 2.6.34 onwards, and we may fix the dev.id issue
to restore such backward compatibility.
This README in not updated very often, so please take this information
with a grain of salt. The architecture of ZIO and the basic concepts
are explained on www.ohwr.org/projects/zio/ (in particular the "files"
and "documents" tabs).
To test zio you need to load the core module:
insmod zio.ko
By detault ZIO uses "kmalloc" as a buffer, it is a simple buffer that
hosts a list of data blocks, for either input or output.
The default trigger is called "user", and it fires data transfers when
the user reads or writes. We also have the "timer" trigger: it is a
kernel-timer based trigger, that fires a block transfer on a timely
basis. You can use the "ms" parameter to set the inter-block time, in
milliseconds (the default is two seconds). You can also pass the
"nsamples" parameter to say how many samples are acquired at each
trigger instance.
With the core in place, you can load a driver (we have several, this only
shows the basics of zio-zero for input):
insmod drivers/zio-zero.ko
zio-zero has three channel sets. cset 0 has three channels.
They simulate three analog inputs, 8-bits per sample.
channel 0: returns zero forever
channel 1: returns random numbers
channel 2: returns a sawtooth signal (0 to 255 and back)
The char devices are called using device-cset-channel:
/dev/zio/zzero-0-0-ctrl
/dev/zio/zzero-0-0-data
/dev/zio/zzero-0-1-ctrl
/dev/zio/zzero-0-1-data
/dev/zio/zzero-0-2-ctrl
/dev/zio/zzero-0-2-data
To read data you can just cat, or "od -t x1" the data device.
To get control information meta-information) together with data, you
can use the "zio-dump" user-space utility, in this directory.
For example:
./zio-dump /dev/zio/zzero-0-2-*
This is the result with a trigger that uses 2000 as msec and 32
as nsample:
./zio-dump /dev/zio/zzero-0-2-*
Ctrl: version 0.2, trigger timer, dev zzero, cset 0, chan 2
Ctrl: seq 1, n 32, size 1, bits 8, flags 01000001 (little-endian)
Ctrl: stamp 1320403540.084798370 (0)
Data: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
Data: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
Ctrl: version 0.2, trigger timer, dev zzero, cset 0, chan 2
Ctrl: seq 2, n 32, size 1, bits 8, flags 01000001 (little-endian)
Ctrl: stamp 1320403542.091093781 (0)
Data: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
Data: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
Ctrl: version 0.2, trigger timer, dev zzero, cset 0, chan 2
Ctrl: seq 3, n 32, size 1, bits 8, flags 01000001 (little-endian)
Ctrl: stamp 1320403544.084790274 (0)
Data: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
Data: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
zio-dump is able to access several pairs of devices (control and data),
and you can change the trigger and buffer attributes for the cset.
Example:
echo 500 > /sys/zio/devices/zzero/cset0/trigger/ms-period
echo 4 > /sys/zio/devices/zzero/cset0/trigger/nsamples
echo 3 > /sys/zio/devices/zzero/cset0/chan0/buffer/max-buffer-len
./zio-dump /dev/zzero-0-*
Ctrl: version 0.2, trigger timer, dev zzero, cset 0, chan 0
Ctrl: seq 102, n 4, size 1, bits 8, flags 01000001 (little-endian)
Ctrl: stamp 4066.519285605 (0)
Data: 00 00 00 00
Ctrl: version 0.2, trigger timer, dev zzero, cset 0, chan 1
Ctrl: seq 102, n 4, size 1, bits 8, flags 01000001 (little-endian)
Ctrl: stamp 4066.519285605 (0)
Data: 71 29 a6 53
Ctrl: version 0.2, trigger timer, dev zzero, cset 0, chan 2
Ctrl: seq 102, n 4, size 1, bits 8, flags 01000001 (little-endian)
Ctrl: stamp 4066.519285605 (0)
Data: 60 61 62 63
LINUX ?= /lib/modules/$(shell uname -r)/build
GIT_VERSION = $(shell cd $(src); git describe --dirty --long --tags)
# For this CSM_VERSION, please see ohwr.org/csm documentation
ifdef CONFIG_CSM_VERSION
ccflags-y += -D"CERN_SUPER_MODULE=MODULE_VERSION(\"$(CONFIG_CSM_VERSION)\")"
else
ccflags-y += -DCERN_SUPER_MODULE=""
endif
ccflags-y += -I$(src)/../include/ -DGIT_VERSION=\"$(GIT_VERSION)\"
ccflags-$(CONFIG_ZIO_DEBUG) += -DDEBUG
# zio-buf-kmalloc.o is now part of zio-core
obj-m = zio-buf-vmalloc.o
/* Alessandro Rubini for CERN, 2011, GNU GPLv2 or later */
/*
* This is a kmalloc-based buffer for the ZIO framework. It is used both
* as a default when no buffer is selected by applications and as an
* example about our our structures and methods are used.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/list.h>
#include <linux/err.h>
#include <linux/fs.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/zio.h>
#include <linux/zio-buffer.h>
#include <linux/zio-trigger.h>
#include <linux/zio-sysfs.h>
/* This is an instance of a buffer, associated to two cdevs */
struct zbk_instance {
struct zio_bi bi;
int nitem; /* allocated item */
struct list_head list; /* items list and lock */
};
#define to_zbki(bi) container_of(bi, struct zbk_instance, bi)
static struct kmem_cache *zbk_slab;
/* The list in the structure above collects a bunch of these */
struct zbk_item {
struct zio_block block;
struct list_head list; /* item list */
struct zbk_instance *instance;
size_t len; /* block.datalen may change, so save this */
};
#define to_item(block) container_of(block, struct zbk_item, block)
static ZIO_ATTR_DEFINE_STD(ZIO_BUF, zbk_std_zattr) = {
ZIO_ATTR(zbuf, ZIO_ATTR_ZBUF_MAXLEN, ZIO_RW_PERM,
ZIO_ATTR_ZBUF_MAXLEN, 16),
ZIO_ATTR(zbuf, ZIO_ATTR_ZBUF_ALLOC_LEN, ZIO_RO_PERM,
ZIO_ATTR_ZBUF_ALLOC_LEN, 0),
};
static int zbk_conf_set(struct device *dev, struct zio_attribute *zattr,
uint32_t usr_val)
{
struct zio_bi *bi = to_zio_bi(dev);
/* If somebody is sleeping for write and we increase the size... */
wake_up_interruptible(&bi->q);
return 0;
}
static int zbk_info_get(struct device *dev, struct zio_attribute *zattr,
uint32_t *usr_val)
{
struct zio_bi *bi = to_zio_bi(dev);
struct zbk_instance *zbki = to_zbki(bi);
switch (zattr->id) {
case ZIO_ATTR_ZBUF_ALLOC_LEN:
*usr_val = zbki->nitem;
break;
case ZIO_ATTR_ZBUF_MAXLEN:
default:
break;
}
return 0;
}
struct zio_sysfs_operations zbk_sysfs_ops = {
.conf_set = zbk_conf_set,
.info_get = zbk_info_get,
};
/* Alloc is called by the trigger (for input) or by f->write (for output) */
static struct zio_block *zbk_alloc_block(struct zio_bi *bi,
size_t datalen, gfp_t gfp)
{
struct zbk_instance *zbki = to_zbki(bi);
struct zbk_item *item;
struct zio_control *ctrl;
unsigned long flags;
void *data;
pr_debug("%s:%d\n", __func__, __LINE__);
/* alloc fails if we overflow the buffer size */
spin_lock_irqsave(&bi->lock, flags);
if (zbki->nitem >= zio_bi_std_val(bi, ZIO_ATTR_ZBUF_MAXLEN)) {
bi->flags |= ZIO_BI_NOSPACE;
goto out_unlock;
}
zbki->nitem++;
spin_unlock_irqrestore(&bi->lock, flags);
/* alloc item and data. Control remains null at this point */
item = kmem_cache_alloc(zbk_slab, gfp);
data = kmalloc(datalen, gfp);
ctrl = zio_alloc_control(gfp);
if (!item || !data || !ctrl)
goto out_free;
memset(item, 0, sizeof(*item));
item->block.data = data;
item->block.datalen = datalen;
item->len = datalen;
item->instance = zbki;
zio_set_ctrl(&item->block, ctrl);
return &item->block;
out_free:
kfree(data);
kmem_cache_free(zbk_slab, item);
zio_free_control(ctrl);
spin_lock_irqsave(&bi->lock, flags);
zbki->nitem--;
out_unlock:
spin_unlock_irqrestore(&bi->lock, flags);
return NULL;
}
/* Free is called by f->read (for input) or by the trigger (for output) */
static void zbk_free_block(struct zio_bi *bi, struct zio_block *block)
{
struct zbk_item *item;
struct zbk_instance *zbki;
unsigned long flags;
int awake = 0;
pr_debug("%s:%d\n", __func__, __LINE__);
item = to_item(block);
zbki = item->instance;
if (bi->flags & ZIO_BI_PUSHING) {
/* freed while pushing: we hold the bi lock already */
zbki->nitem--;
goto out_free;
}
spin_lock_irqsave(&bi->lock, flags);
if (((bi->flags & ZIO_DIR) == ZIO_DIR_OUTPUT) &&
zbki->nitem < zio_bi_std_val(bi, ZIO_ATTR_ZBUF_MAXLEN))
awake = 1;
bi->flags &= ~ZIO_BI_NOSPACE;
zbki->nitem--;
spin_unlock_irqrestore(&bi->lock, flags);
out_free:
kfree(block->data);
zio_free_control(zio_get_ctrl(block));
kmem_cache_free(zbk_slab, item);
if (awake)
wake_up_interruptible(&bi->q);
}
/* Store is called by the trigger (for input) or by f->write (for output) */
static int zbk_store_block(struct zio_bi *bi, struct zio_block *block)
{
struct zbk_instance *zbki = to_zbki(bi);
struct zio_channel *chan =