]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/hidsystem/IOHIDShared.h
xnu-124.13.tar.gz
[apple/xnu.git] / iokit / IOKit / hidsystem / IOHIDShared.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/******************************************************************************
23
24 evio.h
25 Ioctl calls for the events driver
26 Leovitch 02Jan88
27
28 Copyright 1988 NeXT, Inc.
29
30 CAUTION: Developers should stick to the API exported in
31 <drivers/event_status_driver.h> to guarantee
32 binary compatability of their applications in future
33 releases.
34
35 Modified:
36
37 09Dec88 Leo Broken out from evsio.h
38 24Aug89 Ted ANSI function prototyping.
39 19Feb90 Ted Major revision for multiple driver support.
40 26Feb90 Ted New evioScreen structure and EVIOST ioctl.
41 12Mar90 Ted New ev_unregister_screen function, SCREENTOKEN constant.
42 06May90 Ted Added AALastEventSent and AALastEventConsumed to EvVars.
43 22May90 Trey More wait cursor vars in EvVars.
44 13Jun90 Ted NXCursorData structure.
45 18Jun90 Ted Default wait cursor constants.
46 26Sep90 Ted Enhanced cursor system to support intelligent drivers.
47 26Nov90 Ted Removed NXSaveCursor and NXCursorData structures
48 28Nov90 Ted Remove EvVars, rolled into EventGlobals
49 28Nov90 Ted Renamed EventGlobals -> EvGlobals, eventGlobals -> evg
50 05May92 Mike Reworked for NRW driver architecture.
51
52******************************************************************************/
53
54#ifndef _DEV_EVIO_H
55#define _DEV_EVIO_H
56
57#include <sys/cdefs.h>
58
59__BEGIN_DECLS
60
61#if KERNEL
62#include <IOKit/system.h>
63#else /* !KERNEL */
64#include <mach/message.h>
65#include <IOKit/IOKitLib.h>
66#endif /* KERNEL */
67
68#include <IOKit/IOReturn.h>
69#include <IOKit/graphics/IOGraphicsTypes.h>
70#include <IOKit/hidsystem/IOHIDTypes.h>
71#include <IOKit/hidsystem/IOLLEvent.h>
72
73/*
74 * Identify this driver as one that uses the new driverkit and messaging API
75 */
76#ifndef _NeXT_MACH_EVENT_DRIVER_
77#define _NeXT_MACH_EVENT_DRIVER_ (1)
78#endif /* _NeXT_MACH_EVENT_DRIVER_ */
79
80
81/* Pressure Constants */
82#define MINPRESSURE EV_MINPRESSURE
83#define MAXPRESSURE EV_MAXPRESSURE
84
85#define LLEQSIZE 80 /* Entries in low-level event queue */
86
87typedef struct _NXEQElStruct {
88 int next; /* Slot of lleq for next event */
89 ev_lock_data_t sema; /* Is high-level code reading this event now? */
90 NXEvent event; /* The event itself */
91} NXEQElement;
92
93
94/******************************************************************************
95 SHARED MEMORY OVERVIEW
96
97 PERSPECTIVE
98 The ev driver and PostScript share at least one page of wired memory.
99 This memory contains the low-level event queue which ev deposits events
100 into and PostScript reads events from. Also, this memory contains other
101 important data such as wait cursor state and some general cursor state.
102 This memory is critical for speed. That is, we avoid having to make
103 system calls for common operations.
104
105 SHARED MEMORY REGIONS
106 There are currently three "regions" or "zones" delineated within this
107 shared memory. The first zone is the EvOffsets structure. This structure
108 contains two offsets from the beginning of shared memory. The first offset
109 is to the second zone, EvGlobals. The second offset is to the third
110 zone, private shmem for drivers.
111
112 INITIALIZATION OF SHARED MEMORY
113 When the WindowServer starts up, it finds all screens that will be active.
114 It then opens the ev driver and calls the EVIOSSCR ioctl repeatedly for
115 each screen in use. This lets the ev driver set up the evScreen array
116 and fill in each element. This ioctl also returns to PostScript a running
117 total shared memory size with which to allocate. PostScript then allocates
118 a region of memory this size and calls evmmap to "map in" this shared
119 region. Evmmap initializes and fills in the EvOffsets and EvGlobals.
120 Next the WindowServer calls each screen in turn to register itself with
121 the ev driver in the same sequence as presented to EVIOSSCR. Each screen
122 driver calls ev_register_screen() which among other things allocates a
123 part of the private shmem (of the third shared memory zone) for the driver.
124
125 DEBUGGING NOTES
126 You can easily display and set this shared memory from kgdb, but usually
127 cannot do so from within PostScript. Gdb (or some weird interaction
128 between gdb and the os) chokes on this shmem. So if you read or write
129 this area of memory, copy-on-write will occur and you'll get a completely
130 new page for PostScript. This will render the shared memory scheme
131 useless and you will have to restart PostScript. It was my understanding
132 that before, we were able to "read" this area from PS, but not write to
133 it (the idea behind copy-on-WRITE). However, this seems to be broken
134 in 2.0. We think this is a kernel bug.
135******************************************************************************/
136
137typedef volatile struct _evOffsets {
138 int evGlobalsOffset; /* Offset to EvGlobals structure */
139 int evShmemOffset; /* Offset to private shmem regions */
140} EvOffsets;
141
142/******************************************************************************
143 EvGlobals
144 This structures defines the portion of the events driver data structure
145 that is exported to the PostScript server. It contains the event queue
146 which is in memory shared between the driver and the PostScript server.
147 All the variables necessary to read and process events from the queue are
148 contained here.
149******************************************************************************/
150
151typedef volatile struct _evGlobals {
152 ev_lock_data_t cursorSema; /* set to disable periodic code */
153 int LLEHead; /* The next event to be read */
154 int LLETail; /* Where the next event will go */
155 int LLELast; /* The last event entered */
156 int eNum; /* Unique id for mouse events */
157 int buttons; /* State of the mouse buttons 1==down, 0==up */
158 int eventFlags; /* The current value of event.flags */
159 int VertRetraceClock; /* The current value of event.time */
160 IOGPoint cursorLoc; /* The current location of the cursor */
161 int frame; /* current cursor frame */
162 IOGBounds workBounds; /* bounding box of all screens */
163 IOGBounds mouseRect; /* Rect for mouse-exited events */
164 int version; /* for run time checks */
165 int structSize; /* for run time checks */
166 unsigned int reservedA[32];
167
168 unsigned reserved:27;
169 unsigned wantPressure:1; /* pressure in current mouseRect? */
170 unsigned wantPrecision:1; /* precise coordinates in current mouseRect? */
171 unsigned dontWantCoalesce:1;/* coalesce within the current mouseRect? */
172 unsigned dontCoalesce:1; /* actual flag which determines coalescing */
173 unsigned mouseRectValid:1; /* If nonzero, post a mouse-exited
174 whenever mouse outside mouseRect. */
175 int movedMask; /* This contains an event mask for the
176 three events MOUSEMOVED,
177 LMOUSEDRAGGED, and RMOUSEDRAGGED.
178 It says whether driver should
179 generate those events. */
180 int AALastEventSent; /* timestamp for wait cursor */
181 int AALastEventConsumed; /* timestamp for wait cursor */
182 ev_lock_data_t waitCursorSema; /* protects wait cursor fields */
183 int waitCursorUp; /* Is wait cursor up? */
184 char ctxtTimedOut; /* Has wait cursor timer expired? */
185 char waitCursorEnabled; /* Play wait cursor game (per ctxt)? */
186 char globalWaitCursorEnabled; /* Play wait cursor game (global)? */
187 int waitThreshold; /* time before wait cursor appears */
188 NXEQElement lleq[LLEQSIZE]; /* The event queue itself */
189} EvGlobals;
190
191
192/* These evio structs are used in various calls supported by the ev driver. */
193
194struct evioLLEvent {
195 int setCursor;
196 int type;
197 IOGPoint location;
198 NXEventData data;
199 int setFlags;
200 int flags;
201};
202
203typedef struct evioLLEvent _NXLLEvent;
204
205#ifdef mach3xxx
206
207/*
208 * On a keypress of a VOL UP or VOL DOWN key, we send a message to the
209 * sound server to notify it of the volume change. The message includes
210 * a flag to indicate which key was pressed, and the machine independant
211 * flag bits to indicate which modifier keys were pressed.
212 */
213
214struct evioSpecialKeyMsg
215{
216 msg_header_t Head;
217 msg_type_t keyType;
218 int key; // special key number, from bsd/dev/ev_keymap.h
219 msg_type_t directionType;
220 int direction; // NX_KEYDOWN, NX_KEYUP from event.h
221 msg_type_t flagsType;
222 int flags; // device independant flags from event.h
223 msg_type_t levelType;
224 int level; // EV_AUDIO_MIN_VOLUME to EV_AUDIO_MAX_VOLUME
225};
226#else
227struct evioSpecialKeyMsg
228{
229 mach_msg_header_t Head;
230 int key; // special key number, from bsd/dev/ev_keymap.h
231 int direction; // NX_KEYDOWN, NX_KEYUP from event.h
232 int flags; // device independant flags from event.h
233 int level; // EV_AUDIO_MIN_VOLUME to EV_AUDIO_MAX_VOLUME
234};
235#endif
236
237#define EV_SPECIAL_KEY_MSG_ID (('S'<<24) | ('k'<<16) | ('e'<<8) | ('y'))
238typedef struct evioSpecialKeyMsg *evioSpecialKeyMsg_t;
239
240/*
241 * Volume ranges
242 */
243#define EV_AUDIO_MIN_VOLUME 0
244#define EV_AUDIO_MAX_VOLUME 64
245
246#define kIOHIDSystemClass "IOHIDSystem"
247#define kIOHIKeyboardClass "IOHIKeyboard"
248#define kIOHIPointingClass "IOHIPointing"
249
250#define IOHIDSYSTEM_CONFORMSTO kIOHIDSystemClass
251
252enum {
253 kIOHIDCurrentShmemVersion = 2,
254 kIOHIDServerConnectType = 0,
255 kIOHIDParamConnectType = 1,
256 kIOHIDGlobalMemory = 0,
257 kIOHIDEventNotification = 0
258};
259
260#ifdef KERNEL
261typedef UInt16 (*MasterVolumeUpdate)(void);
262typedef bool (*MasterMuteUpdate)(void);
263
264typedef struct {
265 MasterVolumeUpdate incrementMasterVolume;
266 MasterVolumeUpdate decrementMasterVolume;
267 MasterMuteUpdate toggleMasterMute;
268} MasterAudioFunctions;
269
270extern MasterAudioFunctions *masterAudioFunctions;
271#endif
272
273#ifndef KERNEL
274#ifndef _IOKIT_IOHIDLIB_H
275#include <IOKit/hidsystem/IOHIDLib.h>
276#endif
277#endif /* !KERNEL */
278
279__END_DECLS
280
281
282#endif /* !_DEV_EVIO_H */