|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: ! 25: /****************************************************************************** ! 26: ! 27: evio.h ! 28: Ioctl calls for the events driver ! 29: Leovitch 02Jan88 ! 30: ! 31: Copyright 1988 NeXT, Inc. ! 32: ! 33: CAUTION: Developers should stick to the API exported in ! 34: <drivers/event_status_driver.h> to guarantee ! 35: binary compatability of their applications in future ! 36: releases. ! 37: ! 38: Modified: ! 39: ! 40: 09Dec88 Leo Broken out from evsio.h ! 41: 24Aug89 Ted ANSI function prototyping. ! 42: 19Feb90 Ted Major revision for multiple driver support. ! 43: 26Feb90 Ted New evioScreen structure and EVIOST ioctl. ! 44: 12Mar90 Ted New ev_unregister_screen function, SCREENTOKEN constant. ! 45: 06May90 Ted Added AALastEventSent and AALastEventConsumed to EvVars. ! 46: 22May90 Trey More wait cursor vars in EvVars. ! 47: 13Jun90 Ted NXCursorData structure. ! 48: 18Jun90 Ted Default wait cursor constants. ! 49: 26Sep90 Ted Enhanced cursor system to support intelligent drivers. ! 50: 26Nov90 Ted Removed NXSaveCursor and NXCursorData structures ! 51: 28Nov90 Ted Remove EvVars, rolled into EventGlobals ! 52: 28Nov90 Ted Renamed EventGlobals -> EvGlobals, eventGlobals -> evg ! 53: 05May92 Mike Reworked for NRW driver architecture. ! 54: ! 55: ******************************************************************************/ ! 56: ! 57: #ifdef DRIVER_PRIVATE ! 58: ! 59: #ifndef _DEV_EVIO_ ! 60: #define _DEV_EVIO_ ! 61: #import <mach/port.h> ! 62: #import <mach/message.h> ! 63: #import <bsd/dev/ev_types.h> ! 64: #import <bsd/dev/event.h> ! 65: #import <driverkit/generalFuncs.h> ! 66: #import <mach/boolean.h> ! 67: ! 68: /* ! 69: * Identify this driver as one that uses the new driverkit and messaging API ! 70: */ ! 71: #ifndef _NeXT_MACH_EVENT_DRIVER_ ! 72: #define _NeXT_MACH_EVENT_DRIVER_ (1) ! 73: #endif /* _NeXT_MACH_EVENT_DRIVER_ */ ! 74: ! 75: ! 76: /* ! 77: * Time sources, in ticks and milliseconds. These work in both ! 78: * the kernel and user environments, as long as the driverkit is ! 79: * linked in. The tick time is on the same order as the old vertical blanking ! 80: * counter, but is derived from the nanosecond timer timebase. ! 81: */ ! 82: #if defined(_KERNEL) ! 83: extern void IOGetTimestamp(ns_time_t *nsp); // Can not include generalFuncs.h ! 84: // due to PS conflicts with ! 85: // Adobe code. ! 86: ! 87: static inline unsigned ! 88: EvTickTimeValue() ! 89: { ! 90: ns_time_t ns_time; ! 91: unsigned tick; ! 92: IOGetTimestamp(&ns_time); ! 93: // Convert nanosec => ticks and return ! 94: tick = EV_NS_TO_TICK(ns_time); ! 95: if ( tick == 0 ) ! 96: tick = 1; // No zero values allowed! ! 97: return tick; ! 98: } ! 99: ! 100: static inline unsigned ! 101: EvMsecTimeValue() ! 102: { ! 103: ns_time_t ns_time; ! 104: ! 105: IOGetTimestamp(&ns_time); ! 106: // Convert nanosec => millisec and return ! 107: return (unsigned)(ns_time /= 1000000ULL); ! 108: } ! 109: #endif /* _KERNEL */ ! 110: /* Pressure Constants */ ! 111: #define MINPRESSURE EV_MINPRESSURE ! 112: #define MAXPRESSURE EV_MAXPRESSURE ! 113: ! 114: #define LLEQSIZE 80 /* Entries in low-level event queue */ ! 115: ! 116: typedef struct _NXEQElStruct { ! 117: int next; /* Slot of lleq for next event */ ! 118: ev_lock_data_t sema; /* Is high-level code reading this event now? */ ! 119: NXEvent event; /* The event itself */ ! 120: } NXEQElement; ! 121: ! 122: ! 123: /****************************************************************************** ! 124: SHARED MEMORY OVERVIEW ! 125: ! 126: PERSPECTIVE ! 127: The ev driver and PostScript share at least one page of wired memory. ! 128: This memory contains the low-level event queue which ev deposits events ! 129: into and PostScript reads events from. Also, this memory contains other ! 130: important data such as wait cursor state and some general cursor state. ! 131: This memory is critical for speed. That is, we avoid having to make ! 132: system calls for common operations. ! 133: ! 134: SHARED MEMORY REGIONS ! 135: There are currently three "regions" or "zones" delineated within this ! 136: shared memory. The first zone is the EvOffsets structure. This structure ! 137: contains two offsets from the beginning of shared memory. The first offset ! 138: is to the second zone, EvGlobals. The second offset is to the third ! 139: zone, private shmem for drivers. ! 140: ! 141: INITIALIZATION OF SHARED MEMORY ! 142: When the WindowServer starts up, it finds all screens that will be active. ! 143: It then opens the ev driver and calls the EVIOSSCR ioctl repeatedly for ! 144: each screen in use. This lets the ev driver set up the evScreen array ! 145: and fill in each element. This ioctl also returns to PostScript a running ! 146: total shared memory size with which to allocate. PostScript then allocates ! 147: a region of memory this size and calls evmmap to "map in" this shared ! 148: region. Evmmap initializes and fills in the EvOffsets and EvGlobals. ! 149: Next the WindowServer calls each screen in turn to register itself with ! 150: the ev driver in the same sequence as presented to EVIOSSCR. Each screen ! 151: driver calls ev_register_screen() which among other things allocates a ! 152: part of the private shmem (of the third shared memory zone) for the driver. ! 153: ! 154: DEBUGGING NOTES ! 155: You can easily display and set this shared memory from kgdb, but usually ! 156: cannot do so from within PostScript. Gdb (or some weird interaction ! 157: between gdb and the os) chokes on this shmem. So if you read or write ! 158: this area of memory, copy-on-write will occur and you'll get a completely ! 159: new page for PostScript. This will render the shared memory scheme ! 160: useless and you will have to restart PostScript. It was my understanding ! 161: that before, we were able to "read" this area from PS, but not write to ! 162: it (the idea behind copy-on-WRITE). However, this seems to be broken ! 163: in 2.0. We think this is a kernel bug. ! 164: ******************************************************************************/ ! 165: ! 166: typedef volatile struct _evOffsets { ! 167: int evGlobalsOffset; /* Offset to EvGlobals structure */ ! 168: int evShmemOffset; /* Offset to private shmem regions */ ! 169: } EvOffsets; ! 170: ! 171: /****************************************************************************** ! 172: EvGlobals ! 173: This structures defines the portion of the events driver data structure ! 174: that is exported to the PostScript server. It contains the event queue ! 175: which is in memory shared between the driver and the PostScript server. ! 176: All the variables necessary to read and process events from the queue are ! 177: contained here. ! 178: ******************************************************************************/ ! 179: ! 180: typedef volatile struct _evGlobals { ! 181: short LLEHead; /* The next event to be read */ ! 182: short LLETail; /* Where the next event will go */ ! 183: short LLELast; /* The last event entered */ ! 184: short eNum; /* Unique id for mouse events */ ! 185: int buttons; /* State of the mouse buttons 1==down, 0==up */ ! 186: int eventFlags; /* The current value of event.flags */ ! 187: int VertRetraceClock; /* The current value of event.time */ ! 188: ev_lock_data_t cursorSema; /* set to disable periodic code */ ! 189: Point cursorLoc; /* The current location of the cursor */ ! 190: int frame; /* current cursor frame */ ! 191: Bounds workBounds; /* bounding box of all screens */ ! 192: Bounds mouseRect; /* Rect for mouse-exited events */ ! 193: unsigned reserved:27; ! 194: unsigned wantPressure:1; /* pressure in current mouseRect? */ ! 195: unsigned wantPrecision:1; /* precise coordinates in current mouseRect? */ ! 196: unsigned dontWantCoalesce:1;/* coalesce within the current mouseRect? */ ! 197: unsigned dontCoalesce:1; /* actual flag which determines coalescing */ ! 198: unsigned mouseRectValid:1; /* If nonzero, post a mouse-exited ! 199: whenever mouse outside mouseRect. */ ! 200: int movedMask; /* This contains an event mask for the ! 201: three events MOUSEMOVED, ! 202: LMOUSEDRAGGED, and RMOUSEDRAGGED. ! 203: It says whether driver should ! 204: generate those events. */ ! 205: int AALastEventSent; /* timestamp for wait cursor */ ! 206: int AALastEventConsumed; /* timestamp for wait cursor */ ! 207: ev_lock_data_t waitCursorSema; /* protects wait cursor fields */ ! 208: int waitCursorUp; /* Is wait cursor up? */ ! 209: char ctxtTimedOut; /* Has wait cursor timer expired? */ ! 210: char waitCursorEnabled; /* Play wait cursor game (per ctxt)? */ ! 211: char globalWaitCursorEnabled; /* Play wait cursor game (global)? */ ! 212: short waitThreshold; /* time before wait cursor appears */ ! 213: NXEQElement lleq[LLEQSIZE]; /* The event queue itself */ ! 214: } EvGlobals; ! 215: ! 216: ! 217: /* These evio structs are used in various calls supported by the ev driver. */ ! 218: ! 219: struct evioLLEvent { ! 220: int type; ! 221: Point location; ! 222: NXEventData data; ! 223: }; ! 224: ! 225: typedef struct evioLLEvent _NXLLEvent; ! 226: ! 227: /* ! 228: * On a keypress of a VOL UP or VOL DOWN key, we send a message to the ! 229: * sound server to notify it of the volume change. The message includes ! 230: * a flag to indicate which key was pressed, and the machine independant ! 231: * flag bits to indicate which modifier keys were pressed. ! 232: */ ! 233: struct evioSpecialKeyMsg ! 234: { ! 235: msg_header_t Head; ! 236: msg_type_t keyType; ! 237: int key; // special key number, from bsd/dev/ev_keymap.h ! 238: msg_type_t directionType; ! 239: int direction; // NX_KEYDOWN, NX_KEYUP from event.h ! 240: msg_type_t flagsType; ! 241: int flags; // device independant flags from event.h ! 242: msg_type_t levelType; ! 243: int level; // EV_AUDIO_MIN_VOLUME to EV_AUDIO_MAX_VOLUME ! 244: }; ! 245: ! 246: #define EV_SPECIAL_KEY_MSG_ID (('S'<<24) | ('k'<<16) | ('e'<<8) | ('y')) ! 247: typedef struct evioSpecialKeyMsg *evioSpecialKeyMsg_t; ! 248: ! 249: /* ! 250: * Volume ranges ! 251: */ ! 252: #define EV_AUDIO_MIN_VOLUME 0 ! 253: #define EV_AUDIO_MAX_VOLUME 64 ! 254: ! 255: /* ! 256: * Get and Set parameter calls for the Event driver and associated filters. ! 257: */ ! 258: ! 259: #define EV_PREFIX "Ev_" /* All EV calls start with this string */ ! 260: ! 261: /* _NXEvSetParameterInt() calls */ ! 262: #define EVIOLLPE "Ev_LLPostEvent" ! 263: #define EVIOPTRLLPE "Ev_PointerLLPostEvent" ! 264: /* EventData packed as an array of ints. */ ! 265: typedef union ! 266: { ! 267: NXEventData data; ! 268: unsigned idata[(sizeof(NXEventData)+sizeof(unsigned)-1)/sizeof(unsigned)]; ! 269: } _NX_packed_event_t; ! 270: ! 271: typedef enum { ! 272: EVIOLLPE_TYPE, ! 273: EVIOLLPE_LOC_X, ! 274: EVIOLLPE_LOC_Y, ! 275: EVIOLLPE_DATA0, ! 276: EVIOLLPE_DATA1, ! 277: EVIOLLPE_DATA2 ! 278: } evioLLPEIndices; ! 279: #define EVIOLLPE_SIZE (EVIOLLPE_DATA2 + 1) ! 280: ! 281: #define EVIOSM "Ev_MousePosition" ! 282: typedef enum { ! 283: EVIOSM_LOC_X, ! 284: EVIOSM_LOC_Y ! 285: } evioSMIndices; ! 286: #define EVIOSM_SIZE (EVIOSM_LOC_Y + 1) ! 287: ! 288: #define EVIOST "Ev_StartCursor" ! 289: #define EVIOST_SIZE 1 ! 290: ! 291: #define EVIOSETSCREEN "Ev_SetScreen" ! 292: typedef enum { ! 293: EVIOSETSCREEN_TOTALSCREENS, ! 294: EVIOSETSCREEN_INDEX, ! 295: EVIOSETSCREEN_SHMEMSIZE, ! 296: EVIOSETSCREEN_MINX, ! 297: EVIOSETSCREEN_MAXX, ! 298: EVIOSETSCREEN_MINY, ! 299: EVIOSETSCREEN_MAXY ! 300: }evioSETSCREENIndices; ! 301: #define EVIOSETSCREEN_SIZE (EVIOSETSCREEN_MAXY + 1) ! 302: ! 303: ! 304: /* _NXEvGetParameterInt() calls */ ! 305: #define EVIOEVNUM "Ev_ButtonEventNums" /* Mouse driver */ ! 306: typedef enum { ! 307: EVIOEVNUM_LEFT, ! 308: EVIOEVNUM_RIGHT ! 309: } evioEVNUMIndices; ! 310: #define EVIOEVNUM_SIZE (EVIOEVNUM_RIGHT + 1) ! 311: ! 312: #define EVIOSHMEMSIZE "Ev_ShmemSize" ! 313: #define EVIOSHMEMSIZE_SIZE 1 ! 314: ! 315: typedef char EVString[64]; ! 316: typedef char EVParameterName[64]; ! 317: typedef int EVIntParameter[64]; ! 318: typedef char EVCharParameter[4096]; ! 319: typedef unsigned int EVObjectNumber; ! 320: ! 321: #endif /* _DEV_EVIO_ */ ! 322: ! 323: #endif /* DRIVER_PRIVATE */ ! 324:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.