xref: /OK3568_Linux_fs/kernel/Documentation/filesystems/spufs/spufs.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun=====
4*4882a593Smuzhiyunspufs
5*4882a593Smuzhiyun=====
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunName
8*4882a593Smuzhiyun====
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun       spufs - the SPU file system
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunDescription
14*4882a593Smuzhiyun===========
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun       The SPU file system is used on PowerPC machines that implement the Cell
17*4882a593Smuzhiyun       Broadband Engine Architecture in order to access Synergistic  Processor
18*4882a593Smuzhiyun       Units (SPUs).
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun       The file system provides a name space similar to posix shared memory or
21*4882a593Smuzhiyun       message queues. Users that have write permissions on  the  file  system
22*4882a593Smuzhiyun       can use spu_create(2) to establish SPU contexts in the spufs root.
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun       Every SPU context is represented by a directory containing a predefined
25*4882a593Smuzhiyun       set of files. These files can be used for manipulating the state of the
26*4882a593Smuzhiyun       logical SPU. Users can change permissions on those files, but not actu-
27*4882a593Smuzhiyun       ally add or remove files.
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun
30*4882a593SmuzhiyunMount Options
31*4882a593Smuzhiyun=============
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun       uid=<uid>
34*4882a593Smuzhiyun              set the user owning the mount point, the default is 0 (root).
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun       gid=<gid>
37*4882a593Smuzhiyun              set the group owning the mount point, the default is 0 (root).
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunFiles
41*4882a593Smuzhiyun=====
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun       The files in spufs mostly follow the standard behavior for regular sys-
44*4882a593Smuzhiyun       tem  calls like read(2) or write(2), but often support only a subset of
45*4882a593Smuzhiyun       the operations supported on regular file systems. This list details the
46*4882a593Smuzhiyun       supported  operations  and  the  deviations  from  the behaviour in the
47*4882a593Smuzhiyun       respective man pages.
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun       All files that support the read(2) operation also support readv(2)  and
50*4882a593Smuzhiyun       all  files  that support the write(2) operation also support writev(2).
51*4882a593Smuzhiyun       All files support the access(2) and stat(2) family of  operations,  but
52*4882a593Smuzhiyun       only  the  st_mode,  st_nlink,  st_uid and st_gid fields of struct stat
53*4882a593Smuzhiyun       contain reliable information.
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun       All files support the chmod(2)/fchmod(2) and chown(2)/fchown(2)  opera-
56*4882a593Smuzhiyun       tions,  but  will  not be able to grant permissions that contradict the
57*4882a593Smuzhiyun       possible operations, e.g. read access on the wbox file.
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun       The current set of files is:
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun   /mem
63*4882a593Smuzhiyun       the contents of the local storage memory  of  the  SPU.   This  can  be
64*4882a593Smuzhiyun       accessed  like  a regular shared memory file and contains both code and
65*4882a593Smuzhiyun       data in the address space of the SPU.  The possible  operations  on  an
66*4882a593Smuzhiyun       open mem file are:
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun       read(2), pread(2), write(2), pwrite(2), lseek(2)
69*4882a593Smuzhiyun              These  operate  as  documented, with the exception that seek(2),
70*4882a593Smuzhiyun              write(2) and pwrite(2) are not supported beyond the end  of  the
71*4882a593Smuzhiyun              file. The file size is the size of the local storage of the SPU,
72*4882a593Smuzhiyun              which normally is 256 kilobytes.
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun       mmap(2)
75*4882a593Smuzhiyun              Mapping mem into the process address space gives access  to  the
76*4882a593Smuzhiyun              SPU  local  storage  within  the  process  address  space.  Only
77*4882a593Smuzhiyun              MAP_SHARED mappings are allowed.
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun   /mbox
81*4882a593Smuzhiyun       The first SPU to CPU communication mailbox. This file is read-only  and
82*4882a593Smuzhiyun       can  be  read  in  units of 32 bits.  The file can only be used in non-
83*4882a593Smuzhiyun       blocking mode and it even poll() will not block on  it.   The  possible
84*4882a593Smuzhiyun       operations on an open mbox file are:
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun       read(2)
87*4882a593Smuzhiyun              If  a  count smaller than four is requested, read returns -1 and
88*4882a593Smuzhiyun              sets errno to EINVAL.  If there is no data available in the mail
89*4882a593Smuzhiyun              box,  the  return  value  is set to -1 and errno becomes EAGAIN.
90*4882a593Smuzhiyun              When data has been read successfully, four bytes are  placed  in
91*4882a593Smuzhiyun              the data buffer and the value four is returned.
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun   /ibox
95*4882a593Smuzhiyun       The  second  SPU  to CPU communication mailbox. This file is similar to
96*4882a593Smuzhiyun       the first mailbox file, but can be read in blocking I/O mode,  and  the
97*4882a593Smuzhiyun       poll  family of system calls can be used to wait for it.  The  possible
98*4882a593Smuzhiyun       operations on an open ibox file are:
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun       read(2)
101*4882a593Smuzhiyun              If a count smaller than four is requested, read returns  -1  and
102*4882a593Smuzhiyun              sets errno to EINVAL.  If there is no data available in the mail
103*4882a593Smuzhiyun              box and the file descriptor has been opened with O_NONBLOCK, the
104*4882a593Smuzhiyun              return value is set to -1 and errno becomes EAGAIN.
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun              If  there  is  no  data  available  in the mail box and the file
107*4882a593Smuzhiyun              descriptor has been opened without  O_NONBLOCK,  the  call  will
108*4882a593Smuzhiyun              block  until  the  SPU  writes to its interrupt mailbox channel.
109*4882a593Smuzhiyun              When data has been read successfully, four bytes are  placed  in
110*4882a593Smuzhiyun              the data buffer and the value four is returned.
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun       poll(2)
113*4882a593Smuzhiyun              Poll  on  the  ibox  file returns (POLLIN | POLLRDNORM) whenever
114*4882a593Smuzhiyun              data is available for reading.
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun
117*4882a593Smuzhiyun   /wbox
118*4882a593Smuzhiyun       The CPU to SPU communation mailbox. It is write-only and can be written
119*4882a593Smuzhiyun       in  units  of  32  bits. If the mailbox is full, write() will block and
120*4882a593Smuzhiyun       poll can be used to wait for it becoming  empty  again.   The  possible
121*4882a593Smuzhiyun       operations  on  an open wbox file are: write(2) If a count smaller than
122*4882a593Smuzhiyun       four is requested, write returns -1 and sets errno to EINVAL.  If there
123*4882a593Smuzhiyun       is  no space available in the mail box and the file descriptor has been
124*4882a593Smuzhiyun       opened with O_NONBLOCK, the return value is set to -1 and errno becomes
125*4882a593Smuzhiyun       EAGAIN.
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun       If  there is no space available in the mail box and the file descriptor
128*4882a593Smuzhiyun       has been opened without O_NONBLOCK, the call will block until  the  SPU
129*4882a593Smuzhiyun       reads  from  its PPE mailbox channel.  When data has been read success-
130*4882a593Smuzhiyun       fully, four bytes are placed in the data buffer and the value  four  is
131*4882a593Smuzhiyun       returned.
132*4882a593Smuzhiyun
133*4882a593Smuzhiyun       poll(2)
134*4882a593Smuzhiyun              Poll  on  the  ibox file returns (POLLOUT | POLLWRNORM) whenever
135*4882a593Smuzhiyun              space is available for writing.
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun
138*4882a593Smuzhiyun   /mbox_stat, /ibox_stat, /wbox_stat
139*4882a593Smuzhiyun       Read-only files that contain the length of the current queue, i.e.  how
140*4882a593Smuzhiyun       many  words  can  be  read  from  mbox or ibox or how many words can be
141*4882a593Smuzhiyun       written to wbox without blocking.  The files can be read only in 4-byte
142*4882a593Smuzhiyun       units  and  return  a  big-endian  binary integer number.  The possible
143*4882a593Smuzhiyun       operations on an open ``*box_stat`` file are:
144*4882a593Smuzhiyun
145*4882a593Smuzhiyun       read(2)
146*4882a593Smuzhiyun              If a count smaller than four is requested, read returns  -1  and
147*4882a593Smuzhiyun              sets errno to EINVAL.  Otherwise, a four byte value is placed in
148*4882a593Smuzhiyun              the data buffer, containing the number of elements that  can  be
149*4882a593Smuzhiyun              read  from  (for  mbox_stat  and  ibox_stat)  or written to (for
150*4882a593Smuzhiyun              wbox_stat) the respective mail box without blocking or resulting
151*4882a593Smuzhiyun              in EAGAIN.
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun
154*4882a593Smuzhiyun   /npc, /decr, /decr_status, /spu_tag_mask, /event_mask, /srr0
155*4882a593Smuzhiyun       Internal  registers  of  the SPU. The representation is an ASCII string
156*4882a593Smuzhiyun       with the numeric value of the next instruction to  be  executed.  These
157*4882a593Smuzhiyun       can  be  used in read/write mode for debugging, but normal operation of
158*4882a593Smuzhiyun       programs should not rely on them because access to any of  them  except
159*4882a593Smuzhiyun       npc requires an SPU context save and is therefore very inefficient.
160*4882a593Smuzhiyun
161*4882a593Smuzhiyun       The contents of these files are:
162*4882a593Smuzhiyun
163*4882a593Smuzhiyun       =================== ===================================
164*4882a593Smuzhiyun       npc                 Next Program Counter
165*4882a593Smuzhiyun       decr                SPU Decrementer
166*4882a593Smuzhiyun       decr_status         Decrementer Status
167*4882a593Smuzhiyun       spu_tag_mask        MFC tag mask for SPU DMA
168*4882a593Smuzhiyun       event_mask          Event mask for SPU interrupts
169*4882a593Smuzhiyun       srr0                Interrupt Return address register
170*4882a593Smuzhiyun       =================== ===================================
171*4882a593Smuzhiyun
172*4882a593Smuzhiyun
173*4882a593Smuzhiyun       The   possible   operations   on   an   open  npc,  decr,  decr_status,
174*4882a593Smuzhiyun       spu_tag_mask, event_mask or srr0 file are:
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun       read(2)
177*4882a593Smuzhiyun              When the count supplied to the read call  is  shorter  than  the
178*4882a593Smuzhiyun              required  length for the pointer value plus a newline character,
179*4882a593Smuzhiyun              subsequent reads from the same file descriptor  will  result  in
180*4882a593Smuzhiyun              completing  the string, regardless of changes to the register by
181*4882a593Smuzhiyun              a running SPU task.  When a complete string has been  read,  all
182*4882a593Smuzhiyun              subsequent read operations will return zero bytes and a new file
183*4882a593Smuzhiyun              descriptor needs to be opened to read the value again.
184*4882a593Smuzhiyun
185*4882a593Smuzhiyun       write(2)
186*4882a593Smuzhiyun              A write operation on the file results in setting the register to
187*4882a593Smuzhiyun              the  value  given  in  the string. The string is parsed from the
188*4882a593Smuzhiyun              beginning to the first non-numeric character or the end  of  the
189*4882a593Smuzhiyun              buffer.  Subsequent writes to the same file descriptor overwrite
190*4882a593Smuzhiyun              the previous setting.
191*4882a593Smuzhiyun
192*4882a593Smuzhiyun
193*4882a593Smuzhiyun   /fpcr
194*4882a593Smuzhiyun       This file gives access to the Floating Point Status and Control  Regis-
195*4882a593Smuzhiyun       ter as a four byte long file. The operations on the fpcr file are:
196*4882a593Smuzhiyun
197*4882a593Smuzhiyun       read(2)
198*4882a593Smuzhiyun              If  a  count smaller than four is requested, read returns -1 and
199*4882a593Smuzhiyun              sets errno to EINVAL.  Otherwise, a four byte value is placed in
200*4882a593Smuzhiyun              the data buffer, containing the current value of the fpcr regis-
201*4882a593Smuzhiyun              ter.
202*4882a593Smuzhiyun
203*4882a593Smuzhiyun       write(2)
204*4882a593Smuzhiyun              If a count smaller than four is requested, write returns -1  and
205*4882a593Smuzhiyun              sets  errno  to  EINVAL.  Otherwise, a four byte value is copied
206*4882a593Smuzhiyun              from the data buffer, updating the value of the fpcr register.
207*4882a593Smuzhiyun
208*4882a593Smuzhiyun
209*4882a593Smuzhiyun   /signal1, /signal2
210*4882a593Smuzhiyun       The two signal notification channels of an SPU.  These  are  read-write
211*4882a593Smuzhiyun       files  that  operate  on  a 32 bit word.  Writing to one of these files
212*4882a593Smuzhiyun       triggers an interrupt on the SPU.  The  value  written  to  the  signal
213*4882a593Smuzhiyun       files can be read from the SPU through a channel read or from host user
214*4882a593Smuzhiyun       space through the file.  After the value has been read by the  SPU,  it
215*4882a593Smuzhiyun       is  reset  to zero.  The possible operations on an open signal1 or sig-
216*4882a593Smuzhiyun       nal2 file are:
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun       read(2)
219*4882a593Smuzhiyun              If a count smaller than four is requested, read returns  -1  and
220*4882a593Smuzhiyun              sets errno to EINVAL.  Otherwise, a four byte value is placed in
221*4882a593Smuzhiyun              the data buffer, containing the current value of  the  specified
222*4882a593Smuzhiyun              signal notification register.
223*4882a593Smuzhiyun
224*4882a593Smuzhiyun       write(2)
225*4882a593Smuzhiyun              If  a count smaller than four is requested, write returns -1 and
226*4882a593Smuzhiyun              sets errno to EINVAL.  Otherwise, a four byte  value  is  copied
227*4882a593Smuzhiyun              from the data buffer, updating the value of the specified signal
228*4882a593Smuzhiyun              notification register.  The signal  notification  register  will
229*4882a593Smuzhiyun              either be replaced with the input data or will be updated to the
230*4882a593Smuzhiyun              bitwise OR or the old value and the input data, depending on the
231*4882a593Smuzhiyun              contents  of  the  signal1_type,  or  signal2_type respectively,
232*4882a593Smuzhiyun              file.
233*4882a593Smuzhiyun
234*4882a593Smuzhiyun
235*4882a593Smuzhiyun   /signal1_type, /signal2_type
236*4882a593Smuzhiyun       These two files change the behavior of the signal1 and signal2  notifi-
237*4882a593Smuzhiyun       cation  files.  The  contain  a numerical ASCII string which is read as
238*4882a593Smuzhiyun       either "1" or "0".  In mode 0 (overwrite), the  hardware  replaces  the
239*4882a593Smuzhiyun       contents of the signal channel with the data that is written to it.  in
240*4882a593Smuzhiyun       mode 1 (logical OR), the hardware accumulates the bits that are  subse-
241*4882a593Smuzhiyun       quently written to it.  The possible operations on an open signal1_type
242*4882a593Smuzhiyun       or signal2_type file are:
243*4882a593Smuzhiyun
244*4882a593Smuzhiyun       read(2)
245*4882a593Smuzhiyun              When the count supplied to the read call  is  shorter  than  the
246*4882a593Smuzhiyun              required  length  for the digit plus a newline character, subse-
247*4882a593Smuzhiyun              quent reads from the same file descriptor will  result  in  com-
248*4882a593Smuzhiyun              pleting  the  string.  When a complete string has been read, all
249*4882a593Smuzhiyun              subsequent read operations will return zero bytes and a new file
250*4882a593Smuzhiyun              descriptor needs to be opened to read the value again.
251*4882a593Smuzhiyun
252*4882a593Smuzhiyun       write(2)
253*4882a593Smuzhiyun              A write operation on the file results in setting the register to
254*4882a593Smuzhiyun              the value given in the string. The string  is  parsed  from  the
255*4882a593Smuzhiyun              beginning  to  the first non-numeric character or the end of the
256*4882a593Smuzhiyun              buffer.  Subsequent writes to the same file descriptor overwrite
257*4882a593Smuzhiyun              the previous setting.
258*4882a593Smuzhiyun
259*4882a593Smuzhiyun
260*4882a593SmuzhiyunExamples
261*4882a593Smuzhiyun========
262*4882a593Smuzhiyun       /etc/fstab entry
263*4882a593Smuzhiyun              none      /spu      spufs     gid=spu   0    0
264*4882a593Smuzhiyun
265*4882a593Smuzhiyun
266*4882a593SmuzhiyunAuthors
267*4882a593Smuzhiyun=======
268*4882a593Smuzhiyun       Arnd  Bergmann  <arndb@de.ibm.com>,  Mark  Nutter <mnutter@us.ibm.com>,
269*4882a593Smuzhiyun       Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
270*4882a593Smuzhiyun
271*4882a593SmuzhiyunSee Also
272*4882a593Smuzhiyun========
273*4882a593Smuzhiyun       capabilities(7), close(2), spu_create(2), spu_run(2), spufs(7)
274