diff options
author | Arnd Bergmann <arnd@arndb.de> | 2006-10-04 11:26:19 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-10-04 19:21:01 -0400 |
commit | e1dbff2bafa83f839ef15f51904b0cce9fc89387 (patch) | |
tree | dac3c6bfd2789eae23286b5485d7010de10eefa6 /arch/powerpc | |
parent | 772920e594df25f2011ca49abd9c8b85c4820cdc (diff) |
[POWERPC] spufs: add support for read/write on cntl
Writing to cntl can be used to stop execution on the
spu and to restart it, reading from cntl gives the
contents of the current status register.
The access is always in ascii, as for most other files.
This was always meant to be there, but we had a little
problem with writing to runctl so it was left out so
far.
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/file.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c index b4d38cb65f17..e2c9d48a6804 100644 --- a/arch/powerpc/platforms/cell/spufs/file.c +++ b/arch/powerpc/platforms/cell/spufs/file.c | |||
@@ -211,37 +211,43 @@ static int spufs_cntl_mmap(struct file *file, struct vm_area_struct *vma) | |||
211 | #define spufs_cntl_mmap NULL | 211 | #define spufs_cntl_mmap NULL |
212 | #endif /* !SPUFS_MMAP_4K */ | 212 | #endif /* !SPUFS_MMAP_4K */ |
213 | 213 | ||
214 | static int spufs_cntl_open(struct inode *inode, struct file *file) | 214 | static u64 spufs_cntl_get(void *data) |
215 | { | 215 | { |
216 | struct spufs_inode_info *i = SPUFS_I(inode); | 216 | struct spu_context *ctx = data; |
217 | struct spu_context *ctx = i->i_ctx; | 217 | u64 val; |
218 | 218 | ||
219 | file->private_data = ctx; | 219 | spu_acquire(ctx); |
220 | file->f_mapping = inode->i_mapping; | 220 | val = ctx->ops->status_read(ctx); |
221 | ctx->cntl = inode->i_mapping; | 221 | spu_release(ctx); |
222 | return 0; | 222 | |
223 | return val; | ||
223 | } | 224 | } |
224 | 225 | ||
225 | static ssize_t | 226 | static void spufs_cntl_set(void *data, u64 val) |
226 | spufs_cntl_read(struct file *file, char __user *buffer, | ||
227 | size_t size, loff_t *pos) | ||
228 | { | 227 | { |
229 | /* FIXME: read from spu status */ | 228 | struct spu_context *ctx = data; |
230 | return -EINVAL; | 229 | |
230 | spu_acquire(ctx); | ||
231 | ctx->ops->runcntl_write(ctx, val); | ||
232 | spu_release(ctx); | ||
231 | } | 233 | } |
232 | 234 | ||
233 | static ssize_t | 235 | static int spufs_cntl_open(struct inode *inode, struct file *file) |
234 | spufs_cntl_write(struct file *file, const char __user *buffer, | ||
235 | size_t size, loff_t *pos) | ||
236 | { | 236 | { |
237 | /* FIXME: write to runctl bit */ | 237 | struct spufs_inode_info *i = SPUFS_I(inode); |
238 | return -EINVAL; | 238 | struct spu_context *ctx = i->i_ctx; |
239 | |||
240 | file->private_data = ctx; | ||
241 | file->f_mapping = inode->i_mapping; | ||
242 | ctx->cntl = inode->i_mapping; | ||
243 | return simple_attr_open(inode, file, spufs_cntl_get, | ||
244 | spufs_cntl_set, "0x%08lx"); | ||
239 | } | 245 | } |
240 | 246 | ||
241 | static struct file_operations spufs_cntl_fops = { | 247 | static struct file_operations spufs_cntl_fops = { |
242 | .open = spufs_cntl_open, | 248 | .open = spufs_cntl_open, |
243 | .read = spufs_cntl_read, | 249 | .read = simple_attr_read, |
244 | .write = spufs_cntl_write, | 250 | .write = simple_attr_write, |
245 | .mmap = spufs_cntl_mmap, | 251 | .mmap = spufs_cntl_mmap, |
246 | }; | 252 | }; |
247 | 253 | ||