spufs.txt 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. SPUFS(2) Linux Programmer's Manual SPUFS(2)
  2. NAME
  3. spufs - the SPU file system
  4. DESCRIPTION
  5. The SPU file system is used on PowerPC machines that implement the Cell
  6. Broadband Engine Architecture in order to access Synergistic Processor
  7. Units (SPUs).
  8. The file system provides a name space similar to posix shared memory or
  9. message queues. Users that have write permissions on the file system
  10. can use spu_create(2) to establish SPU contexts in the spufs root.
  11. Every SPU context is represented by a directory containing a predefined
  12. set of files. These files can be used for manipulating the state of the
  13. logical SPU. Users can change permissions on those files, but not actu-
  14. ally add or remove files.
  15. MOUNT OPTIONS
  16. uid=<uid>
  17. set the user owning the mount point, the default is 0 (root).
  18. gid=<gid>
  19. set the group owning the mount point, the default is 0 (root).
  20. FILES
  21. The files in spufs mostly follow the standard behavior for regular sys-
  22. tem calls like read(2) or write(2), but often support only a subset of
  23. the operations supported on regular file systems. This list details the
  24. supported operations and the deviations from the behaviour in the
  25. respective man pages.
  26. All files that support the read(2) operation also support readv(2) and
  27. all files that support the write(2) operation also support writev(2).
  28. All files support the access(2) and stat(2) family of operations, but
  29. only the st_mode, st_nlink, st_uid and st_gid fields of struct stat
  30. contain reliable information.
  31. All files support the chmod(2)/fchmod(2) and chown(2)/fchown(2) opera-
  32. tions, but will not be able to grant permissions that contradict the
  33. possible operations, e.g. read access on the wbox file.
  34. The current set of files is:
  35. /mem
  36. the contents of the local storage memory of the SPU. This can be
  37. accessed like a regular shared memory file and contains both code and
  38. data in the address space of the SPU. The possible operations on an
  39. open mem file are:
  40. read(2), pread(2), write(2), pwrite(2), lseek(2)
  41. These operate as documented, with the exception that seek(2),
  42. write(2) and pwrite(2) are not supported beyond the end of the
  43. file. The file size is the size of the local storage of the SPU,
  44. which normally is 256 kilobytes.
  45. mmap(2)
  46. Mapping mem into the process address space gives access to the
  47. SPU local storage within the process address space. Only
  48. MAP_SHARED mappings are allowed.
  49. /mbox
  50. The first SPU to CPU communication mailbox. This file is read-only and
  51. can be read in units of 32 bits. The file can only be used in non-
  52. blocking mode and it even poll() will not block on it. The possible
  53. operations on an open mbox file are:
  54. read(2)
  55. If a count smaller than four is requested, read returns -1 and
  56. sets errno to EINVAL. If there is no data available in the mail
  57. box, the return value is set to -1 and errno becomes EAGAIN.
  58. When data has been read successfully, four bytes are placed in
  59. the data buffer and the value four is returned.
  60. /ibox
  61. The second SPU to CPU communication mailbox. This file is similar to
  62. the first mailbox file, but can be read in blocking I/O mode, and the
  63. poll family of system calls can be used to wait for it. The possible
  64. operations on an open ibox file are:
  65. read(2)
  66. If a count smaller than four is requested, read returns -1 and
  67. sets errno to EINVAL. If there is no data available in the mail
  68. box and the file descriptor has been opened with O_NONBLOCK, the
  69. return value is set to -1 and errno becomes EAGAIN.
  70. If there is no data available in the mail box and the file
  71. descriptor has been opened without O_NONBLOCK, the call will
  72. block until the SPU writes to its interrupt mailbox channel.
  73. When data has been read successfully, four bytes are placed in
  74. the data buffer and the value four is returned.
  75. poll(2)
  76. Poll on the ibox file returns (POLLIN | POLLRDNORM) whenever
  77. data is available for reading.
  78. /wbox
  79. The CPU to SPU communation mailbox. It is write-only and can be written
  80. in units of 32 bits. If the mailbox is full, write() will block and
  81. poll can be used to wait for it becoming empty again. The possible
  82. operations on an open wbox file are: write(2) If a count smaller than
  83. four is requested, write returns -1 and sets errno to EINVAL. If there
  84. is no space available in the mail box and the file descriptor has been
  85. opened with O_NONBLOCK, the return value is set to -1 and errno becomes
  86. EAGAIN.
  87. If there is no space available in the mail box and the file descriptor
  88. has been opened without O_NONBLOCK, the call will block until the SPU
  89. reads from its PPE mailbox channel. When data has been read success-
  90. fully, four bytes are placed in the data buffer and the value four is
  91. returned.
  92. poll(2)
  93. Poll on the ibox file returns (POLLOUT | POLLWRNORM) whenever
  94. space is available for writing.
  95. /mbox_stat
  96. /ibox_stat
  97. /wbox_stat
  98. Read-only files that contain the length of the current queue, i.e. how
  99. many words can be read from mbox or ibox or how many words can be
  100. written to wbox without blocking. The files can be read only in 4-byte
  101. units and return a big-endian binary integer number. The possible
  102. operations on an open *box_stat file are:
  103. read(2)
  104. If a count smaller than four is requested, read returns -1 and
  105. sets errno to EINVAL. Otherwise, a four byte value is placed in
  106. the data buffer, containing the number of elements that can be
  107. read from (for mbox_stat and ibox_stat) or written to (for
  108. wbox_stat) the respective mail box without blocking or resulting
  109. in EAGAIN.
  110. /npc
  111. /decr
  112. /decr_status
  113. /spu_tag_mask
  114. /event_mask
  115. /srr0
  116. Internal registers of the SPU. The representation is an ASCII string
  117. with the numeric value of the next instruction to be executed. These
  118. can be used in read/write mode for debugging, but normal operation of
  119. programs should not rely on them because access to any of them except
  120. npc requires an SPU context save and is therefore very inefficient.
  121. The contents of these files are:
  122. npc Next Program Counter
  123. decr SPU Decrementer
  124. decr_status Decrementer Status
  125. spu_tag_mask MFC tag mask for SPU DMA
  126. event_mask Event mask for SPU interrupts
  127. srr0 Interrupt Return address register
  128. The possible operations on an open npc, decr, decr_status,
  129. spu_tag_mask, event_mask or srr0 file are:
  130. read(2)
  131. When the count supplied to the read call is shorter than the
  132. required length for the pointer value plus a newline character,
  133. subsequent reads from the same file descriptor will result in
  134. completing the string, regardless of changes to the register by
  135. a running SPU task. When a complete string has been read, all
  136. subsequent read operations will return zero bytes and a new file
  137. descriptor needs to be opened to read the value again.
  138. write(2)
  139. A write operation on the file results in setting the register to
  140. the value given in the string. The string is parsed from the
  141. beginning to the first non-numeric character or the end of the
  142. buffer. Subsequent writes to the same file descriptor overwrite
  143. the previous setting.
  144. /fpcr
  145. This file gives access to the Floating Point Status and Control Regis-
  146. ter as a four byte long file. The operations on the fpcr file are:
  147. read(2)
  148. If a count smaller than four is requested, read returns -1 and
  149. sets errno to EINVAL. Otherwise, a four byte value is placed in
  150. the data buffer, containing the current value of the fpcr regis-
  151. ter.
  152. write(2)
  153. If a count smaller than four is requested, write returns -1 and
  154. sets errno to EINVAL. Otherwise, a four byte value is copied
  155. from the data buffer, updating the value of the fpcr register.
  156. /signal1
  157. /signal2
  158. The two signal notification channels of an SPU. These are read-write
  159. files that operate on a 32 bit word. Writing to one of these files
  160. triggers an interrupt on the SPU. The value written to the signal
  161. files can be read from the SPU through a channel read or from host user
  162. space through the file. After the value has been read by the SPU, it
  163. is reset to zero. The possible operations on an open signal1 or sig-
  164. nal2 file are:
  165. read(2)
  166. If a count smaller than four is requested, read returns -1 and
  167. sets errno to EINVAL. Otherwise, a four byte value is placed in
  168. the data buffer, containing the current value of the specified
  169. signal notification register.
  170. write(2)
  171. If a count smaller than four is requested, write returns -1 and
  172. sets errno to EINVAL. Otherwise, a four byte value is copied
  173. from the data buffer, updating the value of the specified signal
  174. notification register. The signal notification register will
  175. either be replaced with the input data or will be updated to the
  176. bitwise OR or the old value and the input data, depending on the
  177. contents of the signal1_type, or signal2_type respectively,
  178. file.
  179. /signal1_type
  180. /signal2_type
  181. These two files change the behavior of the signal1 and signal2 notifi-
  182. cation files. The contain a numerical ASCII string which is read as
  183. either "1" or "0". In mode 0 (overwrite), the hardware replaces the
  184. contents of the signal channel with the data that is written to it. in
  185. mode 1 (logical OR), the hardware accumulates the bits that are subse-
  186. quently written to it. The possible operations on an open signal1_type
  187. or signal2_type file are:
  188. read(2)
  189. When the count supplied to the read call is shorter than the
  190. required length for the digit plus a newline character, subse-
  191. quent reads from the same file descriptor will result in com-
  192. pleting the string. When a complete string has been read, all
  193. subsequent read operations will return zero bytes and a new file
  194. descriptor needs to be opened to read the value again.
  195. write(2)
  196. A write operation on the file results in setting the register to
  197. the value given in the string. The string is parsed from the
  198. beginning to the first non-numeric character or the end of the
  199. buffer. Subsequent writes to the same file descriptor overwrite
  200. the previous setting.
  201. EXAMPLES
  202. /etc/fstab entry
  203. none /spu spufs gid=spu 0 0
  204. AUTHORS
  205. Arnd Bergmann <arndb@de.ibm.com>, Mark Nutter <mnutter@us.ibm.com>,
  206. Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
  207. SEE ALSO
  208. capabilities(7), close(2), spu_create(2), spu_run(2), spufs(7)
  209. Linux 2005-09-28 SPUFS(2)
  210. ------------------------------------------------------------------------------
  211. SPU_RUN(2) Linux Programmer's Manual SPU_RUN(2)
  212. NAME
  213. spu_run - execute an spu context
  214. SYNOPSIS
  215. #include <sys/spu.h>
  216. int spu_run(int fd, unsigned int *npc, unsigned int *event);
  217. DESCRIPTION
  218. The spu_run system call is used on PowerPC machines that implement the
  219. Cell Broadband Engine Architecture in order to access Synergistic Pro-
  220. cessor Units (SPUs). It uses the fd that was returned from spu_cre-
  221. ate(2) to address a specific SPU context. When the context gets sched-
  222. uled to a physical SPU, it starts execution at the instruction pointer
  223. passed in npc.
  224. Execution of SPU code happens synchronously, meaning that spu_run does
  225. not return while the SPU is still running. If there is a need to exe-
  226. cute SPU code in parallel with other code on either the main CPU or
  227. other SPUs, you need to create a new thread of execution first, e.g.
  228. using the pthread_create(3) call.
  229. When spu_run returns, the current value of the SPU instruction pointer
  230. is written back to npc, so you can call spu_run again without updating
  231. the pointers.
  232. event can be a NULL pointer or point to an extended status code that
  233. gets filled when spu_run returns. It can be one of the following con-
  234. stants:
  235. SPE_EVENT_DMA_ALIGNMENT
  236. A DMA alignment error
  237. SPE_EVENT_SPE_DATA_SEGMENT
  238. A DMA segmentation error
  239. SPE_EVENT_SPE_DATA_STORAGE
  240. A DMA storage error
  241. If NULL is passed as the event argument, these errors will result in a
  242. signal delivered to the calling process.
  243. RETURN VALUE
  244. spu_run returns the value of the spu_status register or -1 to indicate
  245. an error and set errno to one of the error codes listed below. The
  246. spu_status register value contains a bit mask of status codes and
  247. optionally a 14 bit code returned from the stop-and-signal instruction
  248. on the SPU. The bit masks for the status codes are:
  249. 0x02 SPU was stopped by stop-and-signal.
  250. 0x04 SPU was stopped by halt.
  251. 0x08 SPU is waiting for a channel.
  252. 0x10 SPU is in single-step mode.
  253. 0x20 SPU has tried to execute an invalid instruction.
  254. 0x40 SPU has tried to access an invalid channel.
  255. 0x3fff0000
  256. The bits masked with this value contain the code returned from
  257. stop-and-signal.
  258. There are always one or more of the lower eight bits set or an error
  259. code is returned from spu_run.
  260. ERRORS
  261. EAGAIN or EWOULDBLOCK
  262. fd is in non-blocking mode and spu_run would block.
  263. EBADF fd is not a valid file descriptor.
  264. EFAULT npc is not a valid pointer or status is neither NULL nor a valid
  265. pointer.
  266. EINTR A signal occurred while spu_run was in progress. The npc value
  267. has been updated to the new program counter value if necessary.
  268. EINVAL fd is not a file descriptor returned from spu_create(2).
  269. ENOMEM Insufficient memory was available to handle a page fault result-
  270. ing from an MFC direct memory access.
  271. ENOSYS the functionality is not provided by the current system, because
  272. either the hardware does not provide SPUs or the spufs module is
  273. not loaded.
  274. NOTES
  275. spu_run is meant to be used from libraries that implement a more
  276. abstract interface to SPUs, not to be used from regular applications.
  277. See http://www.bsc.es/projects/deepcomputing/linuxoncell/ for the rec-
  278. ommended libraries.
  279. CONFORMING TO
  280. This call is Linux specific and only implemented by the ppc64 architec-
  281. ture. Programs using this system call are not portable.
  282. BUGS
  283. The code does not yet fully implement all features lined out here.
  284. AUTHOR
  285. Arnd Bergmann <arndb@de.ibm.com>
  286. SEE ALSO
  287. capabilities(7), close(2), spu_create(2), spufs(7)
  288. Linux 2005-09-28 SPU_RUN(2)
  289. ------------------------------------------------------------------------------
  290. SPU_CREATE(2) Linux Programmer's Manual SPU_CREATE(2)
  291. NAME
  292. spu_create - create a new spu context
  293. SYNOPSIS
  294. #include <sys/types.h>
  295. #include <sys/spu.h>
  296. int spu_create(const char *pathname, int flags, mode_t mode);
  297. DESCRIPTION
  298. The spu_create system call is used on PowerPC machines that implement
  299. the Cell Broadband Engine Architecture in order to access Synergistic
  300. Processor Units (SPUs). It creates a new logical context for an SPU in
  301. pathname and returns a handle to associated with it. pathname must
  302. point to a non-existing directory in the mount point of the SPU file
  303. system (spufs). When spu_create is successful, a directory gets cre-
  304. ated on pathname and it is populated with files.
  305. The returned file handle can only be passed to spu_run(2) or closed,
  306. other operations are not defined on it. When it is closed, all associ-
  307. ated directory entries in spufs are removed. When the last file handle
  308. pointing either inside of the context directory or to this file
  309. descriptor is closed, the logical SPU context is destroyed.
  310. The parameter flags can be zero or any bitwise or'd combination of the
  311. following constants:
  312. SPU_RAWIO
  313. Allow mapping of some of the hardware registers of the SPU into
  314. user space. This flag requires the CAP_SYS_RAWIO capability, see
  315. capabilities(7).
  316. The mode parameter specifies the permissions used for creating the new
  317. directory in spufs. mode is modified with the user's umask(2) value
  318. and then used for both the directory and the files contained in it. The
  319. file permissions mask out some more bits of mode because they typically
  320. support only read or write access. See stat(2) for a full list of the
  321. possible mode values.
  322. RETURN VALUE
  323. spu_create returns a new file descriptor. It may return -1 to indicate
  324. an error condition and set errno to one of the error codes listed
  325. below.
  326. ERRORS
  327. EACCESS
  328. The current user does not have write access on the spufs mount
  329. point.
  330. EEXIST An SPU context already exists at the given path name.
  331. EFAULT pathname is not a valid string pointer in the current address
  332. space.
  333. EINVAL pathname is not a directory in the spufs mount point.
  334. ELOOP Too many symlinks were found while resolving pathname.
  335. EMFILE The process has reached its maximum open file limit.
  336. ENAMETOOLONG
  337. pathname was too long.
  338. ENFILE The system has reached the global open file limit.
  339. ENOENT Part of pathname could not be resolved.
  340. ENOMEM The kernel could not allocate all resources required.
  341. ENOSPC There are not enough SPU resources available to create a new
  342. context or the user specific limit for the number of SPU con-
  343. texts has been reached.
  344. ENOSYS the functionality is not provided by the current system, because
  345. either the hardware does not provide SPUs or the spufs module is
  346. not loaded.
  347. ENOTDIR
  348. A part of pathname is not a directory.
  349. NOTES
  350. spu_create is meant to be used from libraries that implement a more
  351. abstract interface to SPUs, not to be used from regular applications.
  352. See http://www.bsc.es/projects/deepcomputing/linuxoncell/ for the rec-
  353. ommended libraries.
  354. FILES
  355. pathname must point to a location beneath the mount point of spufs. By
  356. convention, it gets mounted in /spu.
  357. CONFORMING TO
  358. This call is Linux specific and only implemented by the ppc64 architec-
  359. ture. Programs using this system call are not portable.
  360. BUGS
  361. The code does not yet fully implement all features lined out here.
  362. AUTHOR
  363. Arnd Bergmann <arndb@de.ibm.com>
  364. SEE ALSO
  365. capabilities(7), close(2), spu_run(2), spufs(7)
  366. Linux 2005-09-28 SPU_CREATE(2)