File: /usr/src/linux/include/asm-mips/shmiq.h

1     /*
2      * Please note that the comments on this file may be out of date
3      * and that they represent what I have figured about the shmiq device
4      * so far in IRIX.
5      *
6      * This also contains some streams and idev bits.
7      *
8      * They may contain errors, please, refer to the source code of the Linux  
9      * kernel for a definitive answer on what we have implemented
10      *
11      * Miguel.
12      */
13     
14     /* STREAMs ioctls */
15     #define STRIOC    ('S' << 8)
16     #define I_STR     (STRIOC | 010)
17     #define I_PUSH    (STRIOC | 02)
18     #define I_LINK    (STRIOC | 014)
19     #define I_UNLINK  (STRIOC | 015)
20     
21     /* Data structure passed on I_STR ioctls */
22     struct strioctl {
23             int     ic_cmd;                 /* streams ioctl command */
24             int     ic_timout;              /* timeout */
25             int     ic_len;                 /* lenght of data */
26             void    *ic_dp;                 /* data */
27     };
28     
29     /*
30      * For mapping the shared memory input queue, you have to:
31      *
32      * 1. Map /dev/zero for the number of bytes you want to use
33      *    for your shared memory input queue plus the size of the
34      *    sharedMemoryInputQueue structure + 4 (I still have not figured
35      *    what this one is for
36      *
37      * 2. Open /dev/shmiq
38      *
39      * 3. Open /dev/qcntlN N is [0..Nshmiqs]
40      *
41      * 4. Fill a shmiqreq structure.  user_vaddr should point to the return
42      *    address from the /dev/zero mmap.  Arg is the number of shmqevents
43      *    that fit into the /dev/zero region (remember that at the beginning there
44      *    is a sharedMemoryInputQueue header).
45      *
46      * 5. Issue the ioctl (qcntlfd, QIOCATTACH, &your_shmiqreq);
47      */
48     
49     struct shmiqreq {
50     	char *user_vaddr;
51     	int  arg;
52     };
53     
54     /* map the shmiq into the process address space */
55     #define QIOCATTACH       _IOW('Q',1,struct shmiqreq)
56     
57     /* remove mappings */
58     #define QIOCDETACH       _IO('Q',2)
59     
60     /*
61      * A shared memory input queue event.
62      */
63     struct shmqdata {
64     	unsigned char device;          /* device major */
65             unsigned char which;           /* device minor */
66             unsigned char type;            /* event type */
67             unsigned char flags;           /* little event data */
68             union {
69                 int pos;                   /* big event data */
70                 short ptraxis [2];         /* event data for PTR events */
71             } un;
72     };
73     
74     /* indetifies the shmiq and the device */
75     struct shmiqlinkid {
76             short int devminor;
77             short int index;
78     };
79     
80     struct shmqevent {
81     	union {
82                     int time;
83                     struct shmiqlinkid id;
84             } un ;
85             struct shmqdata data ;
86     };
87     
88     /*
89      * sharedMemoryInputQueue: this describes the shared memory input queue.
90      *
91      * head   is the user index into the events, user can modify this one.
92      * tail   is managed by the kernel.
93      * flags  is one of SHMIQ_OVERFLOW or SHMIQ_CORRUPTED
94      *        if OVERFLOW is set it seems ioctl QUIOCSERVICED should be called 
95      *        to notify the kernel.
96      * events where the kernel sticks the events.
97      */
98     struct sharedMemoryInputQueue {
99     	volatile int head;	     /* user's index into events */
100             volatile int tail;	     /* kernel's index into events */
101             volatile unsigned int flags; /* place for out-of-band data */
102     #define SHMIQ_OVERFLOW  1
103     #define SHMIQ_CORRUPTED 2
104             struct shmqevent events[1];  /* input event buffer */
105     };
106     
107     /* have to figure this one out */
108     #define QIOCGETINDX      _IOWR('Q', 8, int)
109     
110     
111     /* acknowledge shmiq overflow */
112     #define QIOCSERVICED     _IO('Q', 3)
113     
114     /* Double indirect I_STR ioctl, yeah, fun fun fun */
115     
116     struct muxioctl {
117             int index;		/* lower stream index */
118             int realcmd;		/* the actual command for the subdevice */
119     };
120     /* Double indirect ioctl */
121     #define QIOCIISTR        _IOW('Q', 7, struct muxioctl)
122     
123     /* Cursor ioclts: */
124     
125     /* set cursor tracking mode */
126     #define QIOCURSTRK      _IOW('Q', 4, int)
127     
128     /* set cursor filter box */
129     #define QIOCURSIGN      _IOW('Q', 5, int [4])
130     
131     /* set cursor axes */
132     struct shmiqsetcurs {
133             short index;
134             short axes;
135     };
136     
137     #define QIOCSETCURS     _IOWR('Q',  9, struct shmiqsetcurs)
138     
139     /* set cursor position */
140     struct shmiqsetcpos {
141             short   x;
142             short   y;
143     };
144     #define QIOCSETCPOS     _IOWR('Q', 10, struct shmiqsetcpos)
145     
146     /* get time since last event */
147     #define QIOCGETITIME    _IOR('Q', 11, time_t)
148     
149     /* set current screen */
150     #define QIOCSETSCRN     _IOW('Q',6,int)
151     
152     
153     /* -------------------- iDev stuff -------------------- */
154     
155     #define IDEV_MAX_NAME_LEN 15
156     #define IDEV_MAX_TYPE_LEN 15
157     
158     typedef struct {
159             char            devName[IDEV_MAX_NAME_LEN+1];
160             char            devType[IDEV_MAX_TYPE_LEN+1];
161             unsigned short  nButtons;
162             unsigned short  nValuators;
163             unsigned short  nLEDs;
164             unsigned short  nStrDpys;
165             unsigned short  nIntDpys;
166             unsigned char   nBells;
167             unsigned char   flags;
168     #define IDEV_HAS_KEYMAP		0x01
169     #define IDEV_HAS_PROXIMITY 	0x02
170     #define IDEV_HAS_PCKBD 		0x04
171     } idevDesc;
172     
173     typedef struct {
174     	char *nothing_for_now;
175     } idevInfo;
176     
177     #define IDEV_KEYMAP_NAME_LEN 15
178     
179     typedef struct {
180             char name[IDEV_KEYMAP_NAME_LEN+1];
181     } idevKeymapDesc;
182     
183     /* The valuator definition */
184     typedef struct {
185             unsigned        hwMinRes;
186             unsigned        hwMaxRes;
187             int             hwMinVal;
188             int             hwMaxVal;
189     	
190             unsigned char   possibleModes;
191     #define IDEV_ABSOLUTE           0x0
192     #define IDEV_RELATIVE           0x1
193     #define IDEV_EITHER             0x2
194     	
195             unsigned char   mode;	/* One of: IDEV_ABSOLUTE, IDEV_RELATIVE */
196     	
197             unsigned short  resolution;
198             int             minVal;
199             int             maxVal;
200     } idevValuatorDesc;
201     
202     /* This is used to query a specific valuator with the IDEVGETVALUATORDESC ioctl */
203     typedef struct {
204             short                   valNum;
205             unsigned short          flags;
206             idevValuatorDesc        desc;
207     } idevGetSetValDesc;
208     
209     #define IDEVGETDEVICEDESC	_IOWR('i', 0,  idevDesc)
210     #define IDEVGETVALUATORDESC     _IOWR('i', 1,  idevGetSetValDesc)
211     #define IDEVGETKEYMAPDESC	_IOWR('i', 2,  idevKeymapDesc)
212     #define IDEVINITDEVICE		_IOW ('i', 51, unsigned int)
213     
214     
215     #ifdef __KERNEL__
216     
217     /* These are only interpreted by SHMIQ-attacheable devices and are internal
218      * to the kernel
219      */
220     #define SHMIQ_OFF        _IO('Q',1)
221     #define SHMIQ_ON         _IO('Q',2)
222     
223     void shmiq_push_event (struct shmqevent *e);
224     int get_sioc (struct strioctl *sioc, unsigned long arg);
225     #endif
226