2005-11-15 23:53:48 +03:00
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/mount.h>
|
|
|
|
#include <linux/namei.h>
|
|
|
|
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
|
|
|
|
#include "spufs.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sys_spu_run - run code loaded into an SPU
|
|
|
|
*
|
|
|
|
* @unpc: next program counter for the SPU
|
|
|
|
* @ustatus: status of the SPU
|
|
|
|
*
|
|
|
|
* This system call transfers the control of execution of a
|
|
|
|
* user space thread to an SPU. It will return when the
|
|
|
|
* SPU has finished executing or when it hits an error
|
|
|
|
* condition and it will be interrupted if a signal needs
|
|
|
|
* to be delivered to a handler in user space.
|
|
|
|
*
|
|
|
|
* The next program counter is set to the passed value
|
|
|
|
* before the SPU starts fetching code and the user space
|
|
|
|
* pointer gets updated with the new value when returning
|
|
|
|
* from kernel space.
|
|
|
|
*
|
|
|
|
* The status value returned from spu_run reflects the
|
|
|
|
* value of the spu_status register after the SPU has stopped.
|
|
|
|
*
|
|
|
|
*/
|
2006-01-12 02:07:11 +03:00
|
|
|
static long do_spu_run(struct file *filp,
|
|
|
|
__u32 __user *unpc,
|
|
|
|
__u32 __user *ustatus)
|
2005-11-15 23:53:48 +03:00
|
|
|
{
|
|
|
|
long ret;
|
|
|
|
struct spufs_inode_info *i;
|
|
|
|
u32 npc, status;
|
|
|
|
|
|
|
|
ret = -EFAULT;
|
2006-10-04 19:26:14 +04:00
|
|
|
if (get_user(npc, unpc))
|
2005-11-15 23:53:48 +03:00
|
|
|
goto out;
|
|
|
|
|
2006-01-04 22:31:23 +03:00
|
|
|
/* check if this file was created by spu_create */
|
2005-11-15 23:53:48 +03:00
|
|
|
ret = -EINVAL;
|
2006-01-04 22:31:23 +03:00
|
|
|
if (filp->f_op != &spufs_context_fops)
|
2005-11-15 23:53:48 +03:00
|
|
|
goto out;
|
|
|
|
|
2006-12-08 13:37:30 +03:00
|
|
|
i = SPUFS_I(filp->f_path.dentry->d_inode);
|
2007-07-20 23:39:42 +04:00
|
|
|
ret = spufs_run_spu(i->i_ctx, &npc, &status);
|
2005-11-15 23:53:48 +03:00
|
|
|
|
2006-10-04 19:26:14 +04:00
|
|
|
if (put_user(npc, unpc))
|
|
|
|
ret = -EFAULT;
|
|
|
|
|
|
|
|
if (ustatus && put_user(status, ustatus))
|
2005-11-15 23:53:48 +03:00
|
|
|
ret = -EFAULT;
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-09-19 08:38:12 +04:00
|
|
|
static long do_spu_create(const char __user *pathname, unsigned int flags,
|
|
|
|
mode_t mode, struct file *neighbor)
|
2005-11-15 23:53:48 +03:00
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
tmp = getname(pathname);
|
|
|
|
ret = PTR_ERR(tmp);
|
|
|
|
if (!IS_ERR(tmp)) {
|
|
|
|
struct nameidata nd;
|
|
|
|
|
2008-08-03 06:40:42 +04:00
|
|
|
ret = path_lookup(tmp, LOOKUP_PARENT, &nd);
|
2005-11-15 23:53:48 +03:00
|
|
|
if (!ret) {
|
2008-08-03 06:40:42 +04:00
|
|
|
nd.flags |= LOOKUP_OPEN | LOOKUP_CREATE;
|
2007-07-20 23:39:47 +04:00
|
|
|
ret = spufs_create(&nd, flags, mode, neighbor);
|
2008-02-15 06:34:35 +03:00
|
|
|
path_put(&nd.path);
|
2005-11-15 23:53:48 +03:00
|
|
|
}
|
|
|
|
putname(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct spufs_calls spufs_calls = {
|
2007-07-20 23:39:47 +04:00
|
|
|
.create_thread = do_spu_create,
|
2005-11-15 23:53:48 +03:00
|
|
|
.spu_run = do_spu_run,
|
2007-09-19 08:38:12 +04:00
|
|
|
.coredump_extra_notes_size = spufs_coredump_extra_notes_size,
|
|
|
|
.coredump_extra_notes_write = spufs_coredump_extra_notes_write,
|
2007-12-14 17:27:30 +03:00
|
|
|
.notify_spus_active = do_notify_spus_active,
|
2005-11-15 23:53:48 +03:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
};
|