KERNEL MODULE spec7
-------------------

This kernel module supports the access of the PCI Axi4 memory of the SPEC7 card.
Currently the IP of the SPEC7 presents two bars: bar0 (1MB) and bar4 (16MB).

When the kernel module (spec7.ko) is loaded, the following should be seen among the kernel messages:

spec7:probe_one: PCI device id: [10ee:7022], address: 0000:01:00.0
spec7:probe_one: size bar0 = 1048576, bar4 = 16777216
spec7:spec7_module_init: loaded

The PCI address is here "0000:01:00.0" which gives the following sysfs entries:

- /sys/bus/pci/devices/0000:01:00.0/deadbe
Writing either '0' or '1' will write this values into the SYSCON register of the LM32.

- /sys/bus/pci/devices/0000:01:00.0/lm32_mem
Gives file based access to the LM32 memory.

BAR interfaces
--------------

The module creates to file entries in /dev:
/dev/spec7_bar0
/dev/spec7_bar4

These character devices supports access to the memory regions of each bar in a stream-like fashion through systems calls read() and write(). The region boundaries are protected by returning EOF when reading and EFAULT (invalid address) when writing beyond.

Both cp(3) and dd(3) can be used to transfer files to and from the bar memory regions.

The system call ioctl() can be used to query the size of the bar regions:

ioctl(fd, 0xdc01, 0)

returns the size in bytes.

Both devices implements also the mmap(2) system call, which enables the mapping of the BAR regions to user-space memory.

PERMISSIONS
------------

The default permissions for the device files are granted for root only. To customize this, an udev rules file must be created in /usr/lib/udev/rules.d.

This example gives users who are member of group “spec7” read-write access and others only read access:

file 60-spec7.rules contents:
 
KERNEL=="spec7_*", MODE="0664", GROUP="spec7"

To reload the udev config:

# udevadm control --reload

To add the group “spec7”

# addgroup spec7

To add a groups membership to an existing user the following command is given:

# usermod -a -G spec7 username

Nb. reload the driver to effectuate the new configuration.


Ton Damen, tond@nilhef.nl
September 2021




