162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci===== 462306a36Sopenharmony_cispufs 562306a36Sopenharmony_ci===== 662306a36Sopenharmony_ci 762306a36Sopenharmony_ciName 862306a36Sopenharmony_ci==== 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci spufs - the SPU file system 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ciDescription 1462306a36Sopenharmony_ci=========== 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci The SPU file system is used on PowerPC machines that implement the Cell 1762306a36Sopenharmony_ci Broadband Engine Architecture in order to access Synergistic Processor 1862306a36Sopenharmony_ci Units (SPUs). 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci The file system provides a name space similar to posix shared memory or 2162306a36Sopenharmony_ci message queues. Users that have write permissions on the file system 2262306a36Sopenharmony_ci can use spu_create(2) to establish SPU contexts in the spufs root. 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci Every SPU context is represented by a directory containing a predefined 2562306a36Sopenharmony_ci set of files. These files can be used for manipulating the state of the 2662306a36Sopenharmony_ci logical SPU. Users can change permissions on those files, but not actu- 2762306a36Sopenharmony_ci ally add or remove files. 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ciMount Options 3162306a36Sopenharmony_ci============= 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci uid=<uid> 3462306a36Sopenharmony_ci set the user owning the mount point, the default is 0 (root). 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci gid=<gid> 3762306a36Sopenharmony_ci set the group owning the mount point, the default is 0 (root). 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ciFiles 4162306a36Sopenharmony_ci===== 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci The files in spufs mostly follow the standard behavior for regular sys- 4462306a36Sopenharmony_ci tem calls like read(2) or write(2), but often support only a subset of 4562306a36Sopenharmony_ci the operations supported on regular file systems. This list details the 4662306a36Sopenharmony_ci supported operations and the deviations from the behaviour in the 4762306a36Sopenharmony_ci respective man pages. 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci All files that support the read(2) operation also support readv(2) and 5062306a36Sopenharmony_ci all files that support the write(2) operation also support writev(2). 5162306a36Sopenharmony_ci All files support the access(2) and stat(2) family of operations, but 5262306a36Sopenharmony_ci only the st_mode, st_nlink, st_uid and st_gid fields of struct stat 5362306a36Sopenharmony_ci contain reliable information. 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci All files support the chmod(2)/fchmod(2) and chown(2)/fchown(2) opera- 5662306a36Sopenharmony_ci tions, but will not be able to grant permissions that contradict the 5762306a36Sopenharmony_ci possible operations, e.g. read access on the wbox file. 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci The current set of files is: 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci /mem 6362306a36Sopenharmony_ci the contents of the local storage memory of the SPU. This can be 6462306a36Sopenharmony_ci accessed like a regular shared memory file and contains both code and 6562306a36Sopenharmony_ci data in the address space of the SPU. The possible operations on an 6662306a36Sopenharmony_ci open mem file are: 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci read(2), pread(2), write(2), pwrite(2), lseek(2) 6962306a36Sopenharmony_ci These operate as documented, with the exception that seek(2), 7062306a36Sopenharmony_ci write(2) and pwrite(2) are not supported beyond the end of the 7162306a36Sopenharmony_ci file. The file size is the size of the local storage of the SPU, 7262306a36Sopenharmony_ci which normally is 256 kilobytes. 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci mmap(2) 7562306a36Sopenharmony_ci Mapping mem into the process address space gives access to the 7662306a36Sopenharmony_ci SPU local storage within the process address space. Only 7762306a36Sopenharmony_ci MAP_SHARED mappings are allowed. 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci /mbox 8162306a36Sopenharmony_ci The first SPU to CPU communication mailbox. This file is read-only and 8262306a36Sopenharmony_ci can be read in units of 32 bits. The file can only be used in non- 8362306a36Sopenharmony_ci blocking mode and it even poll() will not block on it. The possible 8462306a36Sopenharmony_ci operations on an open mbox file are: 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci read(2) 8762306a36Sopenharmony_ci If a count smaller than four is requested, read returns -1 and 8862306a36Sopenharmony_ci sets errno to EINVAL. If there is no data available in the mail 8962306a36Sopenharmony_ci box, the return value is set to -1 and errno becomes EAGAIN. 9062306a36Sopenharmony_ci When data has been read successfully, four bytes are placed in 9162306a36Sopenharmony_ci the data buffer and the value four is returned. 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci /ibox 9562306a36Sopenharmony_ci The second SPU to CPU communication mailbox. This file is similar to 9662306a36Sopenharmony_ci the first mailbox file, but can be read in blocking I/O mode, and the 9762306a36Sopenharmony_ci poll family of system calls can be used to wait for it. The possible 9862306a36Sopenharmony_ci operations on an open ibox file are: 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci read(2) 10162306a36Sopenharmony_ci If a count smaller than four is requested, read returns -1 and 10262306a36Sopenharmony_ci sets errno to EINVAL. If there is no data available in the mail 10362306a36Sopenharmony_ci box and the file descriptor has been opened with O_NONBLOCK, the 10462306a36Sopenharmony_ci return value is set to -1 and errno becomes EAGAIN. 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci If there is no data available in the mail box and the file 10762306a36Sopenharmony_ci descriptor has been opened without O_NONBLOCK, the call will 10862306a36Sopenharmony_ci block until the SPU writes to its interrupt mailbox channel. 10962306a36Sopenharmony_ci When data has been read successfully, four bytes are placed in 11062306a36Sopenharmony_ci the data buffer and the value four is returned. 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci poll(2) 11362306a36Sopenharmony_ci Poll on the ibox file returns (POLLIN | POLLRDNORM) whenever 11462306a36Sopenharmony_ci data is available for reading. 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci /wbox 11862306a36Sopenharmony_ci The CPU to SPU communation mailbox. It is write-only and can be written 11962306a36Sopenharmony_ci in units of 32 bits. If the mailbox is full, write() will block and 12062306a36Sopenharmony_ci poll can be used to wait for it becoming empty again. The possible 12162306a36Sopenharmony_ci operations on an open wbox file are: write(2) If a count smaller than 12262306a36Sopenharmony_ci four is requested, write returns -1 and sets errno to EINVAL. If there 12362306a36Sopenharmony_ci is no space available in the mail box and the file descriptor has been 12462306a36Sopenharmony_ci opened with O_NONBLOCK, the return value is set to -1 and errno becomes 12562306a36Sopenharmony_ci EAGAIN. 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci If there is no space available in the mail box and the file descriptor 12862306a36Sopenharmony_ci has been opened without O_NONBLOCK, the call will block until the SPU 12962306a36Sopenharmony_ci reads from its PPE mailbox channel. When data has been read success- 13062306a36Sopenharmony_ci fully, four bytes are placed in the data buffer and the value four is 13162306a36Sopenharmony_ci returned. 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci poll(2) 13462306a36Sopenharmony_ci Poll on the ibox file returns (POLLOUT | POLLWRNORM) whenever 13562306a36Sopenharmony_ci space is available for writing. 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci /mbox_stat, /ibox_stat, /wbox_stat 13962306a36Sopenharmony_ci Read-only files that contain the length of the current queue, i.e. how 14062306a36Sopenharmony_ci many words can be read from mbox or ibox or how many words can be 14162306a36Sopenharmony_ci written to wbox without blocking. The files can be read only in 4-byte 14262306a36Sopenharmony_ci units and return a big-endian binary integer number. The possible 14362306a36Sopenharmony_ci operations on an open ``*box_stat`` file are: 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci read(2) 14662306a36Sopenharmony_ci If a count smaller than four is requested, read returns -1 and 14762306a36Sopenharmony_ci sets errno to EINVAL. Otherwise, a four byte value is placed in 14862306a36Sopenharmony_ci the data buffer, containing the number of elements that can be 14962306a36Sopenharmony_ci read from (for mbox_stat and ibox_stat) or written to (for 15062306a36Sopenharmony_ci wbox_stat) the respective mail box without blocking or resulting 15162306a36Sopenharmony_ci in EAGAIN. 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci /npc, /decr, /decr_status, /spu_tag_mask, /event_mask, /srr0 15562306a36Sopenharmony_ci Internal registers of the SPU. The representation is an ASCII string 15662306a36Sopenharmony_ci with the numeric value of the next instruction to be executed. These 15762306a36Sopenharmony_ci can be used in read/write mode for debugging, but normal operation of 15862306a36Sopenharmony_ci programs should not rely on them because access to any of them except 15962306a36Sopenharmony_ci npc requires an SPU context save and is therefore very inefficient. 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci The contents of these files are: 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci =================== =================================== 16462306a36Sopenharmony_ci npc Next Program Counter 16562306a36Sopenharmony_ci decr SPU Decrementer 16662306a36Sopenharmony_ci decr_status Decrementer Status 16762306a36Sopenharmony_ci spu_tag_mask MFC tag mask for SPU DMA 16862306a36Sopenharmony_ci event_mask Event mask for SPU interrupts 16962306a36Sopenharmony_ci srr0 Interrupt Return address register 17062306a36Sopenharmony_ci =================== =================================== 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci The possible operations on an open npc, decr, decr_status, 17462306a36Sopenharmony_ci spu_tag_mask, event_mask or srr0 file are: 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci read(2) 17762306a36Sopenharmony_ci When the count supplied to the read call is shorter than the 17862306a36Sopenharmony_ci required length for the pointer value plus a newline character, 17962306a36Sopenharmony_ci subsequent reads from the same file descriptor will result in 18062306a36Sopenharmony_ci completing the string, regardless of changes to the register by 18162306a36Sopenharmony_ci a running SPU task. When a complete string has been read, all 18262306a36Sopenharmony_ci subsequent read operations will return zero bytes and a new file 18362306a36Sopenharmony_ci descriptor needs to be opened to read the value again. 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci write(2) 18662306a36Sopenharmony_ci A write operation on the file results in setting the register to 18762306a36Sopenharmony_ci the value given in the string. The string is parsed from the 18862306a36Sopenharmony_ci beginning to the first non-numeric character or the end of the 18962306a36Sopenharmony_ci buffer. Subsequent writes to the same file descriptor overwrite 19062306a36Sopenharmony_ci the previous setting. 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci /fpcr 19462306a36Sopenharmony_ci This file gives access to the Floating Point Status and Control Regis- 19562306a36Sopenharmony_ci ter as a four byte long file. The operations on the fpcr file are: 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci read(2) 19862306a36Sopenharmony_ci If a count smaller than four is requested, read returns -1 and 19962306a36Sopenharmony_ci sets errno to EINVAL. Otherwise, a four byte value is placed in 20062306a36Sopenharmony_ci the data buffer, containing the current value of the fpcr regis- 20162306a36Sopenharmony_ci ter. 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci write(2) 20462306a36Sopenharmony_ci If a count smaller than four is requested, write returns -1 and 20562306a36Sopenharmony_ci sets errno to EINVAL. Otherwise, a four byte value is copied 20662306a36Sopenharmony_ci from the data buffer, updating the value of the fpcr register. 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_ci /signal1, /signal2 21062306a36Sopenharmony_ci The two signal notification channels of an SPU. These are read-write 21162306a36Sopenharmony_ci files that operate on a 32 bit word. Writing to one of these files 21262306a36Sopenharmony_ci triggers an interrupt on the SPU. The value written to the signal 21362306a36Sopenharmony_ci files can be read from the SPU through a channel read or from host user 21462306a36Sopenharmony_ci space through the file. After the value has been read by the SPU, it 21562306a36Sopenharmony_ci is reset to zero. The possible operations on an open signal1 or sig- 21662306a36Sopenharmony_ci nal2 file are: 21762306a36Sopenharmony_ci 21862306a36Sopenharmony_ci read(2) 21962306a36Sopenharmony_ci If a count smaller than four is requested, read returns -1 and 22062306a36Sopenharmony_ci sets errno to EINVAL. Otherwise, a four byte value is placed in 22162306a36Sopenharmony_ci the data buffer, containing the current value of the specified 22262306a36Sopenharmony_ci signal notification register. 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_ci write(2) 22562306a36Sopenharmony_ci If a count smaller than four is requested, write returns -1 and 22662306a36Sopenharmony_ci sets errno to EINVAL. Otherwise, a four byte value is copied 22762306a36Sopenharmony_ci from the data buffer, updating the value of the specified signal 22862306a36Sopenharmony_ci notification register. The signal notification register will 22962306a36Sopenharmony_ci either be replaced with the input data or will be updated to the 23062306a36Sopenharmony_ci bitwise OR of the old value and the input data, depending on the 23162306a36Sopenharmony_ci contents of the signal1_type, or signal2_type respectively, 23262306a36Sopenharmony_ci file. 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci /signal1_type, /signal2_type 23662306a36Sopenharmony_ci These two files change the behavior of the signal1 and signal2 notifi- 23762306a36Sopenharmony_ci cation files. The contain a numerical ASCII string which is read as 23862306a36Sopenharmony_ci either "1" or "0". In mode 0 (overwrite), the hardware replaces the 23962306a36Sopenharmony_ci contents of the signal channel with the data that is written to it. in 24062306a36Sopenharmony_ci mode 1 (logical OR), the hardware accumulates the bits that are subse- 24162306a36Sopenharmony_ci quently written to it. The possible operations on an open signal1_type 24262306a36Sopenharmony_ci or signal2_type file are: 24362306a36Sopenharmony_ci 24462306a36Sopenharmony_ci read(2) 24562306a36Sopenharmony_ci When the count supplied to the read call is shorter than the 24662306a36Sopenharmony_ci required length for the digit plus a newline character, subse- 24762306a36Sopenharmony_ci quent reads from the same file descriptor will result in com- 24862306a36Sopenharmony_ci pleting the string. When a complete string has been read, all 24962306a36Sopenharmony_ci subsequent read operations will return zero bytes and a new file 25062306a36Sopenharmony_ci descriptor needs to be opened to read the value again. 25162306a36Sopenharmony_ci 25262306a36Sopenharmony_ci write(2) 25362306a36Sopenharmony_ci A write operation on the file results in setting the register to 25462306a36Sopenharmony_ci the value given in the string. The string is parsed from the 25562306a36Sopenharmony_ci beginning to the first non-numeric character or the end of the 25662306a36Sopenharmony_ci buffer. Subsequent writes to the same file descriptor overwrite 25762306a36Sopenharmony_ci the previous setting. 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ciExamples 26162306a36Sopenharmony_ci======== 26262306a36Sopenharmony_ci /etc/fstab entry 26362306a36Sopenharmony_ci none /spu spufs gid=spu 0 0 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ciAuthors 26762306a36Sopenharmony_ci======= 26862306a36Sopenharmony_ci Arnd Bergmann <arndb@de.ibm.com>, Mark Nutter <mnutter@us.ibm.com>, 26962306a36Sopenharmony_ci Ulrich Weigand <Ulrich.Weigand@de.ibm.com> 27062306a36Sopenharmony_ci 27162306a36Sopenharmony_ciSee Also 27262306a36Sopenharmony_ci======== 27362306a36Sopenharmony_ci capabilities(7), close(2), spu_create(2), spu_run(2), spufs(7) 274