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

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