]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/spufs.7
libc.7: Add a note on why glibc 2.x uses the soname libc.so.6
[thirdparty/man-pages.git] / man7 / spufs.7
CommitLineData
4875e482 1.\" Copyright (c) International Business Machines Corp., 2006
6282f7bd 2.\"
f0008367 3.\" %%%LICENSE_START(GPLv2+_SW_3_PARA)
4875e482 4.\" This program is free software; you can redistribute it and/or
6282f7bd
MK
5.\" modify it under the terms of the GNU General Public License as
6.\" published by the Free Software Foundation; either version 2 of
7.\" the License, or (at your option) any later version.
8.\"
9.\" This program is distributed in the hope that it will be useful,
4875e482
MK
10.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
6282f7bd
MK
12.\" the GNU General Public License for more details.
13.\"
68fa4398
MK
14.\" You should have received a copy of the GNU General Public
15.\" License along with this manual; if not, see
16.\" <http://www.gnu.org/licenses/>.
8ff7380d 17.\" %%%LICENSE_END
6282f7bd
MK
18.\"
19.\" HISTORY:
20.\" 2005-09-28, created by Arnd Bergmann <arndb@de.ibm.com>,
21.\" Mark Nutter <mnutter@us.ibm.com> and
22.\" Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
23.\" 2006-06-16, revised by Eduardo M. Fleury <efleury@br.ibm.com>
24.\" 2007-07-10, quite a lot of polishing by mtk
4875e482 25.\" 2007-09-28, updates for newer kernels by Jeremy Kerr <jk@ozlabs.org>
6282f7bd 26.\"
a612f2d0 27.TH SPUFS 7 2007-12-20 Linux "Linux Programmer's Manual"
6282f7bd 28.SH NAME
9ee4a2b6 29spufs \- SPU filesystem
6282f7bd 30.SH DESCRIPTION
9ee4a2b6 31The SPU filesystem is used on PowerPC machines that implement the
6282f7bd
MK
32Cell Broadband Engine Architecture in order to access Synergistic
33Processor Units (SPUs).
34
9ee4a2b6 35The filesystem provides a name space similar to POSIX shared
6282f7bd
MK
36memory or message queues.
37Users that have write permissions
9ee4a2b6 38on the filesystem can use
6282f7bd 39.BR spu_create (2)
66516789
MK
40to establish SPU contexts under the
41.B spufs
42root directory.
6282f7bd
MK
43
44Every SPU context is represented by a directory containing
45a predefined set of files.
46These files can be
47used for manipulating the state of the logical SPU.
4875e482 48Users can change permissions on the files, but can't
6282f7bd 49add or remove files.
c634028a 50.SS Mount options
6282f7bd
MK
51.TP
52.B uid=<uid>
4875e482 53Set the user owning the mount point; the default is 0 (root).
6282f7bd
MK
54.TP
55.B gid=<gid>
4875e482
MK
56Set the group owning the mount point; the default is 0 (root).
57.TP
58.B mode=<mode>
66516789
MK
59Set the mode of the top-level directory in
60.BR spufs ,
4875e482
MK
61as an octal mode string.
62The default is 0775.
6282f7bd
MK
63.SS Files
64The files in
66516789 65.B spufs
6282f7bd
MK
66mostly follow the standard behavior for regular system calls like
67.BR read (2)
68or
69.BR write (2),
70but often support only a subset of the operations
9ee4a2b6 71supported on regular filesystems.
6282f7bd
MK
72This list details the supported
73operations and the deviations from the standard behavior described
74in the respective man pages.
75
76All files that support the
77.BR read (2)
78operation also support
79.BR readv (2)
80and all files that support the
81.BR write (2)
82operation also support
83.BR writev (2).
6282f7bd
MK
84All files support the
85.BR access (2)
86and
87.BR stat (2)
88family of operations, but for the latter call,
e0bf9127 89the only fields of the returned
6282f7bd
MK
90.I stat
91structure that contain reliable information are
92.IR st_mode ,
93.IR st_nlink ,
94.IR st_uid ,
95and
96.IR st_gid .
97
98All files support the
99.BR chmod (2)/ fchmod (2)
100and
101.BR chown (2)/ fchown (2)
102operations, but will not be able to grant permissions that contradict
103the possible operations (e.g., read access on the
104.I wbox
105file).
106
107The current set of files is:
108.TP
4875e482
MK
109.I /capabilities
110Contains a comma-delimited string representing the capabilities of this
111SPU context.
112Possible capabilities are:
113.RS
114.TP
115.B sched
116This context may be scheduled.
117.TP
118.B step
119This context can be run in single-step mode, for debugging.
120.PP
121New capabilities flags may be added in the future.
122.RE
123.TP
124.I /mem
6282f7bd
MK
125the contents of the local storage memory of the SPU.
126This can be accessed like a regular shared memory
127file and contains both code and data in the address
128space of the SPU.
129The possible operations on an open
130.I mem
131file are:
132.RS
133.TP
134.BR read "(2), " pread "(2), " write "(2), " pwrite "(2), " lseek (2)
e0bf9127 135These operate as usual, with the exception that
4875e482
MK
136.BR lseek (2),
137.BR write (2),
e0bf9127 138and
6282f7bd
MK
139.BR pwrite (2)
140are not supported beyond the end of the file.
141The file size
142is the size of the local storage of the SPU,
143which is normally 256 kilobytes.
144.TP
145.BR mmap (2)
146Mapping
147.I mem
148into the process address space provides access to the SPU local
149storage within the process address space.
150Only
151.B MAP_SHARED
152mappings are allowed.
153.RE
154.TP
4875e482
MK
155.I /regs
156Contains the saved general-purpose registers of the SPU context.
157This file contains the 128-bit values of each register,
158from register 0 to register 127, in order.
159This allows the general-purpose registers to be
160inspected for debugging.
161
162Reading to or writing from this file requires that the context is
163scheduled out, so use of this file is not recommended in normal
164program operation.
165
166The
167.I regs
168file is not present on contexts that have been created with the
169.B SPU_CREATE_NOSCHED
170flag.
4875e482
MK
171.TP
172.I /mbox
6282f7bd 173The first SPU-to-CPU communication mailbox.
4875e482 174This file is read-only and can be read in units of 4 bytes.
33a0ccb2 175The file can be used only in nonblocking mode \- even
6282f7bd 176.BR poll (2)
4875e482 177cannot be used to block on this file.
e0bf9127 178The only possible operation on an open
6282f7bd
MK
179.I mbox
180file is:
181.RS
182.TP
183.BR read (2)
184If
185.I count
186is smaller than four,
187.BR read (2)
188returns \-1 and sets
189.I errno
190to
191.BR EINVAL .
4875e482
MK
192If there is no data available in the mailbox (i.e., the SPU has not
193sent a mailbox message), the return value is set to \-1 and
6282f7bd
MK
194.I errno
195is set to
196.BR EAGAIN .
197When data
198has been read successfully, four bytes are placed in
199the data buffer and the value four is returned.
200.RE
201.TP
4875e482 202.I /ibox
6282f7bd
MK
203The second SPU-to-CPU communication mailbox.
204This file is similar to the first mailbox file, but can be read
a612f2d0
MK
205in blocking I/O mode, thus calling
206.BR read (2)
207on an open
208.I ibox
209file will block until the SPU has written data to its interrupt mailbox
210channel (unless the file has been opened with
211.BR O_NONBLOCK ,
212see below).
213Also,
6282f7bd 214.BR poll (2)
a612f2d0
MK
215and similar system calls can be used to monitor for the presence
216of mailbox data.
217
e0bf9127 218The possible operations on an open
6282f7bd
MK
219.I ibox
220file are:
221.RS
222.TP
223.BR read (2)
224If
225.I count
226is smaller than four,
227.BR read (2)
228returns \-1 and sets
229.I errno
230to
231.BR EINVAL .
232If there is no data available in the mailbox and the file
233descriptor has been opened with
234.BR O_NONBLOCK ,
235the return value is set to \-1 and
236.I errno
237is set to
238.BR EAGAIN .
239
240If there is no data available in the mailbox and the file
241descriptor has been opened without
242.BR O_NONBLOCK ,
243the call will
244block until the SPU writes to its interrupt mailbox channel.
245When data has been read successfully, four bytes are placed in
246the data buffer and the value four is returned.
247.TP
248.BR poll (2)
e0bf9127 249Poll on the
6282f7bd
MK
250.I ibox
251file returns
252.I "(POLLIN | POLLRDNORM)"
253whenever data is available for reading.
254.RE
255.TP
4875e482 256.I /wbox
6282f7bd 257The CPU-to-SPU communication mailbox.
4875e482 258It is write-only and can be written in units of four bytes.
6282f7bd
MK
259If the mailbox is full,
260.BR write (2)
4875e482 261will block, and
6282f7bd 262.BR poll (2)
4875e482 263can be used to block until the mailbox is available for writing again.
e0bf9127 264The possible operations on an open
6282f7bd
MK
265.I wbox
266file are:
267.RS
268.TP
269.BR write (2)
270If
271.I count
272is smaller than four,
273.BR write (2)
274returns \-1 and sets
275.I errno
276to
277.BR EINVAL .
278If there is no space available in the mailbox and the file
279descriptor has been opened with
280.BR O_NONBLOCK ,
281the return
282value is set to \-1 and
283.I errno
284is set to
285.BR EAGAIN .
286
287If there is no space available in the mailbox and the file
288descriptor has been opened without
289.BR O_NONBLOCK ,
b2ca3ebe 290the call will block until the SPU reads from its
4875e482
MK
291PPE (PowerPC Processing Element)
292mailbox channel.
e0bf9127 293When data has been written successfully,
6282f7bd
MK
294the system call returns four as its function result.
295.TP
296.BR poll (2)
e0bf9127 297A poll on the
6282f7bd
MK
298.I wbox
299file returns
300.I "(POLLOUT | POLLWRNORM)"
301whenever space is available for writing.
302.RE
303.TP
4875e482 304.IR /mbox_stat ", " /ibox_stat ", " /wbox_stat
6282f7bd 305These are read-only files that contain the length of the current
88879aeb 306queue of each mailbox\(emthat is, how many words can be read from
6282f7bd
MK
307.IR mbox " or " ibox
308or how many words can be written to
e0bf9127 309.I wbox
6282f7bd
MK
310without blocking.
311The files can be read only in four-byte units and return
312a big-endian binary integer number.
4875e482 313The only possible operation on an open
6282f7bd 314.I *box_stat
4875e482 315file is:
6282f7bd
MK
316.RS
317.TP
318.BR read (2)
319If
320.I count
321is smaller than four,
322.BR read (2)
323returns \-1 and sets
324.I errno
325to
c7992edc 326.BR EINVAL .
6282f7bd
MK
327Otherwise, a four-byte value is placed in the data buffer.
328This value is the number of elements that can be read from (for
4875e482 329.IR mbox_stat
6282f7bd
MK
330and
331.IR ibox_stat )
332or written to (for
333.IR wbox_stat )
4875e482
MK
334the respective mailbox without blocking or returning an
335.BR EAGAIN
6282f7bd
MK
336error.
337.RE
338.TP
4875e482
MK
339.IR /npc ", " /decr ", " /decr_status ", " /spu_tag_mask ", " \
340/event_mask ", " /event_status ", " /srr0 ", " /lslr
341Internal registers of the SPU.
342These files contain an ASCII string
343representing the hex value of the specified register.
344Reads and writes on these
345files (except for
346.IR npc ,
347see below) require that the SPU context be scheduled out,
348so frequent access to
349these files is not recommended for normal program operation.
6282f7bd
MK
350.IP
351The contents of these files are:
352.RS
353.TP 16
354.I npc
33a0ccb2 355Next Program Counter \- valid only when the SPU is in a stopped state.
6282f7bd
MK
356.TP
357.I decr
358SPU Decrementer
359.TP
360.I decr_status
361Decrementer Status
362.TP
363.I spu_tag_mask
364MFC tag mask for SPU DMA
365.TP
366.I event_mask
367Event mask for SPU interrupts
368.TP
4875e482
MK
369.I event_status
370Number of SPU events pending (read-only)
371.TP
6282f7bd
MK
372.I srr0
373Interrupt Return address register
4875e482
MK
374.TP
375.I lslr
376Local Store Limit Register
6282f7bd
MK
377.RE
378.IP
4875e482 379The possible operations on these files are:
6282f7bd
MK
380.RS
381.TP
382.BR read (2)
4875e482
MK
383Reads the current register value.
384If the register value is larger than the buffer passed to the
6282f7bd 385.BR read (2)
4875e482
MK
386system call, subsequent reads will continue reading from the same
387buffer, until the end of the buffer is reached.
388
6282f7bd 389When a complete string has been read, all subsequent read operations
e0bf9127 390will return zero bytes and a new file descriptor needs to be opened
6282f7bd
MK
391to read a new value.
392.TP
393.BR write (2)
e0bf9127 394A
6282f7bd 395.BR write (2)
e0bf9127 396operation on the file sets the register to the
6282f7bd 397value given in the string.
e0bf9127 398The string is parsed from the beginning
80c9146c 399until the first nonnumeric character or the end of the buffer.
e0bf9127 400Subsequent writes to the same file descriptor overwrite the
6282f7bd 401previous setting.
4875e482
MK
402
403Except for the
404.I npc
405file, these files are not present on contexts that have been created with
406the
407.B SPU_CREATE_NOSCHED
408flag.
6282f7bd
MK
409.RE
410.TP
4875e482 411.IR /fpcr
e0bf9127 412This file provides access to the Floating Point Status and
4875e482
MK
413Control Register (fcpr) as a binary, four-byte file.
414The operations on the
6282f7bd
MK
415.I fpcr
416file are:
417.RS
418.TP
419.BR read (2)
420If
421.I count
422is smaller than four,
423.BR read (2)
424returns \-1 and sets
425.I errno
426to
427.BR EINVAL .
428Otherwise, a four-byte value is placed in the data buffer;
429this is the current value of the
430.I fpcr
431register.
432.TP
433.BR write (2)
434If
435.I count
436is smaller than four,
437.BR write (2)
438returns \-1 and sets
439.I errno
440to
441.BR EINVAL .
442Otherwise, a four-byte value is copied from the data buffer,
443updating the value of the
444.I fpcr
445register.
446.RE
447.TP
4875e482 448.IR /signal1 ", " /signal2
6282f7bd
MK
449The files provide access to the two signal notification channels
450of an SPU.
4875e482 451These are read-write files that operate on four-byte words.
6282f7bd
MK
452Writing to one of these files triggers an interrupt on the SPU.
453The value written to the signal files can
454be read from the SPU through a channel read or from
455host user space through the file.
456After the value has been read by the SPU, it is reset to zero.
e0bf9127 457The possible operations on an open
6282f7bd
MK
458.I signal1
459or
460.I signal2
461file are:
462.RS
463.TP
464.BR read (2)
465If
466.I count
467is smaller than four,
468.BR read (2)
469returns \-1 and sets
470.I errno
471to
472.BR EINVAL .
473Otherwise, a four-byte value is placed in the data buffer;
474this is the current value of the specified signal notification
475register.
476.TP
477.BR write (2)
478If
479.I count
480is smaller than four,
481.BR write (2)
482returns \-1 and sets
483.I errno
484to
485.BR EINVAL .
486Otherwise, a four-byte value is copied from the data buffer,
e0bf9127 487updating the value of the specified signal notification
6282f7bd 488register.
e0bf9127
MK
489The signal notification register will either be replaced with
490the input data or will be updated to the bitwise OR operation
6282f7bd
MK
491of the old value and the input data, depending on the contents
492of the
4875e482 493.IR signal1_type
6282f7bd 494or
4875e482 495.IR signal2_type
6282f7bd
MK
496files respectively.
497.RE
498.TP
4875e482 499.IR /signal1_type ", " /signal2_type
6282f7bd 500These two files change the behavior of the
4875e482 501.IR signal1
6282f7bd 502and
4875e482 503.IR signal2
6282f7bd 504notification files.
4875e482
MK
505They contain a numeric ASCII string which is read
506as either "1" or "0".
6282f7bd
MK
507In mode 0 (overwrite), the hardware replaces the contents
508of the signal channel with the data that is written to it.
509In mode 1 (logical OR), the hardware accumulates the bits
510that are subsequently written to it.
e0bf9127 511The possible operations on an open
6282f7bd
MK
512.I signal1_type
513or
514.I signal2_type
515file are:
516.RS
517.TP
518.BR read (2)
519When the count supplied to the
520.BR read (2)
4875e482
MK
521call is shorter than the required length for the digit (plus a newline
522character), subsequent reads from the same file descriptor will
523complete the string.
6282f7bd
MK
524When a complete string has been read, all subsequent read operations
525will return zero bytes and a new file descriptor needs to be opened
526to read the value again.
527.TP
528.BR write (2)
e0bf9127 529A
6282f7bd
MK
530.BR write (2)
531operation on the file sets the register to the
532value given in the string.
533The string is parsed from the beginning
80c9146c 534until the first nonnumeric character or the end of the buffer.
6282f7bd
MK
535Subsequent writes to the same file descriptor overwrite the
536previous setting.
537.RE
4875e482
MK
538.TP
539.IR /mbox_info ", " /ibox_info ", " /wbox_info ", " /dma_into ", " /proxydma_info
540Read-only files that contain the saved state of the SPU mailboxes and
541DMA queues.
542This allows the SPU status to be inspected, mainly for debugging.
543The
544.I mbox_info
545and
546.I ibox_info
547files each contain the four-byte mailbox message that has been written
548by the SPU.
549If no message has been written to these mailboxes, then
550contents of these files is undefined.
551The
552.IR mbox_stat ,
553.I ibox_stat
554and
555.I wbox_stat
556files contain the available message count.
557
558The
559.I wbox_info
560file contains an array of four-byte mailbox messages, which have been
561sent to the SPU.
562With current CBEA machines, the array is four items in
563length, so up to 4 * 4 = 16 bytes can be read from this file.
564If any mailbox queue entry is empty,
565then the bytes read at the corresponding location are undefined.
566
567The
568.I dma_info
569file contains the contents of the SPU MFC DMA queue, represented as the
570following structure:
571
088a639b 572.in +4n
4875e482
MK
573.nf
574struct spu_dma_info {
575 uint64_t dma_info_type;
576 uint64_t dma_info_mask;
577 uint64_t dma_info_status;
578 uint64_t dma_info_stall_and_notify;
579 uint64_t dma_info_atomic_command_status;
580 struct mfc_cq_sr dma_info_command_data[16];
581};
582.fi
583.in
584
585The last member of this data structure is the actual DMA queue,
586containing 16 entries.
587The
588.I mfc_cq_sr
589structure is defined as:
590
088a639b 591.in +4n
4875e482
MK
592.nf
593struct mfc_cq_sr {
594 uint64_t mfc_cq_data0_RW;
595 uint64_t mfc_cq_data1_RW;
596 uint64_t mfc_cq_data2_RW;
597 uint64_t mfc_cq_data3_RW;
598};
599.fi
600.in
601
602The
603.I proxydma_info
604file contains similar information, but describes the proxy DMA queue
605(i.e., DMAs initiated by entities outside the SPU) instead.
606The file is in the following format:
607
088a639b 608.in +4n
4875e482
MK
609.nf
610struct spu_proxydma_info {
611 uint64_t proxydma_info_type;
612 uint64_t proxydma_info_mask;
613 uint64_t proxydma_info_status;
614 struct mfc_cq_sr proxydma_info_command_data[8];
615};
616.fi
617.in
618
619Accessing these files requires that the SPU context is scheduled out -
620frequent use can be inefficient.
621These files should not be used for normal program operation.
622
623These files are not present on contexts that have been created with the
624.B SPU_CREATE_NOSCHED
625flag.
4875e482
MK
626.TP
627.IR /cntl
628This file provides access to the SPU Run Control and SPU status
629registers, as an ASCII string.
630The following operations are supported:
631.RS
632.TP
633.BR read (2)
634Reads from the
635.I cntl
636file will return an ASCII string with the hex
637value of the SPU Status register.
638.TP
639.BR write (2)
640Writes to the
641.I cntl
642file will set the context's SPU Run Control register.
643.RE
644.TP
645.I /mfc
646Provides access to the Memory Flow Controller of the SPU.
647Reading from the file returns the contents of the
648SPU's MFC Tag Status register, and
649writing to the file initiates a DMA from the MFC.
650The following operations are supported:
651.RS
652.TP
653.BR write (2)
654Writes to this file need to be in the format of a MFC DMA command,
655defined as follows:
656
088a639b 657.in +4n
4875e482
MK
658.nf
659struct mfc_dma_command {
660 int32_t pad; /* reserved */
661 uint32_t lsa; /* local storage address */
662 uint64_t ea; /* effective address */
663 uint16_t size; /* transfer size */
664 uint16_t tag; /* command tag */
665 uint16_t class; /* class ID */
666 uint16_t cmd; /* command opcode */
667};
668.fi
669.in
670
671Writes are required to be exactly
672.I sizeof(struct mfc_dma_command)
673bytes in size.
674The command will be sent to the SPU's MFC proxy queue, and the
675tag stored in the kernel (see below).
676.TP
677.BR read (2)
678Reads the contents of the tag status register.
679If the file is opened in blocking mode (i.e., without
680.BR O_NONBLOCK ),
681then the read will block until a
682DMA tag (as performed by a previous write) is complete.
ff40dbb3 683In nonblocking mode,
4875e482
MK
684the MFC tag status register will be returned without waiting.
685.TP
686.BR poll (2)
687Calling
688.BR poll (2)
689on the
690.I mfc
691file will block until a new DMA can be
692started (by checking for
693.BR POLLOUT )
694or until a previously started DMA
695(by checking for
696.BR POLLIN )
697has been completed.
698
699.I /mss
a6c99d33 700Provides access to the MFC MultiSource Synchronization (MSS) facility.
4875e482
MK
701By
702.BR mmap (2)-ing
a46458f9 703this file, processes can access the MSS area of the SPU.
4875e482
MK
704
705The following operations are supported:
706.TP
707.BR mmap (2)
708Mapping
709.B mss
710into the process address space gives access to the SPU MSS area
711within the process address space.
712Only
713.B MAP_SHARED
714mappings are allowed.
715.RE
716.TP
717.I /psmap
718Provides access to the whole problem-state mapping of the SPU.
719Applications can use this area to interface to the SPU, rather than
66516789
MK
720writing to individual register files in
721.BR spufs .
4875e482
MK
722
723The following operations are supported:
724.RS
725.TP
726.BR mmap (2)
727Mapping
59bd36b0 728.B psmap
4875e482
MK
729gives a process a direct map of the SPU problem state area.
730Only
731.B MAP_SHARED
732mappings are supported.
733.RE
734.TP
735.I /phys-id
736Read-only file containing the physical SPU number that the SPU context
737is running on.
738When the context is not running, this file contains the
c3074d70 739string "\-1".
4875e482
MK
740
741The physical SPU number is given by an ASCII hex string.
4875e482
MK
742.TP
743.I /object-id
744Allows applications to store (or retrieve) a single 64-bit ID into the
745context.
746This ID is later used by profiling tools to uniquely identify
747the context.
748.RS
749.TP
750.BR write (2)
751By writing an ASCII hex value into this file, applications can set the
752object ID of the SPU context.
753Any previous value of the object ID is overwritten.
754.TP
755.BR read (2)
756Reading this file gives an ASCII hex string representing the object ID
757for this SPU context.
deb39835 758.RE
6282f7bd
MK
759.SH EXAMPLE
760.TP
761.IR /etc/fstab " entry"
762none /spu spufs gid=spu 0 0
763.\" .SH AUTHORS
4875e482
MK
764.\" Arnd Bergmann <arndb@de.ibm.com>, Mark Nutter <mnutter@us.ibm.com>,
765.\" Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, Jeremy Kerr <jk@ozlabs.org>
6282f7bd
MK
766.SH SEE ALSO
767.BR close (2),
768.BR spu_create (2),
4875e482 769.BR spu_run (2),
173fe7e7
DP
770.BR capabilities (7)
771
4875e482 772.I The Cell Broadband Engine Architecture (CBEA) specification