|
|
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: #ifndef _APPLEPS2DEVICE_H ! 24: #define _APPLEPS2DEVICE_H ! 25: ! 26: #include <IOKit/IOService.h> ! 27: ! 28: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! 29: // Definitions ! 30: // ! 31: // Data Port (0x60) Commands. These commands are all transmitted directly to ! 32: // the physical keyboard and/or mouse, so expect an acknowledge for each byte ! 33: // that you send through this port. ! 34: // ! 35: ! 36: #define kDP_SetMouseScaling1To1 0xE6 // (mouse) ! 37: #define kDP_SetMouseScaling2To1 0xE7 // (mouse) ! 38: #define kDP_SetMouseResolution 0xE8 // (mouse) ! 39: #define kDP_GetMouseInformation 0xE9 // (mouse) ! 40: #define kDP_SetMouseStreamMode 0xEA // (mouse) ! 41: #define kDP_SetKeyboardLEDs 0xED // (keyboard) ! 42: #define kDP_TestKeyboardEcho 0xEE // (keyboard) ! 43: #define kDP_GetSetKeyboardASCs 0xF0 // (keyboard) ! 44: #define kDP_GetId 0xF2 // (keyboard+mouse) ! 45: #define kDP_SetKeyboardTypematic 0xF3 // (keyboard) ! 46: #define kDP_SetMouseSampleRate 0xF3 // (mouse) ! 47: #define kDP_Enable 0xF4 // (keyboard+mouse) ! 48: #define kDP_SetDefaultsAndDisable 0xF5 // (keyboard+mouse) ! 49: #define kDP_SetDefaults 0xF6 // (keyboard+mouse) ! 50: #define kDP_SetAllTypematic 0xF7 // (keyboard) ! 51: #define kDP_SetAllMakeRelease 0xF8 // (keyboard) ! 52: #define kDP_SetAllMakeOnly 0xF9 // (keyboard) ! 53: #define kDP_SetAllTypematicMakeRelease 0xFA // (keyboard) ! 54: #define kDP_SetKeyMakeRelease 0xFB // (keyboard) ! 55: #define kDP_SetKeyMakeOnly 0xFC // (keyboard) ! 56: #define kDP_Reset 0xFF // (keyboard+mouse) ! 57: ! 58: // ! 59: // Command Port (0x64) Commands. These commands all access registers local ! 60: // to the motherboard, ie. nothing is transmitted, thus these commands and ! 61: // any associated data passed thru the Data Port do not return acknowledges. ! 62: // ! 63: ! 64: #define kCP_GetCommandByte 0x20 // (keyboard+mouse) ! 65: #define kCP_ReadControllerRAMBase 0x21 // ! 66: #define kCP_SetCommandByte 0x60 // (keyboard+mouse) ! 67: #define kCP_WriteControllerRAMBase 0x61 // ! 68: #define kCP_TestPassword 0xA4 // ! 69: #define kCP_GetPassword 0xA5 // ! 70: #define kCP_VerifyPassword 0xA6 // ! 71: #define kCP_DisableMouseClock 0xA7 // (mouse) ! 72: #define kCP_EnableMouseClock 0xA8 // (mouse) ! 73: #define kCP_TestMousePort 0xA9 // ! 74: #define kCP_TestController 0xAA // ! 75: #define kCP_TestKeyboardPort 0xAB // ! 76: #define kCP_GetControllerDiagnostic 0xAC // ! 77: #define kCP_DisableKeyboardClock 0xAD // (keyboard) ! 78: #define kCP_EnableKeyboardClock 0xAE // (keyboard) ! 79: #define kCP_ReadInputPort 0xC0 // ! 80: #define kCP_PollInputPortLow 0xC1 // ! 81: #define kCP_PollInputPortHigh 0xC2 // ! 82: #define kCP_ReadOutputPort 0xD0 // ! 83: #define kCP_WriteOutputPort 0xD1 // ! 84: #define kCP_WriteKeyboardOutputBuffer 0xD2 // (keyboard) ! 85: #define kCP_WriteMouseOutputBuffer 0xD3 // (mouse) ! 86: #define kCP_TransmitToMouse 0xD4 // (mouse) ! 87: #define kCP_ReadTestInputs 0xE0 // ! 88: #define kCP_PulseOutputBitBase 0xF0 // ! 89: ! 90: // ! 91: // Bit definitions for the 8-bit "Command Byte" register, which is accessed ! 92: // through the Command Port (0x64). ! 93: // ! 94: ! 95: #define kCB_EnableKeyboardIRQ 0x01 // Enable Keyboard IRQ ! 96: #define kCB_EnableMouseIRQ 0x02 // Enable Mouse IRQ ! 97: #define kCB_SystemFlag 0x04 // Set System Flag ! 98: #define kCB_InhibitOverride 0x08 // Inhibit Override ! 99: #define kCB_DisableKeyboardClock 0x10 // Disable Keyboard Clock ! 100: #define kCB_DisableMouseClock 0x20 // Disable Mouse Clock ! 101: #define kCB_TranslateMode 0x40 // Keyboard Translate Mode ! 102: ! 103: // ! 104: // Bit definitions for the 8-bit "LED" register, which is accessed through ! 105: // the Data Port (0x64). Undefined bit positions must be zero. ! 106: // ! 107: ! 108: #define kLED_ScrollLock 0x01 // Scroll Lock ! 109: #define kLED_NumLock 0x02 // Num Lock ! 110: #define kLED_CapsLock 0x04 // Caps Lock ! 111: ! 112: // ! 113: // Scan Codes used for special purposes on the keyboard and/or mouse receive ! 114: // port. These values would be received from your interrupt handler or from ! 115: // a ReadDataPort command primitive. These values do not represent actual ! 116: // keys, but indicate some sort of status. ! 117: // ! 118: ! 119: #define kSC_Acknowledge 0xFA // ack for transmitted commands ! 120: #define kSC_Extend 0xE0 // marker for "extended" sequence ! 121: #define kSC_Pause 0xE1 // marker for pause key sequence ! 122: #define kSC_Resend 0xFE // request to resend keybd cmd ! 123: #define kSC_Reset 0xAA // the keyboard/mouse has reset ! 124: #define kSC_UpBit 0x80 // OR'd in if key below is released ! 125: ! 126: // ! 127: // Scan Codes for some modifier keys. ! 128: // ! 129: ! 130: #define kSC_Alt 0x38 // (extended = right key) ! 131: #define kSC_Ctrl 0x1D // (extended = right key) ! 132: #define kSC_ShiftLeft 0x2A ! 133: #define kSC_ShiftRight 0x36 ! 134: #define kSC_WindowsLeft 0x5B // extended ! 135: #define kSC_WindowsRight 0x5C // extended ! 136: ! 137: // ! 138: // Scan Codes for some keys. ! 139: // ! 140: ! 141: #define kSC_Delete 0x53 // (extended = gray key) ! 142: #define kSC_NumLock 0x45 ! 143: ! 144: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! 145: // PS/2 Command Primitives ! 146: // ! 147: // o kPS2C_ReadDataPort: ! 148: // o Description: Reads the next available byte off the data port (60h). ! 149: // o Out Field: Holds byte that was read. ! 150: // ! 151: // o kPS2C_ReadDataAndCompare: ! 152: // o Description: Reads the next available byte off the data port (60h), ! 153: // and compares it with the byte in the In Field. If the ! 154: // comparison fails, the request is aborted (refer to the ! 155: // commandsCount field in the request structure). ! 156: // o In Field: Holds byte that comparison should be made to. ! 157: // ! 158: // o kPS2C_WriteDataPort: ! 159: // o Description: Writes the byte in the In Field to the data port (60h). ! 160: // o In Field: Holds byte that should be written. ! 161: // ! 162: // o kPS2C_WriteCommandPort: ! 163: // o Description: Writes the byte in the In Field to the command port (64h). ! 164: // o In Field: Holds byte that should be written. ! 165: // ! 166: ! 167: enum PS2CommandEnum ! 168: { ! 169: kPS2C_ReadDataPort, ! 170: kPS2C_ReadDataPortAndCompare, ! 171: kPS2C_WriteDataPort, ! 172: kPS2C_WriteCommandPort ! 173: }; ! 174: typedef enum PS2CommandEnum PS2CommandEnum; ! 175: ! 176: struct PS2Command ! 177: { ! 178: PS2CommandEnum command; ! 179: UInt8 inOrOut; ! 180: }; ! 181: typedef struct PS2Command PS2Command; ! 182: ! 183: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! 184: // PS/2 Request Structure ! 185: // ! 186: // o General Notes: ! 187: // o allocateRequest allocates the request structure -- use it always. ! 188: // o freeRequest deallocates the request structure -- use it always. ! 189: // o It is the driver's responsibility to free the request structure: ! 190: // o after a submitRequestAndBlock call returns, or ! 191: // o in the completion routine for each submitRequest issued. ! 192: // o It is not the driver's resposiblity to free the request structure: ! 193: // o when no completion routine is specified in a request issued via ! 194: // submitRequest, in which case the request is freed automatically ! 195: // by the controller. This case is called "fire-and-forget". ! 196: // o On completion, the requester can see how far the processing got by ! 197: // looking at the commandsCount field. If it is equal to the original ! 198: // number of commands, then the request was successful. If isn't, the ! 199: // value represents the zero-based index of the command that failed. ! 200: // ! 201: // o General Notes For Inquisitive Minds: ! 202: // o Requests are executed atomically with respect to all other requests, ! 203: // that is, if a keyboard request is currently being processed, then a ! 204: // request submitted by the mouse driver or one submitted by a separate ! 205: // thread of control in the keyboard driver will get queued until the ! 206: // controller is available again. ! 207: // o Request processing can be preempted to service interrupts on other ! 208: // PS/2 devices, should other-device data arrive unexpectedly on the ! 209: // input stream while processing a request. ! 210: // o The request processor knows when to read the mouse input stream ! 211: // over the keyboard input stream for a given command sequence. It ! 212: // does not depend on which driver it came from, rest assurred. If ! 213: // the mouse driver so chose, it could send keyboard commands. ! 214: // ! 215: // o commands: ! 216: // o Description: Holds list of commands that controller should execute. ! 217: // o Comments: Refer to PS2Command structure. ! 218: // ! 219: // o commandsCount: ! 220: // o Description: Holds the number of commands in the command list. ! 221: // o Comments: Number of commands should never exceed kMaxCommands. ! 222: // ! 223: // o completionRoutineTarget, Action, and Param: ! 224: // o Description: Object and method of the completion routine, which is ! 225: // called when the request has finished. The Param field ! 226: // may be filled with anything you want; it is passed to ! 227: // completion routine when it is called. These fields ! 228: // are optional. If left null, the request structure ! 229: // will be deallocated automatically by the controller ! 230: // on completion of the request. ! 231: // o Prototype: void completionRoutine(void * target, void * param); ! 232: // o Comments: Never issue submitRequestAndBlock or otherwise BLOCK on ! 233: // any request sent down to your device from the completion ! 234: // routine. Obey, or deadlock. ! 235: // ! 236: ! 237: #define kMaxCommands 20 ! 238: ! 239: typedef void (*PS2CompletionAction)(void * target, void * param); ! 240: ! 241: struct PS2Request ! 242: { ! 243: UInt8 commandsCount; ! 244: PS2Command commands[kMaxCommands]; ! 245: void * completionTarget; ! 246: PS2CompletionAction completionAction; ! 247: void * completionParam; ! 248: }; ! 249: typedef struct PS2Request PS2Request; ! 250: ! 251: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! 252: // ApplePS2KeyboardDevice and ApplePS2MouseDevice Class Descriptions ! 253: // ! 254: // ! 255: // o General Notes: ! 256: // o When the probe method is invoked on the client driver, the controller ! 257: // guarantees that the keyboard clock is enabled and the keyboard itself ! 258: // is disabled. This implies the client driver can send commands to the ! 259: // keyboard without a problem, and the keyboard itself will not send any ! 260: // asynchronous key data that may mess up the responses expected by the ! 261: // commands sent to it. ! 262: // ! 263: // o installInterruptAction: ! 264: // o Description: Ask the device to deliver asynchronous data to driver. ! 265: // o In Fields: Target/action of completion routine. ! 266: // ! 267: // o installInterruptAction Interrupt Routine: ! 268: // o Description: Delivers a newly read byte from the input data stream. ! 269: // o Prototype: void interruptOccurred(void * target, UInt8 byte); ! 270: // o In Fields: Byte that was read. ! 271: // o Comments: Never issue submitRequestAndBlock or otherwise BLOCK on ! 272: // any request sent down to your device from the interrupt ! 273: // routine. Obey, or deadlock. ! 274: // ! 275: // o uninstallInterruptHandler: ! 276: // o Description: Ask the device to stop delivering asynchronous data. ! 277: // ! 278: // o allocateRequest: ! 279: // o Description: Allocate a request structure, blocks until successful. ! 280: // o Result: Request structure pointer. ! 281: // o Comments: Request structure is guaranteed to be zeroed. ! 282: // ! 283: // o freeRequest: ! 284: // o Description: Deallocate a request structure. ! 285: // o In Fields: Request structure pointer. ! 286: // ! 287: // o submitRequest: ! 288: // o Description: Submit the request to the controller for processing. ! 289: // o In Fields: Request structure pointer. ! 290: // o Result: kern_return_t queueing status. ! 291: // ! 292: // o submitRequestAndBlock: ! 293: // o Description: Submit the request to the controller for processing, then ! 294: // block the calling thread until the request completes. ! 295: // o In Fields: Request structure pointer. ! 296: // ! 297: ! 298: typedef void (*PS2InterruptAction)(void * target, UInt8 data); ! 299: ! 300: #endif /* !_APPLEPS2DEVICE_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.