Annotation of XNU/iokit/IOKit/hidsystem/IOHIDShared.h, revision 1.1

1.1     ! root        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: 
        !            87: typedef 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: 
        !           137: typedef 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: 
        !           151: typedef 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: #if EVENT_SYSTEM_VERSION > 1
        !           167:     unsigned int reservedA[32];
        !           168: #endif
        !           169:     unsigned reserved:27;
        !           170:     unsigned wantPressure:1;   /* pressure in current mouseRect? */
        !           171:     unsigned wantPrecision:1;  /* precise coordinates in current mouseRect? */
        !           172:     unsigned dontWantCoalesce:1;/* coalesce within the current mouseRect? */
        !           173:     unsigned dontCoalesce:1;   /* actual flag which determines coalescing */
        !           174:     unsigned mouseRectValid:1; /* If nonzero, post a mouse-exited
        !           175:                                   whenever mouse outside mouseRect. */
        !           176:     int movedMask;             /* This contains an event mask for the
        !           177:                                   three events MOUSEMOVED,
        !           178:                                   LMOUSEDRAGGED,  and RMOUSEDRAGGED.
        !           179:                                   It says whether driver should
        !           180:                                   generate those events. */
        !           181:     int AALastEventSent;       /* timestamp for wait cursor */
        !           182:     int AALastEventConsumed;   /* timestamp for wait cursor */ 
        !           183:     ev_lock_data_t waitCursorSema; /* protects wait cursor fields */
        !           184:     int waitCursorUp;          /* Is wait cursor up? */
        !           185:     char ctxtTimedOut;         /* Has wait cursor timer expired? */
        !           186:     char waitCursorEnabled;    /* Play wait cursor game (per ctxt)? */
        !           187:     char globalWaitCursorEnabled; /* Play wait cursor game (global)? */
        !           188:     int waitThreshold;         /* time before wait cursor appears */
        !           189:     NXEQElement lleq[LLEQSIZE];        /* The event queue itself */
        !           190: } EvGlobals;
        !           191: 
        !           192: 
        !           193: /* These evio structs are used in various calls supported by the ev driver. */
        !           194: 
        !           195: struct evioLLEvent {
        !           196:     int setCursor;
        !           197:     int type;
        !           198:     IOGPoint location;
        !           199:     NXEventData data;
        !           200:     int setFlags;
        !           201:     int flags;
        !           202: };
        !           203: 
        !           204: typedef struct evioLLEvent _NXLLEvent;
        !           205: 
        !           206: #ifdef mach3xxx
        !           207: 
        !           208: /*
        !           209:  * On a keypress of a VOL UP or VOL DOWN key, we send a message to the 
        !           210:  * sound server to notify it of the volume change.  The message includes
        !           211:  * a flag to indicate which key was pressed, and the machine independant
        !           212:  * flag bits to indicate which modifier keys were pressed.
        !           213:  */
        !           214: 
        !           215: struct evioSpecialKeyMsg
        !           216: {
        !           217:        msg_header_t Head;
        !           218:        msg_type_t keyType;
        !           219:        int key;                // special key number, from bsd/dev/ev_keymap.h
        !           220:        msg_type_t directionType;
        !           221:        int direction;          // NX_KEYDOWN, NX_KEYUP from event.h
        !           222:        msg_type_t flagsType;
        !           223:        int flags;              // device independant flags from event.h
        !           224:        msg_type_t levelType;
        !           225:        int level;              // EV_AUDIO_MIN_VOLUME to EV_AUDIO_MAX_VOLUME
        !           226: };
        !           227: #else
        !           228: struct evioSpecialKeyMsg
        !           229: {
        !           230:        mach_msg_header_t Head;
        !           231:        int key;                // special key number, from bsd/dev/ev_keymap.h
        !           232:        int direction;          // NX_KEYDOWN, NX_KEYUP from event.h
        !           233:        int flags;              // device independant flags from event.h
        !           234:        int level;              // EV_AUDIO_MIN_VOLUME to EV_AUDIO_MAX_VOLUME
        !           235: };
        !           236: #endif
        !           237: 
        !           238: #define EV_SPECIAL_KEY_MSG_ID  (('S'<<24) | ('k'<<16) | ('e'<<8) | ('y'))
        !           239: typedef struct evioSpecialKeyMsg *evioSpecialKeyMsg_t;
        !           240: 
        !           241: /*
        !           242:  * Volume ranges
        !           243:  */
        !           244: #define EV_AUDIO_MIN_VOLUME    0
        !           245: #define EV_AUDIO_MAX_VOLUME    64
        !           246: 
        !           247: #define kIOHIDSystemClass      "IOHIDSystem"
        !           248: #define kIOHIKeyboardClass     "IOHIKeyboard"
        !           249: #define kIOHIPointingClass     "IOHIPointing"
        !           250: 
        !           251: #define IOHIDSYSTEM_CONFORMSTO kIOHIDSystemClass
        !           252: 
        !           253: enum {
        !           254:     kIOHIDCurrentShmemVersion  = 2,
        !           255:     kIOHIDServerConnectType    = 0,
        !           256:     kIOHIDParamConnectType     = 1,
        !           257:     kIOHIDGlobalMemory         = 0,
        !           258:     kIOHIDEventNotification    = 0
        !           259: };
        !           260: 
        !           261: #ifndef KERNEL
        !           262: #ifndef _IOKIT_IOHIDLIB_H
        !           263: #include <IOKit/hidsystem/IOHIDLib.h>
        !           264: #endif
        !           265: #endif /* !KERNEL */
        !           266: 
        !           267: __END_DECLS
        !           268: 
        !           269: 
        !           270: #endif /* !_DEV_EVIO_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.