blob: 67aff57faf605098f8820ddb92ae40c6339f012f [file] [log] [blame]
Arnd Bergmann67207b92005-11-15 15:53:48 -05001/*
2 * SPU file system
3 *
4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
5 *
6 * Author: Arnd Bergmann <arndb@de.ibm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22#ifndef SPUFS_H
23#define SPUFS_H
24
25#include <linux/kref.h>
26#include <linux/rwsem.h>
27#include <linux/spinlock.h>
28#include <linux/fs.h>
29
30#include <asm/spu.h>
Mark Nutter5473af02005-11-15 15:53:49 -050031#include <asm/spu_csa.h>
Arnd Bergmann67207b92005-11-15 15:53:48 -050032
33/* The magic number for our file system */
34enum {
35 SPUFS_MAGIC = 0x23c9b64e,
36};
37
38struct spu_context {
39 struct spu *spu; /* pointer to a physical SPU */
Mark Nutter5473af02005-11-15 15:53:49 -050040 struct spu_state csa; /* SPU context save area. */
Arnd Bergmann67207b92005-11-15 15:53:48 -050041 struct rw_semaphore backing_sema; /* protects the above */
42 spinlock_t mmio_lock; /* protects mmio access */
43
44 struct kref kref;
45};
46
47struct spufs_inode_info {
48 struct spu_context *i_ctx;
49 struct inode vfs_inode;
50};
51#define SPUFS_I(inode) \
52 container_of(inode, struct spufs_inode_info, vfs_inode)
53
54extern struct tree_descr spufs_dir_contents[];
55
56/* system call implementation */
57long spufs_run_spu(struct file *file,
58 struct spu_context *ctx, u32 *npc, u32 *status);
59long spufs_create_thread(struct nameidata *nd, const char *name,
60 unsigned int flags, mode_t mode);
61
62/* context management */
63struct spu_context * alloc_spu_context(void);
64void destroy_spu_context(struct kref *kref);
65struct spu_context * get_spu_context(struct spu_context *ctx);
66int put_spu_context(struct spu_context *ctx);
67
68void spu_acquire(struct spu_context *ctx);
69void spu_release(struct spu_context *ctx);
70void spu_acquire_runnable(struct spu_context *ctx);
71void spu_acquire_saved(struct spu_context *ctx);
72
73#endif