|
|
1.1 ! root 1: /* ! 2: * Mach Operating System ! 3: * Copyright (c) 1992 Carnegie Mellon University ! 4: * All Rights Reserved. ! 5: * ! 6: * Permission to use, copy, modify and distribute this software and its ! 7: * documentation is hereby granted, provided that both the copyright ! 8: * notice and this permission notice appear in all copies of the ! 9: * software, derivative works or modified versions, and any portions ! 10: * thereof, and that both notices appear in supporting documentation. ! 11: * ! 12: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" ! 13: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR ! 14: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ! 15: * ! 16: * Carnegie Mellon requests users of this software to return to ! 17: * ! 18: * Software Distribution Coordinator or [email protected] ! 19: * School of Computer Science ! 20: * Carnegie Mellon University ! 21: * Pittsburgh PA 15213-3890 ! 22: * ! 23: * any improvements or extensions that they make and grant Carnegie Mellon ! 24: * the rights to redistribute these changes. ! 25: */ ! 26: /* ! 27: * File: dtop.h ! 28: * Author: Alessandro Forin, Carnegie Mellon University ! 29: * Date: 1/92 ! 30: * ! 31: * Definitions for the Desktop serial bus (i2c aka ACCESS). ! 32: */ ! 33: ! 34: #ifndef _DTOP_H_ ! 35: #define _DTOP_H_ ! 36: ! 37: #define DTOP_MAX_DEVICES 14 ! 38: #define DTOP_MAX_MSG_SIZE 36 /* 3 hdr + 32 data + 1 checksum */ ! 39: ! 40: typedef struct { ! 41: ! 42: unsigned char dest_address; /* low bit is zero */ ! 43: unsigned char src_address; /* ditto */ ! 44: union { ! 45: struct { ! 46: unsigned char len : 5, /* message byte len */ ! 47: sub : 2, /* sub-address */ ! 48: P : 1; /* Control(1)/Data(0) marker */ ! 49: } val; ! 50: unsigned char bits; /* quick check */ ! 51: } code; ! 52: ! 53: /* varzise, checksum byte at end */ ! 54: unsigned char body[DTOP_MAX_MSG_SIZE-3]; ! 55: ! 56: } dtop_message, *dtop_message_t; ! 57: ! 58: /* ! 59: * Standard addresses ! 60: */ ! 61: ! 62: #define DTOP_ADDR_HOST 0x50 /* address for the (only) host */ ! 63: #define DTOP_ADDR_DEFAULT 0x6e /* power-up default address */ ! 64: #define DTOP_ADDR_FIRST 0x52 /* first assignable address */ ! 65: #define DTOP_ADDR_LAST 0x6c /* last, inclusive */ ! 66: ! 67: #define DTOP_ADDR_KBD 0x6c /* as used by DEC */ ! 68: #define DTOP_ADDR_MOUSE 0x6a ! 69: ! 70: /* ! 71: * Standard messages ! 72: */ ! 73: ! 74: /* from host to devices */ ! 75: ! 76: #define DTOP_MSG_RESET 0xf0 /* preceeded by 0x81: P,len 1 */ ! 77: ! 78: #define DTOP_MSG_ID_REQUEST 0xf1 /* preceeded by 0x81: P,len 1 */ ! 79: ! 80: #define DTOP_MSG_ASSIGN_ADDRESS 0xf2 /* preceeded by 0x9e: P,len 30 */ ! 81: /* followed by a dtop_id_reply_t */ ! 82: /* and by the new_IC_address */ ! 83: ! 84: #define DTOP_MSG_CAP_REQUEST 0xf3 /* preceeded by 0x83: P,len 3 */ ! 85: /* followed by a 16 bit u_offset */ ! 86: ! 87: #define DTOP_MSG_APPL_TEST 0xb1 /* preceed by P, sub, len 1 */ ! 88: ! 89: /* from devices to host */ ! 90: ! 91: #define DTOP_MSG_ATTENTION 0xe0 /* preceeded by P, len */ ! 92: # define DTOP_ATN_OK_STATUS 0x00 /* anything else bad */ ! 93: /* followed by 0-30 bytes */ ! 94: ! 95: #define DTOP_MSG_ID_REPLY 0xe1 /* preceeded by P,len (29..32) */ ! 96: ! 97: typedef struct { ! 98: unsigned char module_revision[8]; /* ascii, blank padded */ ! 99: unsigned char vendor_name[8]; ! 100: unsigned char module_name[8]; ! 101: int device_number; /* 32 bits cpl-2 */ ! 102: /* 0-3 optional bytes follow, ignore */ ! 103: } dtop_id_reply_t; ! 104: ! 105: #define DTOP_MSG_CAP_REPLY 0xe3 /* preceeded by P,len (3..32) */ ! 106: /* followed by 16 bit u_offset */ ! 107: /* followed by data */ ! 108: ! 109: #define DTOP_MSG_APPL_SIGNAL 0xa0 /* application level signal */ ! 110: # define DTOP_SIG_ATTENTION 0x00 ! 111: # define DTOP_SIG_RESET 0x01 ! 112: # define DTOP_SIG_HALT 0x02 ! 113: ! 114: #define DTOP_MSG_APPL_TREPLY 0xa1 /* followed by status (0-->ok) */ ! 115: /* and 0..30 bytes of result data */ ! 116: ! 117: /* reserved message codes (testing, manifacturing) */ ! 118: ! 119: #define DTOP_MSG_RES0 0xc0 ! 120: #define DTOP_MSG_RES1 0xc1 ! 121: #define DTOP_MSG_RES2 0xc2 ! 122: #define DTOP_MSG_RES3 0xc3 ! 123: ! 124: ! 125: /* ! 126: * Device specific definitions: Keyboard ! 127: */ ! 128: ! 129: /* from host to keyboard */ ! 130: ! 131: #define DTOP_KMSG_CLICK 0x01 /* preceeded by P, sub len 2 */ ! 132: # define DTOP_CLICK_VOLUME_MAX 0x7 /* followed by one byte */ ! 133: ! 134: #define DTOP_KMSG_BELL 0x02 /* preceeded by P, sub len 2 */ ! 135: /* same as above */ ! 136: ! 137: #define DTOP_KMSG_LED 0x03 /* preceeded by P, sub len 2 */ ! 138: /* four lower bits turn leds on */ ! 139: ! 140: #define DTOP_KMSG_POLL 0x04 /* preceeded by P, sub len 1 */ ! 141: ! 142: /* keyboard sends up to 11 codes in a data message, distinguished values: */ ! 143: #define DTOP_KBD_EMPTY 0x00 ! 144: #define DTOP_KBD_OUT_ERR 0x01 ! 145: #define DTOP_KBD_IN_ERR 0x02 ! 146: ! 147: #define DTOP_KBD_KEY_MIN 0x08 ! 148: #define DTOP_KBD_KEY_MAX 0xff ! 149: ! 150: /* powerup status values: 0 ok, else.. */ ! 151: #define DTOP_KBD_ROM_FAIL 0x01 ! 152: #define DTOP_KBD_RAM_FAIL 0x02 ! 153: #define DTOP_KBD_KEY_DOWN 0x03 ! 154: ! 155: ! 156: /* ! 157: * Device specific definitions: Locators (mouse) ! 158: */ ! 159: ! 160: /* locator sends this type of report data */ ! 161: ! 162: typedef struct { ! 163: unsigned short buttons; /* 1->pressed */ ! 164: short x; ! 165: short y; ! 166: short z; ! 167: /* possibly 3 more dimensions for gloves */ ! 168: } dtop_locator_msg_t; ! 169: ! 170: #define DTOP_LMSG_SET_RATE 0x01 /* preceeded by P,sub, len 2 */ ! 171: /* followed by sampling interval, ! 172: from 8 to 25 msecs (0->polled */ ! 173: ! 174: #define DTOP_LMSG_POLL 0x02 /* preceeded by P,sub, len 1 */ ! 175: ! 176: /* Powerup codes same as keyboard */ ! 177: ! 178: ! 179: /* ! 180: * Implementation specific definitions ! 181: */ ! 182: ! 183: typedef union { ! 184: ! 185: dtop_message unknown_report; ! 186: ! 187: struct { ! 188: char last_codes_count; ! 189: unsigned char last_codes[11]; /* max as per specs */ ! 190: unsigned int last_msec; /* autorepeat state */ ! 191: unsigned short poll_frequency; ! 192: unsigned char k_ar_state; ! 193: # define K_AR_IDLE 0 /* quiescent, no polling */ ! 194: # define K_AR_OFF 4 /* turn off polling pls */ ! 195: # define K_AR_ACTIVE 2 /* polling, no autos yet */ ! 196: # define K_AR_TRIGGER 1 /* sent one autorepeat */ ! 197: unsigned char bell_volume; ! 198: unsigned char led_status; ! 199: } keyboard; ! 200: ! 201: struct { ! 202: unsigned char type : 7, /* DEV_MOUSE, DEV_TABLET, .. */ ! 203: relative : 1; ! 204: unsigned char n_coords; ! 205: unsigned short prev_buttons; ! 206: # define L_BUTTON_MAX 16 ! 207: unsigned char button_code[L_BUTTON_MAX]; ! 208: # define L_COORD_MAX 6 ! 209: unsigned int coordinate[L_COORD_MAX]; /* max 6D */ ! 210: } locator; ! 211: ! 212: /* add more as they come along */ ! 213: ! 214: } dtop_device, *dtop_device_t; ! 215: ! 216: /* All handler functions should have this interface */ ! 217: extern int ! 218: dtop_null_device_handler( ! 219: dtop_device_t dev, ! 220: dtop_message_t msg, ! 221: int event, ! 222: unsigned char outc), ! 223: dtop_locator_handler( ! 224: dtop_device_t dev, ! 225: dtop_message_t msg, ! 226: int event, ! 227: unsigned char outc), ! 228: dtop_keyboard_handler( ! 229: dtop_device_t dev, ! 230: dtop_message_t msg, ! 231: int event, ! 232: unsigned char outc); ! 233: ! 234: ! 235: #define DTOP_EVENT_RECEIVE_PACKET 1 ! 236: #define DTOP_EVENT_BAD_PACKET 2 ! 237: #define DTOP_EVENT_PUTC 4 ! 238: #define DTOP_EVENT_POLL 8 ! 239: ! 240: ! 241: #endif /* _DTOP_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.