spufs

Name

spufs - the SPU file system

Description

The SPU file system is used on PowerPC machines that implement the CellBroadband Engine Architecture in order to access Synergistic ProcessorUnits (SPUs).

The file system provides a name space similar to posix shared memory ormessage queues. Users that have write permissions on the file systemcan use spu_create(2) to establish SPU contexts in the spufs root.

Every SPU context is represented by a directory containing a predefinedset of files. These files can be used for manipulating the state of thelogical SPU. Users can change permissions on those files, but not actu-ally add or remove files.

Mount Options

uid=<uid>

set the user owning the mount point, the default is 0 (root).

gid=<gid>

set the group owning the mount point, the default is 0 (root).

Files

The files in spufs mostly follow the standard behavior for regular sys-tem calls like read(2) or write(2), but often support only a subset ofthe operations supported on regular file systems. This list details thesupported operations and the deviations from the behaviour in therespective man pages.

All files that support the read(2) operation also support readv(2) andall files that support the write(2) operation also support writev(2).All files support the access(2) and stat(2) family of operations, butonly the st_mode, st_nlink, st_uid and st_gid fields ofstructstatcontain reliable information.

All files support the chmod(2)/fchmod(2) and chown(2)/fchown(2) opera-tions, but will not be able to grant permissions that contradict thepossible operations, e.g. read access on the wbox file.

The current set of files is:

/mem

the contents of the local storage memory of the SPU. This can beaccessed like a regular shared memory file and contains both code anddata in the address space of the SPU. The possible operations on anopen mem file are:

read(2), pread(2), write(2), pwrite(2), lseek(2)

These operate as documented, with the exception that seek(2),write(2) and pwrite(2) are not supported beyond the end of thefile. The file size is the size of the local storage of the SPU,which normally is 256 kilobytes.

mmap(2)

Mapping mem into the process address space gives access to theSPU local storage within the process address space. OnlyMAP_SHARED mappings are allowed.

/mbox

The first SPU to CPU communication mailbox. This file is read-only andcan be read in units of 32 bits. The file can only be used in non-blocking mode and it even poll() will not block on it. The possibleoperations on an open mbox file are:

read(2)

If a count smaller than four is requested, read returns -1 andsets errno to EINVAL. If there is no data available in the mailbox, the return value is set to -1 and errno becomes EAGAIN.When data has been read successfully, four bytes are placed inthe data buffer and the value four is returned.

/ibox

The second SPU to CPU communication mailbox. This file is similar tothe first mailbox file, but can be read in blocking I/O mode, and thepoll family of system calls can be used to wait for it. The possibleoperations on an open ibox file are:

read(2)

If a count smaller than four is requested, read returns -1 andsets errno to EINVAL. If there is no data available in the mailbox and the file descriptor has been opened with O_NONBLOCK, thereturn value is set to -1 and errno becomes EAGAIN.

If there is no data available in the mail box and the filedescriptor has been opened without O_NONBLOCK, the call willblock until the SPU writes to its interrupt mailbox channel.When data has been read successfully, four bytes are placed inthe data buffer and the value four is returned.

poll(2)

Poll on the ibox file returns (POLLIN | POLLRDNORM) wheneverdata is available for reading.

/wbox

The CPU to SPU communation mailbox. It is write-only and can be writtenin units of 32 bits. If the mailbox is full, write() will block andpoll can be used to wait for it becoming empty again. The possibleoperations on an open wbox file are: write(2) If a count smaller thanfour is requested, write returns -1 and sets errno to EINVAL. If thereis no space available in the mail box and the file descriptor has beenopened with O_NONBLOCK, the return value is set to -1 and errno becomesEAGAIN.

If there is no space available in the mail box and the file descriptorhas been opened without O_NONBLOCK, the call will block until the SPUreads from its PPE mailbox channel. When data has been read success-fully, four bytes are placed in the data buffer and the value four isreturned.

poll(2)

Poll on the ibox file returns (POLLOUT | POLLWRNORM) wheneverspace is available for writing.

/mbox_stat,/ibox_stat,/wbox_stat

Read-only files that contain the length of the current queue, i.e. howmany words can be read from mbox or ibox or how many words can bewritten to wbox without blocking. The files can be read only in 4-byteunits and return a big-endian binary integer number. The possibleoperations on an open*box_stat file are:

read(2)

If a count smaller than four is requested, read returns -1 andsets errno to EINVAL. Otherwise, a four byte value is placed inthe data buffer, containing the number of elements that can beread from (for mbox_stat and ibox_stat) or written to (forwbox_stat) the respective mail box without blocking or resultingin EAGAIN.

/npc,/decr,/decr_status,/spu_tag_mask,/event_mask,/srr0

Internal registers of the SPU. The representation is an ASCII stringwith the numeric value of the next instruction to be executed. Thesecan be used in read/write mode for debugging, but normal operation ofprograms should not rely on them because access to any of them exceptnpc requires an SPU context save and is therefore very inefficient.

The contents of these files are:

npc

Next Program Counter

decr

SPU Decrementer

decr_status

Decrementer Status

spu_tag_mask

MFC tag mask for SPU DMA

event_mask

Event mask for SPU interrupts

srr0

Interrupt Return address register

The possible operations on an open npc, decr, decr_status,spu_tag_mask, event_mask or srr0 file are:

read(2)

When the count supplied to the read call is shorter than therequired length for the pointer value plus a newline character,subsequent reads from the same file descriptor will result incompleting the string, regardless of changes to the register bya running SPU task. When a complete string has been read, allsubsequent read operations will return zero bytes and a new filedescriptor needs to be opened to read the value again.

write(2)

A write operation on the file results in setting the register tothe value given in the string. The string is parsed from thebeginning to the first non-numeric character or the end of thebuffer. Subsequent writes to the same file descriptor overwritethe previous setting.

/fpcr

This file gives access to the Floating Point Status and Control Regis-ter as a four byte long file. The operations on the fpcr file are:

read(2)

If a count smaller than four is requested, read returns -1 andsets errno to EINVAL. Otherwise, a four byte value is placed inthe data buffer, containing the current value of the fpcr regis-ter.

write(2)

If a count smaller than four is requested, write returns -1 andsets errno to EINVAL. Otherwise, a four byte value is copiedfrom the data buffer, updating the value of the fpcr register.

/signal1,/signal2

The two signal notification channels of an SPU. These are read-writefiles that operate on a 32 bit word. Writing to one of these filestriggers an interrupt on the SPU. The value written to the signalfiles can be read from the SPU through a channel read or from host userspace through the file. After the value has been read by the SPU, itis reset to zero. The possible operations on an open signal1 or sig-nal2 file are:

read(2)

If a count smaller than four is requested, read returns -1 andsets errno to EINVAL. Otherwise, a four byte value is placed inthe data buffer, containing the current value of the specifiedsignal notification register.

write(2)

If a count smaller than four is requested, write returns -1 andsets errno to EINVAL. Otherwise, a four byte value is copiedfrom the data buffer, updating the value of the specified signalnotification register. The signal notification register willeither be replaced with the input data or will be updated to thebitwise OR of the old value and the input data, depending on thecontents of the signal1_type, or signal2_type respectively,file.

/signal1_type,/signal2_type

These two files change the behavior of the signal1 and signal2 notifi-cation files. The contain a numerical ASCII string which is read aseither “1” or “0”. In mode 0 (overwrite), the hardware replaces thecontents of the signal channel with the data that is written to it. inmode 1 (logical OR), the hardware accumulates the bits that are subse-quently written to it. The possible operations on an open signal1_typeor signal2_type file are:

read(2)

When the count supplied to the read call is shorter than therequired length for the digit plus a newline character, subse-quent reads from the same file descriptor will result in com-pleting the string. When a complete string has been read, allsubsequent read operations will return zero bytes and a new filedescriptor needs to be opened to read the value again.

write(2)

A write operation on the file results in setting the register tothe value given in the string. The string is parsed from thebeginning to the first non-numeric character or the end of thebuffer. Subsequent writes to the same file descriptor overwritethe previous setting.

Examples

/etc/fstab entry

none /spu spufs gid=spu 0 0

Authors

Arnd Bergmann <arndb@de.ibm.com>, Mark Nutter <mnutter@us.ibm.com>,Ulrich Weigand <Ulrich.Weigand@de.ibm.com>

See Also

capabilities(7), close(2), spu_create(2), spu_run(2), spufs(7)