1 .\" Copyright (c) International Business Machines Corp., 2006
3 .\" This program is free software; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
8 .\" This program is distributed in the hope that it will be useful,
9 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
10 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 .\" the GNU General Public License for more details.
13 .\" You should have received a copy of the GNU General Public License
14 .\" along with this program; if not, write to the Free Software
15 .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19 .\" 2005-09-28, created by Arnd Bergmann <arndb@de.ibm.com>
20 .\" 2006-06-16, revised by Eduardo M. Fleury <efleury@br.ibm.com>
21 .\" 2007-07-10, some polishing by mtk
22 .\" 2007-09-28, updates for newer kernels, added example
23 .\" by Jeremy Kerr <jk@ozlabs.org>
25 .\" Japanese Version Copyright (c) 2007 Akihiro MOTOKI
26 .\" all rights reserved.
27 .\" Translated 2007-10-19, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
28 .\" Updated 2008-11-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.04
30 .TH SPU_RUN 2 2007-11-25 Linux "Linux Programmer's Manual"
33 .\"O spu_run \- execute an SPU context
34 spu_run \- SPU コンテキストを実行する
38 .B #include <sys/spu.h>
40 .BI "int spu_run(int " fd ", unsigned int *" npc \
41 ", unsigned int *" event ");"
47 .\"O system call is used on PowerPC machines that implement the
48 .\"O Cell Broadband Engine Architecture in order to access Synergistic
49 .\"O Processor Units (SPUs).
52 .\"O argument is a file descriptor returned by
53 .\"O .BR spu_create (2)
54 .\"O that refers to a specific SPU context.
55 .\"O When the context gets scheduled to a physical SPU,
56 .\"O it starts execution at the instruction pointer passed in
59 システムコールは、Cell Broadband Engine アーキテクチャを実装した
60 PowerPC マシンで Synergistic Processor Units (SPU) にアクセスするために
67 そのコンテキストが物理 SPU に割り当てられると、
69 で渡された命令ポインタ (instruction pointer) から実行が開始される。
71 .\"O Execution of SPU code happens synchronously, meaning that
73 .\"O blocks while the SPU is still running.
74 .\"O If there is a need
75 .\"O to execute SPU code in parallel with other code on either the
76 .\"O main CPU or other SPUs, a new thread of execution must be created
77 .\"O first (e.g., using
78 .\"O .BR pthread_create (3)).
79 SPU コードの実行は同期的 (synchronously) に行われる、つまり
83 SPU コードの実行をメイン CPU や他の SPU と並行して行う必要がある場合は、
84 最初に、その SPU コードを実行する新しいスレッドを、(例えば
85 .BR pthread_create (3)
90 .\"O returns, the current value of the SPU program counter is written to
92 .\"O so successive calls to
98 が返るときには、SPU のプログラムカウンタの現在値が
109 .\"O argument provides a buffer for an extended status code.
111 .\"O context was created with the
112 .\"O .B SPU_CREATE_EVENTS_ENABLED
113 .\"O flag, then this buffer is populated by the Linux kernel before
117 引き数には、拡張ステータスコード用のバッファを指定する。
118 .B SPU_CREATE_EVENTS_ENABLED
119 フラグ付きで SPU コンテキストが作成されると、
121 が返る前に Linux カーネルによりこのバッファに
124 .\"O The status code may be one (or more) of the following constants:
125 ステータスコードには以下の定数が一つ以上入る。
127 .B SPE_EVENT_DMA_ALIGNMENT
128 .\"O A DMA alignment error occurred.
129 DMA (direct memory access) のアライメント・エラーが発生した。
131 .B SPE_EVENT_INVALID_DMA
132 .\"O An invalid MFC DMA command was attempted.
133 無効な MFC (Memory Flow Controller) DMA コマンドを行おうとした。
135 .B SPE_EVENT_SPE_DATA_STORAGE
136 .\"O A DMA storage error occurred.
139 .B SPE_EVENT_SPE_ERROR
140 .\"O An illegal instruction was executed.
144 .\"O is a valid value for the
147 .\"O In this case, the events will not be reported to the calling process.
151 この場合、イベントは呼び出し元のプロセスに報告されない。
152 .\"O .SH RETURN VALUE
156 .\"O returns the value of the
159 .\"O On error it returns \-1 and sets
161 .\"O to one of the error codes listed below.
169 を下記のエラーコードのいずれかに設定する。
173 .\"O register value is a bit mask of status codes and
174 .\"O optionally a 14-bit code returned from the
175 .\"O .BR stop-and-signal
176 .\"O instruction on the SPU.
177 .\"O The bit masks for the status codes
180 レジスタの値は、ステータスコードと SPU の
184 後者の 14 ビットのコードはオプションである。
185 ステータスコードのビットマスクは下記の通りである。
188 .\"O SPU was stopped by a
189 .\"O .BR stop-and-signal
196 .\"O SPU was stopped by a
204 .\"O SPU is waiting for a channel.
208 .\"O SPU is in single-step mode.
209 SPU はシングルステップモードであった。
212 .\"O SPU has tried to execute an invalid instruction.
216 .\"O SPU has tried to access an invalid channel.
217 SPU が不正なチャンネルにアクセスしようとした。
220 .\"O The bits masked with this value contain the code returned from a
221 .\"O .BR stop-and-signal
223 .\"O These bits are only valid if the 0x02 bit is set.
224 この値のマスクを適用して得られたビット値には、
225 stop-and-signal 命令から返されたコードが入っている。
226 これらのビットは 0x02 ビットがセットされている場合にのみ有効である。
230 .\"O has not returned an error, one or more bits among the lower eight
231 .\"O ones are always set.
233 がエラーを返さなかった場合、下位 8 ビットのうち 1 つ以上は
240 .\"O is not a valid file descriptor.
246 .\"O is not a valid pointer, or
248 .\"O is non-NULL and an invalid pointer.
252 が NULL 以外で、しかも無効なポインタである。
255 .\"O A signal occurred while
257 .\"O was in progress; see
261 .\"O value has been updated to the new program counter value if
269 の値は新しいプログラムカウンタの値に更新される。
273 .\"O is not a valid file descriptor returned from
274 .\"O .BR spu_create (2).
278 が返した有効なファイルディスクリプタでない。
281 .\"O There was not enough memory available to handle a page fault
282 .\"O resulting from a Memory Flow Controller (MFC) direct memory access.
283 Memory Flow Controller (MFC) DMA により発生したページフォールトを
287 .\"O The functionality is not provided by the current system, because
288 .\"O either the hardware does not provide SPUs or the spufs module is not
290 機能が動作中のシステムで提供されていない。理由は、
291 ハードウェアで SPU が提供されていないか、
292 spufs モジュールがロードされていないか、のどちらかである。
297 .\"O system call was added to Linux in kernel 2.6.16.
299 システムコールはカーネル 2.6.16 で Linux に追加された。
300 .\"O .SH CONFORMING TO
302 .\"O This call is Linux-specific and only implemented by the PowerPC
304 .\"O Programs using this system call are not portable.
305 このシステムコールは Linux 固有であり、
306 PowerPC アーキテクチャでのみ実装されている。
307 このシステムコールを使ったプログラムは移植性がない。
310 .\"O Glibc does not provide a wrapper for this system call; call it using
311 .\"O .BR syscall (2).
312 .\"O Note however, that
314 .\"O is meant to be used from libraries that implement a more abstract
315 .\"O interface to SPUs, not to be used from regular applications.
317 .\"O .I http://www.bsc.es/projects/deepcomputing/linuxoncell/
318 .\"O for the recommended libraries.
319 glibc はこのシステムコールに対するラッパー関数を提供していない。
323 は より抽象度の高い SPU へのインタフェースを実装するライブラリから
324 利用されることを意図したものであり、通常のアプリケーションから
325 使用は意図されていない。推奨のライブラリについては
326 .I http://www.bsc.es/projects/deepcomputing/linuxoncell/
330 .\"O The following is an example of running a simple, one-instruction SPU
331 .\"O program with the
334 以下は、簡単な 1 命令の SPU プログラムを
336 システムコールを使って実行させる例である。
343 #include <sys/types.h>
346 #define handle_error(msg) \\
347 do { perror(msg); exit(EXIT_FAILURE); } while (0)
351 int context, fd, spu_status;
352 uint32_t instruction, npc;
354 context = spu_create("/spu/example\-context", 0, 0755);
356 handle_error("spu_create");
358 /* write a \(aqstop 0x1234\(aq instruction to the SPU\(aqs
361 instruction = 0x00001234;
363 fd = open("/spu/example\-context/mem", O_RDWR);
365 handle_error("open");
366 write(fd, &instruction, sizeof(instruction));
368 /* set npc to the starting instruction address of the
369 * SPU program. Since we wrote the instruction at the
370 * start of the mem file, the entry point will be 0x0
374 spu_status = spu_run(context, &npc, NULL);
375 if (spu_status == \-1)
376 handle_error("open");
378 /* we should see a status code of 0x1234002:
379 * 0x00000002 (spu was stopped due to stop\-and\-signal)
380 * | 0x12340000 (the stop\-and\-signal code)
382 printf("SPU Status: 0x%08x\\n", spu_status);
388 .\" Arnd Bergmann <arndb@de.ibm.com>, Jeremy Kerr <jk@ozlabs.org>
393 .BR capabilities (7),