本文主要是介绍Documentation/fmc/fmc-chardev.txt,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文交流有困难的话,也可以向中文版维护者求助。
如果本翻译更新不及时或者翻译存在问题,请联系中文版维护者。
中文版维护者: 陶莹莉 tyl18768122426@163.com
中文版翻译者: 陶莹莉 tyl18768122426@163.com
中文版校译者: 陶莹莉 tyl18768122426@163.com
fmc-chardev
===========
fmc字符设备
===========
This is a simple generic driver, that allows user access by means of a
character device (actually, one for each mezzanine it takes hold of).
这是一个简单通用的驱动程序,允许用户通过一个字符设备访问(实际上,为每个夹层它抓住了一个)。
The char device is created as a misc device. Its name in /dev (as
created by udev) is the same name as the underlying FMC device. Thus,
the name can be a silly fmc-0000 look-alike if the device has no
identifiers nor bus_id, a more specific fmc-0400 if the device has a
bus-specific address but no associated name, or something like
fdelay-0400 if the FMC core can rely on both a mezzanine name and a bus
address.
字符设备被创建为一个混杂的设备。它的名字在/dev(由udev创建)和作为底层的FMC装置是一样的。
因此,设备可以看起来是一个愚蠢的FMC-0000如果这个设备没有标识符也没有bus_id,
一个更特殊的FMC-0400是如果该设备有一个总线特定的地址,但没有相关的名称,或类似的东西
如果FMC核心可以依靠夹层名称和总线地址。
Currently the driver only supports read and write: you can lseek to the
desired address and read or write a register.
目前驱动程序仅支持读取和写入:你可以移动指针到所需的地址,读或写一个寄存器。
The driver assumes all registers are 32-bit in size, and only accepts a
single read or write per system call. However, as a result of Unix read
and write semantics, users can simply fread or fwrite bigger areas in
order to dump or store bigger memory areas.
驱动程序假定所有的寄存器是32位的大小,每个系统调用只接受
一个读或写。然而,作为Unix读取和写语义的结果,用户可以简单地用fread或者 fwrite实现更大的领域
用于倾倒或存放更大的内存区域。
There is currently no support for mmap, user-space interrupt management
and DMA buffers. They may be added in later versions, if the need
arises.
目前还没有支持内存文件映射的用户空间的中断管理和DMA缓冲区。这可能会加在以后的版本中,如果有需要
The example below shows raw access to a SPEC card programmed with its
golden FPGA file, that features an SDB structure at offset 256 - i.e.
64 words. The mezzanine's EEPROM in this case is not programmed, so the
default name is fmc-<bus><devfn>, and there are two cards in the system:
下面的例子显示了一个规范卡片的编程用他的可编程门阵列文件,其特点是在偏移256 - 即64个字的一个SDB结构。
夹层的只读存储器在这种情况下是不可编程的,所以默认名称是FMC-<bus><devfn>,在系统中有两个卡
spusa.root# insmod fmc-chardev.ko
[ 1073.339332] spec 0000:02:00.0: Driver has no ID: matches all
[ 1073.345051] spec 0000:02:00.0: Created misc device "fmc-0200"
[ 1073.350821] spec 0000:04:00.0: Driver has no ID: matches all
[ 1073.356525] spec 0000:04:00.0: Created misc device "fmc-0400"
spusa.root# ls -l /dev/fmc*
crw------- 1 root root 10, 58 Nov 20 19:23 /dev/fmc-0200
crw------- 1 root root 10, 57 Nov 20 19:23 /dev/fmc-0400
spusa.root# dd bs=4 skip=64 count=1 if=/dev/fmc-0200 2> /dev/null | od -t x1z
0000000 2d 42 44 53 >-BDS<
0000004
The simple program in this package can access an FMC char
device and read or write a word or a whole area. Actually, the program
is not specific to FMC at all, it just uses lseek, read and write.
这个包中的tools/fmc-mem这个简单的程序可以访问FMC字符设备并读取或写一个字
或整个区域。事实上,该程序并不是对所有的FMC都是特定的,它只是使用指针,来读取和写入。
Its first argument is the device name, the second the offset, the third
(if any) the value to write and the optional last argument that must
begin with "+" is the number of bytes to read or write. In case of
repeated reading data is written to stdout; repeated writes read from
stdin and the value argument is ignored.
它的第一个参数是设备名称,第二个是偏移量,第三个(如果有的话)的值用于写入,
可选的最后一个参数,必须以“+”开始是读取或写入的字节数。在这种情况下
重复读取数据写入到stdout;重复写入从stdin中读取的和参数值将被忽略。
The following examples show reading the SDB magic number and the first
SDB record from a SPEC device programmed with its golden image:
下面的例子显示读入存储数据缓冲器不可思议的数字和第一条SDB记录从SPEC设备用其金色的形象编程:
spusa.root# ./fmc-mem /dev/fmc-0200 100
5344422d
spusa.root# ./fmc-mem /dev/fmc-0200 100 +40 | od -Ax -t x1z
000000 2d 42 44 53 00 01 02 00 00 00 00 00 00 00 00 00 >-BDS............<
000010 00 00 00 00 ff 01 00 00 00 00 00 00 51 06 00 00 >............Q...<
000020 c9 42 a5 e6 02 00 00 00 11 05 12 20 2d 34 42 57 >.B......... -4BW<
000030 73 6f 72 43 72 61 62 73 49 53 47 2d 00 20 20 20 >sorCrabsISG-. <
000040
这篇关于Documentation/fmc/fmc-chardev.txt的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!