[PATCH] spufs: serialize sys_spu_run per spu
[linux-2.6/cjktty.git] / arch / powerpc / platforms / cell / spufs / spufs.h
blobb504744508198dcb82301dd9cfc81843a12e04e1
1 /*
2 * SPU file system
4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
6 * Author: Arnd Bergmann <arndb@de.ibm.com>
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.
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.
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.
22 #ifndef SPUFS_H
23 #define SPUFS_H
25 #include <linux/kref.h>
26 #include <linux/rwsem.h>
27 #include <linux/spinlock.h>
28 #include <linux/fs.h>
30 #include <asm/spu.h>
31 #include <asm/spu_csa.h>
33 /* The magic number for our file system */
34 enum {
35 SPUFS_MAGIC = 0x23c9b64e,
38 struct spu_context_ops;
40 #define SPU_CONTEXT_PREEMPT_nr 0UL
41 #define SPU_CONTEXT_PREEMPT (1UL << SPU_CONTEXT_PREEMPT_nr)
43 struct spu_context {
44 struct spu *spu; /* pointer to a physical SPU */
45 struct spu_state csa; /* SPU context save area. */
46 spinlock_t mmio_lock; /* protects mmio access */
47 struct address_space *local_store;/* local store backing store */
49 enum { SPU_STATE_RUNNABLE, SPU_STATE_SAVED } state;
50 struct rw_semaphore state_sema;
51 struct semaphore run_sema;
53 struct mm_struct *owner;
55 struct kref kref;
56 wait_queue_head_t ibox_wq;
57 wait_queue_head_t wbox_wq;
58 wait_queue_head_t stop_wq;
59 struct fasync_struct *ibox_fasync;
60 struct fasync_struct *wbox_fasync;
61 struct spu_context_ops *ops;
62 struct work_struct reap_work;
63 u64 flags;
66 /* SPU context query/set operations. */
67 struct spu_context_ops {
68 int (*mbox_read) (struct spu_context * ctx, u32 * data);
69 u32(*mbox_stat_read) (struct spu_context * ctx);
70 unsigned int (*mbox_stat_poll)(struct spu_context *ctx,
71 unsigned int events);
72 int (*ibox_read) (struct spu_context * ctx, u32 * data);
73 int (*wbox_write) (struct spu_context * ctx, u32 data);
74 u32(*signal1_read) (struct spu_context * ctx);
75 void (*signal1_write) (struct spu_context * ctx, u32 data);
76 u32(*signal2_read) (struct spu_context * ctx);
77 void (*signal2_write) (struct spu_context * ctx, u32 data);
78 void (*signal1_type_set) (struct spu_context * ctx, u64 val);
79 u64(*signal1_type_get) (struct spu_context * ctx);
80 void (*signal2_type_set) (struct spu_context * ctx, u64 val);
81 u64(*signal2_type_get) (struct spu_context * ctx);
82 u32(*npc_read) (struct spu_context * ctx);
83 void (*npc_write) (struct spu_context * ctx, u32 data);
84 u32(*status_read) (struct spu_context * ctx);
85 char*(*get_ls) (struct spu_context * ctx);
86 void (*runcntl_write) (struct spu_context * ctx, u32 data);
87 void (*runcntl_stop) (struct spu_context * ctx);
90 extern struct spu_context_ops spu_hw_ops;
91 extern struct spu_context_ops spu_backing_ops;
93 struct spufs_inode_info {
94 struct spu_context *i_ctx;
95 struct inode vfs_inode;
97 #define SPUFS_I(inode) \
98 container_of(inode, struct spufs_inode_info, vfs_inode)
100 extern struct tree_descr spufs_dir_contents[];
102 /* system call implementation */
103 long spufs_run_spu(struct file *file,
104 struct spu_context *ctx, u32 *npc, u32 *status);
105 long spufs_create_thread(struct nameidata *nd, const char *name,
106 unsigned int flags, mode_t mode);
107 extern struct file_operations spufs_context_fops;
109 /* context management */
110 struct spu_context * alloc_spu_context(struct address_space *local_store);
111 void destroy_spu_context(struct kref *kref);
112 struct spu_context * get_spu_context(struct spu_context *ctx);
113 int put_spu_context(struct spu_context *ctx);
114 void spu_unmap_mappings(struct spu_context *ctx);
116 void spu_forget(struct spu_context *ctx);
117 void spu_acquire(struct spu_context *ctx);
118 void spu_release(struct spu_context *ctx);
119 int spu_acquire_runnable(struct spu_context *ctx);
120 void spu_acquire_saved(struct spu_context *ctx);
122 int spu_activate(struct spu_context *ctx, u64 flags);
123 void spu_deactivate(struct spu_context *ctx);
124 void spu_yield(struct spu_context *ctx);
125 int __init spu_sched_init(void);
126 void __exit spu_sched_exit(void);
128 size_t spu_wbox_write(struct spu_context *ctx, u32 data);
129 size_t spu_ibox_read(struct spu_context *ctx, u32 *data);
131 /* irq callback funcs. */
132 void spufs_ibox_callback(struct spu *spu);
133 void spufs_wbox_callback(struct spu *spu);
134 void spufs_stop_callback(struct spu *spu);
136 #endif