The file system provides a name space similar to POSIX shared memory or message queues. Users that have write permissions on the file system can use spu_create(2) to establish SPU contexts under the spufs root directory.
Every SPU context is represented by a directory containing a predefined set of files. These files can be used for manipulating the state of the logical SPU. Users can change permissions on the files, but can't add or remove files.
All files that support the read(2) operation also support readv(2) and all files that support the write(2) operation also support writev(2). All files support the access(2) and stat(2) family of operations, but for the latter call, the only fields of the returned stat structure that contain reliable information are st_mode, st_nlink, st_uid, and st_gid.
All files support the chmod(2)/fchmod(2) and chown(2)/fchown(2) operations, but will not be able to grant permissions that contradict the possible operations (e.g., read access on the wbox file).
The current set of files is:
New capabilities flags may be added in the future.
Reading to or writing from this file requires that the context is scheduled out, so use of this file is not recommended in normal program operation.
The regs file is not present on contexts that have been created with the SPU_CREATE_NOSCHED flag.
The possible operations on an open ibox file are:
If there is no data available in the mailbox and the file descriptor has been opened without O_NONBLOCK, the call will block until the SPU writes to its interrupt mailbox channel. When data has been read successfully, four bytes are placed in the data buffer and the value four is returned.
If there is no space available in the mailbox and the file descriptor has been opened without O_NONBLOCK, the call will block until the SPU reads from its PPE (PowerPC Processing Element) mailbox channel. When data has been written successfully, the system call returns four as its function result.
When a complete string has been read, all subsequent read operations will return zero bytes and a new file descriptor needs to be opened to read a new value.
Except for the npc file, these files are not present on contexts that have been created with the SPU_CREATE_NOSCHED flag.
The wbox_info file contains an array of four-byte mailbox messages, which have been sent to the SPU. With current CBEA machines, the array is four items in length, so up to 4 * 4 = 16 bytes can be read from this file. If any mailbox queue entry is empty, then the bytes read at the corresponding location are undefined.
The dma_info file contains the contents of the SPU MFC DMA queue, represented as the following structure:
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]; };
The last member of this data structure is the actual DMA queue, containing 16 entries. The mfc_cq_sr structure is defined as:
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; };
The proxydma_info file contains similar information, but describes the proxy DMA queue (i.e., DMAs initiated by entities outside the SPU) instead. The file is in the following format:
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]; };
Accessing these files requires that the SPU context is scheduled out - frequent use can be inefficient. These files should not be used for normal program operation.
These files are not present on contexts that have been created with the SPU_CREATE_NOSCHED flag.
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 */ };
Writes are required to be exactly sizeof(struct mfc_dma_command) bytes in size. The command will be sent to the SPU's MFC proxy queue, and the tag stored in the kernel (see below).
/mss Provides access to the MFC MultiSource Synchronization (MSS) facility. By mmap(2)-ing this file, processes can access the MSS area of the SPU.
The following operations are supported:
The following operations are supported:
The physical SPU number is given by an ASCII hex string.