示例

/etc/fstabentry
无/ spu spufs gid = spu 0 0

另外参见

close(2),spu_create(2),spu_run(2),功能(7)

小区宽带引擎架构(CBEA)规范

出版信息

这个页面是Linux手册页项目5.08版的一部分。有关项目的说明、有关报告错误的信息以及此页面的最新版本,请访问https://www.kernel.org/doc/man-pages/

名称

spufs-SPU文件系统

SPUFS - Linux手册页

Linux程序员手册 第7部分
更新日期: 2020-06-09

说明

SPU文件系统在实现单元宽带引擎体系结构的PowerPC机器上使用,以便访问协同处理器单元(SPU)。

文件系统提供的名称空间类似于POSIX共享内存或消息队列。对文件系统具有写权限的用户可以使用spu_create(2)在spufs根目录下建立SPU上下文。

每个SPU上下文由包含预定义文件集的目录表示。这些文件可用于操纵逻辑SPU的状态。用户可以更改文件的权限,但不能添加或删除文件。

Mount options

uid=<uid>
设置拥有挂载点的用户;默认值为0(根)。
gid=<gid>
设置拥有安装点的组;默认值为0(根)。
mode=<mode>
将spufs中的顶级目录的模式设置为八进制模式字符串。默认值为0775。

Files

spufs中的文件大多遵循常规系统调用(例如read(2)或write(2))的标准行为,但通常仅支持常规文件系统支持的部分操作。该列表详细说明了受支持的操作以及与相应手册页中描述的标准行为的偏差。

所有支持read(2)操作的文件也都支持readv(2),所有支持write(2)操作的文件也都支持writev(2)。所有文件都支持access(2)和stat(2)系列操作,但是对于后面的调用,返回的stat结构中唯一包含可靠信息的字段是st_modest_nlink,st_uid和st_gid。

所有文件都支持chmod(2)/ fchmod(2)和chown(2)/ fchown(2)操作,但是将无法授予与可能的操作相冲突的权限(例如,对wbox文件的读取访问权限)。

当前文件集为:

/capabilities
Contains a comma-delimited string representing the capabilities of this SPU context. Possible capabilities are:
sched
可以安排该上下文。
step
可以在单步模式下运行此上下文以进行调试。

将来可能会添加新的功能标志。

/mem
the contents of the local storage memory of the SPU. This can be accessed like a regular shared memory file and contains both code and data in the address space of the SPU. The possible operations on an open mem

file are:

read(2), pread(2), write(2), pwrite(2), lseek(2)
除了文件末尾不支持lseek(2),write(2)和pwrite(2)之外,这些操作照常进行。文件大小是SPU本地存储的大小,通常为256 KB。
mmap(2)
通过将mem映射到进程地址空间,可以访问进程地址空间内的SPU本地存储。仅允许MAP_SHARED映射。
/regs
包含SPU上下文的已保存通用寄存器。该文件按顺序包含从寄存器0到寄存器127的每个寄存器的128位值。这允许检查通用寄存器以进行调试。
读取或写入该文件要求安排上下文,因此在正常程序操作中建议不要使用此文件。
在使用SPU_CREATE_NOSCHED标志创建的上下文中不存在regs文件。
/mbox
The first SPU-to-CPU communication mailbox. This file is read-only and can be read in units of 4 bytes. The file can be used only in nonblocking mode - even poll(2)

cannot be used to block on this file.
The only possible operation on an open
mbox

file is:

read(2)
如果count小于4,则read(2)返回-1并将errno设置为EINVAL。如果邮箱中没有可用数据(即SPU尚未发送邮箱消息),则将返回值设置为-1,并将errno设置为EAGAIN。成功读取数据后,将四个字节放入数据缓冲区,并返回值四。
/ibox
第二个SPU到CPU的通信邮箱。该文件类似于第一个邮箱文件,但是可以在阻止I / O模式下读取,因此,在打开的ibox文件上调用read(2)将会阻止,直到SPU将数据写入其中断邮箱通道为止(除非该文件具有使用O_NONBLOCK打开,请参见下文)。此外,poll(2)和类似的系统调用可用于监视邮箱数据的存在。
The possible operations on an open ibox

file are:

read(2)
如果count小于4,则read(2)返回-1并将errno设置为EINVAL。如果邮箱中没有可用数据,并且使用O_NONBLOCK打开了文件描述符,则返回值设置为-1,而errno设置为EAGAIN。
如果邮箱中没有可用数据,并且在没有O_NONBLOCK的情况下打开了文件描述符,则调用将一直阻塞,直到SPU写入其中断邮箱通道。成功读取数据后,将四个字节放入数据缓冲区,并返回值四。
poll(2)
只要有可读取的数据,对ibox文件的轮询就会返回(POLLIN | POLLRDNORM)。
/wbox
The CPU-to-SPU communication mailbox. It is write-only and can be written in units of four bytes. If the mailbox is full, write(2)

will block, and
poll(2)

can be used to block until the mailbox is available for writing again.
The possible operations on an open
wbox

file are:

write(2)
如果count小于4,则write(2)返回-1并将errno设置为EINVAL。如果邮箱中没有可用空间,并且已使用O_NONBLOCK打开文件描述符,则将返回值设置为-1,并将errno设置为EAGAIN。
如果邮箱中没有可用空间,并且在没有O_NONBLOCK的情况下打开了文件描述符,则调用将一直阻塞,直到SPU从其PPE(PowerPC处理元素)邮箱通道读取数据为止。成功写入数据后,系统调用将返回四作为其函数结果。
poll(2)
只要有足够的写空间,对wbox文件的轮询将返回(POLLOUT | POLLWRNORM)。
/mbox_stat, /ibox_stat, /wbox_stat
These are read-only files that contain the length of the current queue of each mailbox---that is, how many words can be read from mboxor ibox

or how many words can be written to
wbox

without blocking.
The files can be read only in four-byte units and return
a big-endian binary integer number.
The only possible operation on an open
*box_stat

file is:

read(2)
如果count小于4,则read(2)返回-1并将errno设置为EINVAL。否则,将在数据缓冲区中放置一个四字节的值。此值是可以从(对于mbox_stat和ibox_stat)读取或写入(对于wbox_stat)相应邮箱而不会阻塞或返回EAGAIN错误的元素数。
/npc, /decr, /decr_status, /spu_tag_mask, /event_mask, /event_status, /srr0, /lslr
SPU的内部寄存器。这些文件包含一个ASCII字符串,表示指定寄存器的十六进制值。对这些文件的读写(npc除外,请参见下文)要求将SPU上下文安排好,因此建议不要在正常程序操作中频繁访问这些文件。
The contents of these files are:
npc
下一个程序计数器-仅在SPU处于停止状态时有效。
decr
SPU减量器
decr_status
递减器状态
spu_tag_mask
SPU DMA的MFC标签屏蔽
event_mask
SPU中断的事件掩码
event_status
待处理的SPU事件数(只读)
srr0
中断返回地址寄存器
lslr
本地商店限制记录
The possible operations on these files are:
read(2)
读取当前寄存器值。如果寄存器值大于传递给read(2)系统调用的缓冲区,则后续读取将继续从同一缓冲区读取,直到到达缓冲区末尾。
读取完整的字符串后,所有后续读取操作将返回零字节,并且需要打开新的文件描述符以读取新值。
write(2)
对文件的write(2)操作会将寄存器设置为字符串中给定的值。该字符串从头开始解析,直到第一个非数字字符或缓冲区的末尾。随后对同一文件描述符的写入将覆盖先前的设置。
除npc文件外,这些文件不存在于使用SPU_CREATE_NOSCHED标志创建的上下文中。
/fpcr
This file provides access to the Floating Point Status and Control Register (fcpr) as a binary, four-byte file. The operations on the fpcr

file are:

read(2)
如果count小于4,则read(2)返回-1并将errno设置为EINVAL。否则,将在数据缓冲区中放置一个四字节值;这是fpcr寄存器的当前值。
write(2)
如果count小于4,则write(2)返回-1并将errno设置为EINVAL。否则,将从数据缓冲区复制一个四字节的值,从而更新fpcr寄存器的值。
/signal1, /signal2
The files provide access to the two signal notification channels of an SPU. These are read-write files that operate on four-byte words. Writing to one of these files triggers an interrupt on the SPU. The value written to the signal files can be read from the SPU through a channel read or from host user space through the file. After the value has been read by the SPU, it is reset to zero. The possible operations on an open signal1

or
signal2

file are:

read(2)
如果count小于4,则read(2)返回-1并将errno设置为EINVAL。否则,将在数据缓冲区中放置一个四字节值;这是指定信号通知寄存器的当前值。
write(2)
如果count小于4,则write(2)返回-1并将errno设置为EINVAL。否则,将从数据缓冲区复制一个四字节的值,从而更新指定信号通知寄存器的值。信号通知寄存器将被输入数据替换,或者将被更新为旧值和输入数据的按位或运算,这分别取决于signal1_type或signal2_type文件的内容。
/signal1_type, /signal2_type
These two files change the behavior of the signal1

and
signal2

notification files.
They contain a numeric ASCII string which is read
as either "1" or "0".
In mode 0 (overwrite), the hardware replaces the contents
of the signal channel with the data that is written to it.
In mode 1 (logical OR), the hardware accumulates the bits
that are subsequently written to it.
The possible operations on an open
signal1_type

or
signal2_type

file are:

read(2)
当提供给read(2)调用的计数短于该数字所需的长度(加上换行符)时,从同一文件描述符进行的后续读取将完成该字符串。读取完整的字符串后,所有后续读取操作将返回零字节,并且需要打开新的文件描述符以再次读取该值。
write(2)
对文件的write(2)操作会将寄存器设置为字符串中给定的值。该字符串从头开始解析,直到第一个非数字字符或缓冲区的末尾。随后对同一文件描述符的写入将覆盖先前的设置。
/mbox_info, /ibox_info, /wbox_info, /dma_into, /proxydma_info
包含SPU邮箱和DMA队列的已保存状态的只读文件。这允许检查SPU状态,主要用于调试。 mbox_info和ibox_info文件每个都包含SPU写入的四字节邮箱消息。如果没有消息写入这些邮箱,则这些文件的内容是不确定的。 mbox_stat,ibox_stat和wbox_stat文件包含可用的邮件数。
wbox_info文件包含一个四字节的邮箱消息数组,这些消息已发送到SPU。在当前的CBEA机器中,数组的长度为4个项目,因此最多可以从该文件读取4 * 4 = 16个字节。如果任何邮箱队列条目为空,则未定义在相应位置读取的字节。
dma_info文件包含SPU MFC DMA队列的内容,表示为以下结构:
struct spu_dma_info {
    uint64_t         dma_info_type;
    uint64_t         dma_info_mask;
    uint64_t         dma_info_status;
    uint64_t         dma_info_stall_and_notify;
    uint64_t         dma_info_atomic_command_status;
    struct mfc_cq_sr dma_info_command_data[16];
};
该数据结构的最后一个成员是实际的DMA队列,其中包含16个条目。 mfc_cq_sr结构定义为:
struct mfc_cq_sr {
    uint64_t mfc_cq_data0_RW;
    uint64_t mfc_cq_data1_RW;
    uint64_t mfc_cq_data2_RW;
    uint64_t mfc_cq_data3_RW;
};
proxydma_info文件包含类似的信息,但是描述了代理DMA队列(即,由SPU外部实体发起的DMA)。该文件的格式如下:
struct spu_proxydma_info {
    uint64_t         proxydma_info_type;
    uint64_t         proxydma_info_mask;
    uint64_t         proxydma_info_status;
    struct mfc_cq_sr proxydma_info_command_data[8];
};
访问这些文件要求将SPU上下文安排在外-频繁使用可能效率低下。这些文件不应用于正常的程序操作。
这些文件不存在于使用SPU_CREATE_NOSCHED标志创建的上下文中。
/cntl
This file provides access to the SPU Run Control and SPU status registers, as an ASCII string. The following operations are supported:
read(2)
从cntl文件读取将返回带有SPU状态寄存器的十六进制值的ASCII字符串。
write(2)
写入cntl文件将设置上下文的SPU运行控制寄存器。
/mfc
Provides access to the Memory Flow Controller of the SPU. Reading from the file returns the contents of the SPU's MFC Tag Status register, and writing to the file initiates a DMA from the MFC. The following operations are supported:
write(2)
写入该文件必须采用MFC DMA命令的格式,定义如下:
struct mfc_dma_command {
    int32_t  pad;    /* reserved */
    uint32_t lsa;    /* local storage address */
    uint64_t ea;     /* effective address */
    uint16_t size;   /* transfer size */
    uint16_t tag;    /* command tag */
    uint16_t class;  /* class ID */
    uint16_t cmd;    /* command opcode */
};
要求写入的大小正好为sizeof(struct mfc_dma_command)个字节。该命令将被发送到SPU的MFC代理队列,并将标记存储在内核中(请参见下文)。
read(2)
读取标签状态寄存器的内容。如果以阻止模式打开文件(即不使用O_NONBLOCK),则读取将被阻止直到DMA标记(由上一次写入执行)完成为止。在非阻塞模式下,将不等待返回MFC标签状态寄存器。
poll(2)
在mfc文件上调用poll(2)将阻塞,直到可以启动新的DMA(通过检查POLLOUT)或直到先前启动的DMA(通过检查POLLIN)完成为止。
/ mss提供对MFC多源同步(MSS)工具的访问。通过mmap(2)处理此文件,进程可以访问SPU的MSS区域。
支持以下操作:
mmap(2)
通过将mss映射到进程地址空间,可以访问进程地址空间内的SPU MSS区域。仅允许MAP_SHARED映射。
/psmap
提供对SPU整个问题状态映射的访问。应用程序可以使用此区域连接到SPU,而不用写入spufs中的单个寄存器文件。
The following operations are supported:
mmap(2)
映射psmap为进程提供了SPU问题状态区域的直接映射。仅支持MAP_SHARED映射。
/phys-id
只读文件,其中包含运行SPU上下文的物理SPU编号。当上下文未运行时,此文件包含字符串" -1"。
物理SPU编号由ASCII十六进制字符串给出。
/object-id
Allows applications to store (or retrieve) a single 64-bit ID into the context. This ID is later used by profiling tools to uniquely identify the context.
write(2)
通过将ASCII十六进制值写入此文件,应用程序可以设置SPU上下文的对象ID。对象ID的所有先前值都将被覆盖。
read(2)
读取此文件将给出一个ASCII十六进制字符串,表示此SPU上下文的对象ID。
日期:2019-08-20 18:02:02 来源:oir作者:oir