import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.git] / drivers / sgi / char / rrm.c
1 /*
2  * Linux Rendering Resource Manager
3  *
4  *          Implements the SGI-compatible rendering resource manager.
5  *          This takes care of implementing the virtualized video hardware
6  *          access required for OpenGL direct rendering.
7  *
8  * Author:  Miguel de Icaza (miguel@nuclecu.unam.mx)
9  *
10  * Fixes:
11  */
12 #include <linux/module.h>
13
14 #include <asm/uaccess.h>
15 #include <asm/rrm.h>
16
17
18 int
19 rrm_open_rn (int rnid, void *arg)
20 {
21         return 0;
22 }
23
24 int
25 rrm_close_rn (int rnid, void *arg)
26 {
27         return 0;
28 }
29
30 int
31 rrm_bind_proc_to_rn (int rnid, void *arg)
32 {
33         return 0;
34 }
35
36 typedef int (*rrm_function )(void *arg);
37
38 struct {
39         int (*r_fn)(int rnid, void *arg);
40         int arg_size;
41 } rrm_functions [] = {
42         { rrm_open_rn,         sizeof (struct RRM_OpenRN) },
43         { rrm_close_rn,        sizeof (struct RRM_CloseRN) },
44         { rrm_bind_proc_to_rn, sizeof (struct RRM_BindProcToRN) }
45 };
46
47 #define RRM_FUNCTIONS (sizeof (rrm_functions)/sizeof (rrm_functions [0]))
48
49 /* cmd is a number in the range [0..RRM_CMD_LIMIT-RRM_BASE] */
50 int
51 rrm_command (unsigned int cmd, void *arg)
52 {
53         int i, rnid;
54
55         if (cmd > RRM_FUNCTIONS){
56                 printk ("Called unimplemented rrm ioctl: %d\n", cmd + RRM_BASE);
57                 return -EINVAL;
58         }
59         i = verify_area (VERIFY_READ, arg, rrm_functions [cmd].arg_size);
60         if (i) return i;
61
62         if (__get_user (rnid, (int *) arg))
63                 return -EFAULT;
64         return (*(rrm_functions [cmd].r_fn))(rnid, arg);
65 }
66
67 int
68 rrm_close (struct inode *inode, struct file *file)
69 {
70         /* This routine is invoked when the device is closed */
71         return 0;
72 }
73
74 EXPORT_SYMBOL(rrm_command);
75 EXPORT_SYMBOL(rrm_close);