18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci=====
48c2ecf20Sopenharmony_cispufs
58c2ecf20Sopenharmony_ci=====
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciName
88c2ecf20Sopenharmony_ci====
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci       spufs - the SPU file system
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciDescription
148c2ecf20Sopenharmony_ci===========
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci       The SPU file system is used on PowerPC machines that implement the Cell
178c2ecf20Sopenharmony_ci       Broadband Engine Architecture in order to access Synergistic  Processor
188c2ecf20Sopenharmony_ci       Units (SPUs).
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci       The file system provides a name space similar to posix shared memory or
218c2ecf20Sopenharmony_ci       message queues. Users that have write permissions on  the  file  system
228c2ecf20Sopenharmony_ci       can use spu_create(2) to establish SPU contexts in the spufs root.
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci       Every SPU context is represented by a directory containing a predefined
258c2ecf20Sopenharmony_ci       set of files. These files can be used for manipulating the state of the
268c2ecf20Sopenharmony_ci       logical SPU. Users can change permissions on those files, but not actu-
278c2ecf20Sopenharmony_ci       ally add or remove files.
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ciMount Options
318c2ecf20Sopenharmony_ci=============
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci       uid=<uid>
348c2ecf20Sopenharmony_ci              set the user owning the mount point, the default is 0 (root).
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci       gid=<gid>
378c2ecf20Sopenharmony_ci              set the group owning the mount point, the default is 0 (root).
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciFiles
418c2ecf20Sopenharmony_ci=====
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci       The files in spufs mostly follow the standard behavior for regular sys-
448c2ecf20Sopenharmony_ci       tem  calls like read(2) or write(2), but often support only a subset of
458c2ecf20Sopenharmony_ci       the operations supported on regular file systems. This list details the
468c2ecf20Sopenharmony_ci       supported  operations  and  the  deviations  from  the behaviour in the
478c2ecf20Sopenharmony_ci       respective man pages.
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci       All files that support the read(2) operation also support readv(2)  and
508c2ecf20Sopenharmony_ci       all  files  that support the write(2) operation also support writev(2).
518c2ecf20Sopenharmony_ci       All files support the access(2) and stat(2) family of  operations,  but
528c2ecf20Sopenharmony_ci       only  the  st_mode,  st_nlink,  st_uid and st_gid fields of struct stat
538c2ecf20Sopenharmony_ci       contain reliable information.
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci       All files support the chmod(2)/fchmod(2) and chown(2)/fchown(2)  opera-
568c2ecf20Sopenharmony_ci       tions,  but  will  not be able to grant permissions that contradict the
578c2ecf20Sopenharmony_ci       possible operations, e.g. read access on the wbox file.
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci       The current set of files is:
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci   /mem
638c2ecf20Sopenharmony_ci       the contents of the local storage memory  of  the  SPU.   This  can  be
648c2ecf20Sopenharmony_ci       accessed  like  a regular shared memory file and contains both code and
658c2ecf20Sopenharmony_ci       data in the address space of the SPU.  The possible  operations  on  an
668c2ecf20Sopenharmony_ci       open mem file are:
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci       read(2), pread(2), write(2), pwrite(2), lseek(2)
698c2ecf20Sopenharmony_ci              These  operate  as  documented, with the exception that seek(2),
708c2ecf20Sopenharmony_ci              write(2) and pwrite(2) are not supported beyond the end  of  the
718c2ecf20Sopenharmony_ci              file. The file size is the size of the local storage of the SPU,
728c2ecf20Sopenharmony_ci              which normally is 256 kilobytes.
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci       mmap(2)
758c2ecf20Sopenharmony_ci              Mapping mem into the process address space gives access  to  the
768c2ecf20Sopenharmony_ci              SPU  local  storage  within  the  process  address  space.  Only
778c2ecf20Sopenharmony_ci              MAP_SHARED mappings are allowed.
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci   /mbox
818c2ecf20Sopenharmony_ci       The first SPU to CPU communication mailbox. This file is read-only  and
828c2ecf20Sopenharmony_ci       can  be  read  in  units of 32 bits.  The file can only be used in non-
838c2ecf20Sopenharmony_ci       blocking mode and it even poll() will not block on  it.   The  possible
848c2ecf20Sopenharmony_ci       operations on an open mbox file are:
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci       read(2)
878c2ecf20Sopenharmony_ci              If  a  count smaller than four is requested, read returns -1 and
888c2ecf20Sopenharmony_ci              sets errno to EINVAL.  If there is no data available in the mail
898c2ecf20Sopenharmony_ci              box,  the  return  value  is set to -1 and errno becomes EAGAIN.
908c2ecf20Sopenharmony_ci              When data has been read successfully, four bytes are  placed  in
918c2ecf20Sopenharmony_ci              the data buffer and the value four is returned.
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci   /ibox
958c2ecf20Sopenharmony_ci       The  second  SPU  to CPU communication mailbox. This file is similar to
968c2ecf20Sopenharmony_ci       the first mailbox file, but can be read in blocking I/O mode,  and  the
978c2ecf20Sopenharmony_ci       poll  family of system calls can be used to wait for it.  The  possible
988c2ecf20Sopenharmony_ci       operations on an open ibox file are:
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci       read(2)
1018c2ecf20Sopenharmony_ci              If a count smaller than four is requested, read returns  -1  and
1028c2ecf20Sopenharmony_ci              sets errno to EINVAL.  If there is no data available in the mail
1038c2ecf20Sopenharmony_ci              box and the file descriptor has been opened with O_NONBLOCK, the
1048c2ecf20Sopenharmony_ci              return value is set to -1 and errno becomes EAGAIN.
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci              If  there  is  no  data  available  in the mail box and the file
1078c2ecf20Sopenharmony_ci              descriptor has been opened without  O_NONBLOCK,  the  call  will
1088c2ecf20Sopenharmony_ci              block  until  the  SPU  writes to its interrupt mailbox channel.
1098c2ecf20Sopenharmony_ci              When data has been read successfully, four bytes are  placed  in
1108c2ecf20Sopenharmony_ci              the data buffer and the value four is returned.
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci       poll(2)
1138c2ecf20Sopenharmony_ci              Poll  on  the  ibox  file returns (POLLIN | POLLRDNORM) whenever
1148c2ecf20Sopenharmony_ci              data is available for reading.
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci   /wbox
1188c2ecf20Sopenharmony_ci       The CPU to SPU communation mailbox. It is write-only and can be written
1198c2ecf20Sopenharmony_ci       in  units  of  32  bits. If the mailbox is full, write() will block and
1208c2ecf20Sopenharmony_ci       poll can be used to wait for it becoming  empty  again.   The  possible
1218c2ecf20Sopenharmony_ci       operations  on  an open wbox file are: write(2) If a count smaller than
1228c2ecf20Sopenharmony_ci       four is requested, write returns -1 and sets errno to EINVAL.  If there
1238c2ecf20Sopenharmony_ci       is  no space available in the mail box and the file descriptor has been
1248c2ecf20Sopenharmony_ci       opened with O_NONBLOCK, the return value is set to -1 and errno becomes
1258c2ecf20Sopenharmony_ci       EAGAIN.
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci       If  there is no space available in the mail box and the file descriptor
1288c2ecf20Sopenharmony_ci       has been opened without O_NONBLOCK, the call will block until  the  SPU
1298c2ecf20Sopenharmony_ci       reads  from  its PPE mailbox channel.  When data has been read success-
1308c2ecf20Sopenharmony_ci       fully, four bytes are placed in the data buffer and the value  four  is
1318c2ecf20Sopenharmony_ci       returned.
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci       poll(2)
1348c2ecf20Sopenharmony_ci              Poll  on  the  ibox file returns (POLLOUT | POLLWRNORM) whenever
1358c2ecf20Sopenharmony_ci              space is available for writing.
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci   /mbox_stat, /ibox_stat, /wbox_stat
1398c2ecf20Sopenharmony_ci       Read-only files that contain the length of the current queue, i.e.  how
1408c2ecf20Sopenharmony_ci       many  words  can  be  read  from  mbox or ibox or how many words can be
1418c2ecf20Sopenharmony_ci       written to wbox without blocking.  The files can be read only in 4-byte
1428c2ecf20Sopenharmony_ci       units  and  return  a  big-endian  binary integer number.  The possible
1438c2ecf20Sopenharmony_ci       operations on an open ``*box_stat`` file are:
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci       read(2)
1468c2ecf20Sopenharmony_ci              If a count smaller than four is requested, read returns  -1  and
1478c2ecf20Sopenharmony_ci              sets errno to EINVAL.  Otherwise, a four byte value is placed in
1488c2ecf20Sopenharmony_ci              the data buffer, containing the number of elements that  can  be
1498c2ecf20Sopenharmony_ci              read  from  (for  mbox_stat  and  ibox_stat)  or written to (for
1508c2ecf20Sopenharmony_ci              wbox_stat) the respective mail box without blocking or resulting
1518c2ecf20Sopenharmony_ci              in EAGAIN.
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci   /npc, /decr, /decr_status, /spu_tag_mask, /event_mask, /srr0
1558c2ecf20Sopenharmony_ci       Internal  registers  of  the SPU. The representation is an ASCII string
1568c2ecf20Sopenharmony_ci       with the numeric value of the next instruction to  be  executed.  These
1578c2ecf20Sopenharmony_ci       can  be  used in read/write mode for debugging, but normal operation of
1588c2ecf20Sopenharmony_ci       programs should not rely on them because access to any of  them  except
1598c2ecf20Sopenharmony_ci       npc requires an SPU context save and is therefore very inefficient.
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci       The contents of these files are:
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci       =================== ===================================
1648c2ecf20Sopenharmony_ci       npc                 Next Program Counter
1658c2ecf20Sopenharmony_ci       decr                SPU Decrementer
1668c2ecf20Sopenharmony_ci       decr_status         Decrementer Status
1678c2ecf20Sopenharmony_ci       spu_tag_mask        MFC tag mask for SPU DMA
1688c2ecf20Sopenharmony_ci       event_mask          Event mask for SPU interrupts
1698c2ecf20Sopenharmony_ci       srr0                Interrupt Return address register
1708c2ecf20Sopenharmony_ci       =================== ===================================
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci       The   possible   operations   on   an   open  npc,  decr,  decr_status,
1748c2ecf20Sopenharmony_ci       spu_tag_mask, event_mask or srr0 file are:
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci       read(2)
1778c2ecf20Sopenharmony_ci              When the count supplied to the read call  is  shorter  than  the
1788c2ecf20Sopenharmony_ci              required  length for the pointer value plus a newline character,
1798c2ecf20Sopenharmony_ci              subsequent reads from the same file descriptor  will  result  in
1808c2ecf20Sopenharmony_ci              completing  the string, regardless of changes to the register by
1818c2ecf20Sopenharmony_ci              a running SPU task.  When a complete string has been  read,  all
1828c2ecf20Sopenharmony_ci              subsequent read operations will return zero bytes and a new file
1838c2ecf20Sopenharmony_ci              descriptor needs to be opened to read the value again.
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci       write(2)
1868c2ecf20Sopenharmony_ci              A write operation on the file results in setting the register to
1878c2ecf20Sopenharmony_ci              the  value  given  in  the string. The string is parsed from the
1888c2ecf20Sopenharmony_ci              beginning to the first non-numeric character or the end  of  the
1898c2ecf20Sopenharmony_ci              buffer.  Subsequent writes to the same file descriptor overwrite
1908c2ecf20Sopenharmony_ci              the previous setting.
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci   /fpcr
1948c2ecf20Sopenharmony_ci       This file gives access to the Floating Point Status and Control  Regis-
1958c2ecf20Sopenharmony_ci       ter as a four byte long file. The operations on the fpcr file are:
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci       read(2)
1988c2ecf20Sopenharmony_ci              If  a  count smaller than four is requested, read returns -1 and
1998c2ecf20Sopenharmony_ci              sets errno to EINVAL.  Otherwise, a four byte value is placed in
2008c2ecf20Sopenharmony_ci              the data buffer, containing the current value of the fpcr regis-
2018c2ecf20Sopenharmony_ci              ter.
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci       write(2)
2048c2ecf20Sopenharmony_ci              If a count smaller than four is requested, write returns -1  and
2058c2ecf20Sopenharmony_ci              sets  errno  to  EINVAL.  Otherwise, a four byte value is copied
2068c2ecf20Sopenharmony_ci              from the data buffer, updating the value of the fpcr register.
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci   /signal1, /signal2
2108c2ecf20Sopenharmony_ci       The two signal notification channels of an SPU.  These  are  read-write
2118c2ecf20Sopenharmony_ci       files  that  operate  on  a 32 bit word.  Writing to one of these files
2128c2ecf20Sopenharmony_ci       triggers an interrupt on the SPU.  The  value  written  to  the  signal
2138c2ecf20Sopenharmony_ci       files can be read from the SPU through a channel read or from host user
2148c2ecf20Sopenharmony_ci       space through the file.  After the value has been read by the  SPU,  it
2158c2ecf20Sopenharmony_ci       is  reset  to zero.  The possible operations on an open signal1 or sig-
2168c2ecf20Sopenharmony_ci       nal2 file are:
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci       read(2)
2198c2ecf20Sopenharmony_ci              If a count smaller than four is requested, read returns  -1  and
2208c2ecf20Sopenharmony_ci              sets errno to EINVAL.  Otherwise, a four byte value is placed in
2218c2ecf20Sopenharmony_ci              the data buffer, containing the current value of  the  specified
2228c2ecf20Sopenharmony_ci              signal notification register.
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci       write(2)
2258c2ecf20Sopenharmony_ci              If  a count smaller than four is requested, write returns -1 and
2268c2ecf20Sopenharmony_ci              sets errno to EINVAL.  Otherwise, a four byte  value  is  copied
2278c2ecf20Sopenharmony_ci              from the data buffer, updating the value of the specified signal
2288c2ecf20Sopenharmony_ci              notification register.  The signal  notification  register  will
2298c2ecf20Sopenharmony_ci              either be replaced with the input data or will be updated to the
2308c2ecf20Sopenharmony_ci              bitwise OR or the old value and the input data, depending on the
2318c2ecf20Sopenharmony_ci              contents  of  the  signal1_type,  or  signal2_type respectively,
2328c2ecf20Sopenharmony_ci              file.
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci   /signal1_type, /signal2_type
2368c2ecf20Sopenharmony_ci       These two files change the behavior of the signal1 and signal2  notifi-
2378c2ecf20Sopenharmony_ci       cation  files.  The  contain  a numerical ASCII string which is read as
2388c2ecf20Sopenharmony_ci       either "1" or "0".  In mode 0 (overwrite), the  hardware  replaces  the
2398c2ecf20Sopenharmony_ci       contents of the signal channel with the data that is written to it.  in
2408c2ecf20Sopenharmony_ci       mode 1 (logical OR), the hardware accumulates the bits that are  subse-
2418c2ecf20Sopenharmony_ci       quently written to it.  The possible operations on an open signal1_type
2428c2ecf20Sopenharmony_ci       or signal2_type file are:
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci       read(2)
2458c2ecf20Sopenharmony_ci              When the count supplied to the read call  is  shorter  than  the
2468c2ecf20Sopenharmony_ci              required  length  for the digit plus a newline character, subse-
2478c2ecf20Sopenharmony_ci              quent reads from the same file descriptor will  result  in  com-
2488c2ecf20Sopenharmony_ci              pleting  the  string.  When a complete string has been read, all
2498c2ecf20Sopenharmony_ci              subsequent read operations will return zero bytes and a new file
2508c2ecf20Sopenharmony_ci              descriptor needs to be opened to read the value again.
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci       write(2)
2538c2ecf20Sopenharmony_ci              A write operation on the file results in setting the register to
2548c2ecf20Sopenharmony_ci              the value given in the string. The string  is  parsed  from  the
2558c2ecf20Sopenharmony_ci              beginning  to  the first non-numeric character or the end of the
2568c2ecf20Sopenharmony_ci              buffer.  Subsequent writes to the same file descriptor overwrite
2578c2ecf20Sopenharmony_ci              the previous setting.
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ciExamples
2618c2ecf20Sopenharmony_ci========
2628c2ecf20Sopenharmony_ci       /etc/fstab entry
2638c2ecf20Sopenharmony_ci              none      /spu      spufs     gid=spu   0    0
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ciAuthors
2678c2ecf20Sopenharmony_ci=======
2688c2ecf20Sopenharmony_ci       Arnd  Bergmann  <arndb@de.ibm.com>,  Mark  Nutter <mnutter@us.ibm.com>,
2698c2ecf20Sopenharmony_ci       Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ciSee Also
2728c2ecf20Sopenharmony_ci========
2738c2ecf20Sopenharmony_ci       capabilities(7), close(2), spu_create(2), spu_run(2), spufs(7)
274