summaryrefslogtreecommitdiff
path: root/sys/arch/pmax/dev/dtopreg.h
blob: 74aa68a1405627ad2035aa69c1ad9606f1e58f63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/*	$NetBSD: dtopreg.h,v 1.5 1994/10/26 21:09:00 cgd Exp $	*/

/*-
 * Copyright (c) 1992, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * Ralph Campbell and Rick Macklem.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)dtopreg.h	8.1 (Berkeley) 6/10/93
 */

/* 
 * Mach Operating System
 * Copyright (c) 1992 Carnegie Mellon University
 * All Rights Reserved.
 * 
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 * 
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 * 
 * Carnegie Mellon requests users of this software to return to
 * 
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 * 
 * any improvements or extensions that they make and grant Carnegie Mellon
 * the rights to redistribute these changes.
 */
/*
 * HISTORY
 * Log:	dtop.h,v 
 * Revision 2.3  92/03/05  17:08:17  rpd
 * 	Define how many buttons and coordinates we can take.
 * 	[92/03/05            af]
 * 
 * Revision 2.2  92/03/02  18:32:17  rpd
 * 	Created from DEC specs:
 * 	"DESKTOPinterconnect Description and Protocol Specification"
 * 	Version 0.9, Jun 17 1991
 * 	"Open Desktop Bus, Locator Device Protocol Specification"
 * 	Version 0.4, Dec 13 1990
 * 	"Open Desktop Bus, Keyboard Device Protocol Specification"
 * 	Version 0.7, Jan 9 1991
 * 	[92/01/19            af]
 * 
 */
/*
 *	File: dtop.h
 * 	Author: Alessandro Forin, Carnegie Mellon University
 *	Date:	1/92
 *
 *	Definitions for the Desktop serial bus (i2c aka ACCESS).
 */

#ifndef	_DTOP_H_
#define	_DTOP_H_

#define	DTOP_MAX_DEVICES	14
#define	DTOP_MAX_MSG_SIZE	36	/* 3 hdr + 32 data + 1 checksum */

typedef struct {

	unsigned char	dest_address;	/* low bit is zero */
	unsigned char	src_address;	/* ditto */
	union {
	    struct {
		unsigned char	len : 5, /* message byte len */
				sub : 2, /* sub-address */
				P : 1;	 /* Control(1)/Data(0) marker */
	    } val;
	    unsigned char	bits;	/* quick check */
	} code;

	/* varzise, checksum byte at end */
	unsigned char	body[DTOP_MAX_MSG_SIZE-3];

} dtop_message, *dtop_message_t;

/*
 * Standard addresses
 */

#define	DTOP_ADDR_HOST		0x50	/* address for the (only) host */
#define	DTOP_ADDR_DEFAULT	0x6e	/* power-up default address */
#define	DTOP_ADDR_FIRST		0x52	/* first assignable address */
#define	DTOP_ADDR_LAST		0x6c	/* last, inclusive */

/*
 * Standard messages
 */

/* from host to devices */

#define	DTOP_MSG_RESET		0xf0	/* preceeded by 0x81: P,len 1 */

#define	DTOP_MSG_ID_REQUEST	0xf1	/* preceeded by 0x81: P,len 1 */

#define	DTOP_MSG_ASSIGN_ADDRESS	0xf2	/* preceeded by 0x9e: P,len 30 */
					/* followed by a dtop_id_reply_t */
					/* and by the new_IC_address */

#define	DTOP_MSG_CAP_REQUEST	0xf3	/* preceeded by 0x83: P,len 3 */
					/* followed by a 16 bit u_offset */

#define	DTOP_MSG_APPL_TEST	0xb1	/* preceed by P, sub, len 1 */

/* from devices to host */

#define	DTOP_MSG_ATTENTION	0xe0	/* preceeded by P, len */
#	define DTOP_ATN_OK_STATUS	0x00	/* anything else bad */
					/* followed by 0-30 bytes */

#define	DTOP_MSG_ID_REPLY	0xe1	/* preceeded by P,len (29..32) */

typedef struct {
	unsigned char	module_revision[8];	/* ascii, blank padded */
	unsigned char	vendor_name[8];
	unsigned char	module_name[8];
	int		device_number;	/* 32 bits cpl-2 */
	/* 0-3 optional bytes follow, ignore */
} dtop_id_reply_t;

#define	DTOP_MSG_CAP_REPLY	0xe3	/* preceeded by P,len (3..32) */
					/* followed by 16 bit u_offset */
					/* followed by data */

#define	DTOP_MSG_APPL_SIGNAL	0xa0	/* application level signal */
#	define DTOP_SIG_ATTENTION	0x00
#	define DTOP_SIG_RESET		0x01
#	define DTOP_SIG_HALT		0x02

#define	DTOP_MSG_APPL_TREPLY	0xa1	/* followed by status (0-->ok) */
					/* and 0..30 bytes of result data  */

/* reserved message codes (testing, manifacturing) */

#define	DTOP_MSG_RES0		0xc0
#define	DTOP_MSG_RES1		0xc1
#define	DTOP_MSG_RES2		0xc2
#define	DTOP_MSG_RES3		0xc3


/*
 *	Device specific definitions:  Keyboard
 */

/* from host to keyboard */

#define	DTOP_KMSG_CLICK		0x01	/* preceeded by P, sub len 2 */
#	define	DTOP_CLICK_VOLUME_MAX	0x7	/* followed by one byte */

#define	DTOP_KMSG_BELL		0x02	/* preceeded by P, sub len 2 */
					/* same as above */

#define	DTOP_KMSG_LED		0x03	/* preceeded by P, sub len 2 */
					/* four lower bits turn leds on */

#define	DTOP_KMSG_POLL		0x04	/* preceeded by P, sub len 1 */

/* keyboard sends up to 11 codes in a data message, distinguished values: */
#define	DTOP_KBD_EMPTY		0x00
#define	DTOP_KBD_OUT_ERR	0x01
#define	DTOP_KBD_IN_ERR		0x02

#define	DTOP_KBD_KEY_MIN	0x08
#define	DTOP_KBD_KEY_MAX	0xff

/* powerup status values: 0 ok, else.. */
#define	DTOP_KBD_ROM_FAIL	0x01
#define	DTOP_KBD_RAM_FAIL	0x02
#define	DTOP_KBD_KEY_DOWN	0x03


/*
 *	Device specific definitions:  Locators (mouse)
 */

/* locator sends this type of report data */

typedef struct {
	unsigned short	buttons;	/* 1->pressed */
	short		x;
	short		y;
	short		z;
	/* possibly 3 more dimensions for gloves */
} dtop_locator_msg_t;

#define	DTOP_LMSG_SET_RATE	0x01	/* preceeded by P,sub, len 2 */
					/* followed by sampling interval,
					   from 8 to 25 msecs (0->polled */

#define	DTOP_LMSG_POLL		0x02	/* preceeded by P,sub, len 1 */

/* Powerup codes same as keyboard */


/*
 * Implementation specific definitions
 */

typedef	union {

	dtop_message	unknown_report;

	struct {
		char		last_codes_count;
		unsigned char	last_codes[11];	/* max as per specs */
		unsigned int	last_msec;	/* autorepeat state */
		unsigned short	poll_frequency;
		unsigned char	k_ar_state;
#		define		K_AR_IDLE	0	/* quiescent, no polling */
#		define		K_AR_OFF	4	/* turn off polling pls */
#		define		K_AR_ACTIVE	2	/* polling, no autos yet */
#		define		K_AR_TRIGGER	1	/* sent one autorepeat */
	} keyboard;

	struct {
		unsigned char	type : 7, /* DEV_MOUSE, DEV_TABLET, .. */
				relative : 1;
		unsigned char	n_coords;
		unsigned short	prev_buttons;
#		define		L_BUTTON_MAX	16
		unsigned char	button_code[L_BUTTON_MAX];
#		define		L_COORD_MAX	6
		unsigned int	coordinate[L_COORD_MAX];	/* max 6D */
	} locator;

	/* add more as they come along */

} dtop_device, *dtop_device_t;


#define	DTOP_EVENT_RECEIVE_PACKET	1
#define	DTOP_EVENT_BAD_PACKET		2
#define	DTOP_EVENT_PUTC			4
#define	DTOP_EVENT_POLL			8


/*
 * Device numbers.
 */
#define	DTOPKBD_PORT	0
#define	DTOPMOUSE_PORT	1
#endif	/* _DTOP_H_ */