README.md 2.13 KB
Newer Older
Ton Damen's avatar
Ton Damen committed
1
KERNEL MODULE spec7
2
3
4
5
6
7
8
-------------------

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:

Ton Damen's avatar
Ton Damen committed
9
```
10
11
12
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
Ton Damen's avatar
Ton Damen committed
13
14
```

15
16
17
18

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

- /sys/bus/pci/devices/0000:01:00.0/deadbe
Ton Damen's avatar
Ton Damen committed
19

20
21
22
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
Ton Damen's avatar
Ton Damen committed
23

24
25
26
27
28
29
Gives file based access to the LM32 memory.

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

The module creates to file entries in /dev:
Ton Damen's avatar
Ton Damen committed
30
```
31
32
/dev/spec7_bar0
/dev/spec7_bar4
Ton Damen's avatar
Ton Damen committed
33
```
34
35
36
37
38
39
40

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:

Ton Damen's avatar
Ton Damen committed
41
`ioctl(fd, 0xdc01, 0)`
42
43
44
45
46
47
48
49
50
51
52
53
54
55

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:
 
Ton Damen's avatar
Ton Damen committed
56
`KERNEL=="spec7_*", MODE="0664", GROUP="spec7"`
57
58
59

To reload the udev config:

Ton Damen's avatar
Ton Damen committed
60
`# udevadm control --reload`
61
62
63

To add the group “spec7”

Ton Damen's avatar
Ton Damen committed
64
`# addgroup spec7`
65
66
67

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

Ton Damen's avatar
Ton Damen committed
68
`# usermod -a -G spec7 username`
69
70
71
72
73
74
75
76
77
78

Nb. reload the driver to effectuate the new configuration.


Ton Damen, tond@nilhef.nl
September 2021