20 #include <linux/device.h>
21 #include <linux/kernel.h>
24 #include <asm/uaccess.h>
25 #include <linux/list.h>
27 #include <linux/elf.h>
32 #include <linux/poll.h>
33 #include <linux/sched.h>
34 #include <linux/wait.h>
37 #include <asm/cacheflush.h>
40 #include <asm/processor.h>
48 static struct chan_waitqueues {
56 static int sp_stopping;
60 static void rtlx_dispatch(
void)
71 unsigned int vpeflags;
84 wake_up(&channel_wqs[i].lx_queue);
85 wake_up(&channel_wqs[i].rt_queue);
91 static void __used dump_rtlx(
void)
100 printk(
" rt_state %d lx_state %d buffer_size %d\n",
103 printk(
" rt_read %d rt_write %d\n",
106 printk(
" lx_read %d lx_write %d\n",
115 static int rtlx_init(
struct rtlx_info *rtlxi)
129 static void starting(
int vpe)
142 static void stopping(
int vpe)
159 if (index >= RTLX_CHANNELS) {
180 "opened with O_NONBLOCK\n");
193 &channel_wqs[index].lx_queue,
198 if (!signal_pending(
current)) {
207 pr_err(
" *vpe_get_shared is NULL. "
208 "Has an SP program been loaded?\n");
214 if ((
unsigned int)*p <
KSEG0) {
216 "invalid pointer maybe an error code %d\n",
222 if ((ret = rtlx_init(*p)) < 0)
246 pr_err(
"rtlx_release() with null rtlx\n");
283 static inline int write_spacefree(
int read,
int write,
int size)
293 return ((read + size - write) % size) - 1;
308 unsigned long failed;
349 unsigned long failed;
363 count =
min(count, (
size_t)write_spacefree(rt_read, rt->
rt_write,
395 static int file_release(
struct inode *inode,
struct file *filp)
403 unsigned int mask = 0;
405 minor = iminor(file->
f_path.dentry->d_inode);
407 poll_wait(file, &channel_wqs[minor].rt_queue, wait);
408 poll_wait(file, &channel_wqs[minor].lx_queue, wait);
427 int minor = iminor(file->
f_path.dentry->d_inode);
437 static ssize_t file_write(
struct file *file,
const char __user * buffer,
438 size_t count, loff_t * ppos)
443 minor = iminor(file->
f_path.dentry->d_inode);
466 .release = file_release,
474 .handler = rtlx_interrupt,
480 static char register_chrdev_failed[]
__initdata =
481 KERN_ERR "rtlx_module_init: unable to register device\n";
483 static int __init rtlx_module_init(
void)
489 printk(
"VPE loader: not a MIPS MT capable processor\n");
495 "initializing RTLX.\nPass maxtcs=<n> argument as kernel "
501 major = register_chrdev(0,
module_name, &rtlx_fops);
503 printk(register_chrdev_failed);
530 pr_err(
"APRP RTLX init on non-vectored-interrupt processor\n");
547 static void __exit rtlx_module_exit(
void)