dtvar.h revision 1.4 1 1.4 christos /* $NetBSD: dtvar.h,v 1.4 2005/12/11 12:18:41 christos Exp $ */
2 1.2 ad
3 1.2 ad /*-
4 1.2 ad * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
5 1.2 ad * All rights reserved.
6 1.2 ad *
7 1.2 ad * This code is derived from software contributed to The NetBSD Foundation
8 1.2 ad * by Andrew Doran.
9 1.2 ad *
10 1.2 ad * Redistribution and use in source and binary forms, with or without
11 1.2 ad * modification, are permitted provided that the following conditions
12 1.2 ad * are met:
13 1.2 ad * 1. Redistributions of source code must retain the above copyright
14 1.2 ad * notice, this list of conditions and the following disclaimer.
15 1.2 ad * 2. Redistributions in binary form must reproduce the above copyright
16 1.2 ad * notice, this list of conditions and the following disclaimer in the
17 1.2 ad * documentation and/or other materials provided with the distribution.
18 1.2 ad * 3. All advertising materials mentioning features or use of this software
19 1.2 ad * must display the following acknowledgement:
20 1.2 ad * This product includes software developed by the NetBSD
21 1.2 ad * Foundation, Inc. and its contributors.
22 1.2 ad * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.2 ad * contributors may be used to endorse or promote products derived
24 1.2 ad * from this software without specific prior written permission.
25 1.2 ad *
26 1.2 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.2 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.2 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.2 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.2 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.2 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.2 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.2 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.2 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.2 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.2 ad * POSSIBILITY OF SUCH DAMAGE.
37 1.2 ad */
38 1.2 ad
39 1.2 ad #ifndef _DTVAR_H_
40 1.2 ad #define _DTVAR_H_
41 1.2 ad
42 1.2 ad #define DT_DEVICE_NO(a) (((a) - DT_ADDR_FIRST) >> 1)
43 1.3 ad #define DT_GET_SHORT(b0, b1) (((b0) << 8) | (b1))
44 1.2 ad
45 1.2 ad struct dt_msg {
46 1.2 ad uint8_t dst;
47 1.2 ad uint8_t src;
48 1.3 ad uint8_t ctl;
49 1.2 ad
50 1.2 ad /* varzise, checksum byte at end */
51 1.2 ad uint8_t body[DT_MAX_MSG_SIZE-3];
52 1.2 ad
53 1.2 ad union {
54 1.2 ad SLIST_ENTRY(dt_msg) slist;
55 1.2 ad SIMPLEQ_ENTRY(dt_msg) simpleq;
56 1.2 ad } chain;
57 1.2 ad };
58 1.2 ad
59 1.3 ad #define DT_CTL(l, s, p) \
60 1.3 ad ((l & 0x1f) | ((s & 0x03) << 5) | ((p & 0x01) << 7))
61 1.3 ad #define DT_CTL_P(c) ((c >> 7) & 0x01)
62 1.3 ad #define DT_CTL_SUBADDR(c) ((c >> 5) & 0x03)
63 1.3 ad #define DT_CTL_LEN(c) (c & 0x1f)
64 1.3 ad
65 1.2 ad struct dt_device {
66 1.2 ad struct device *dtdv_dv;
67 1.3 ad void (*dtdv_handler)(void *, struct dt_msg *);
68 1.2 ad };
69 1.2 ad
70 1.2 ad struct dt_state {
71 1.2 ad volatile u_int *ds_data;
72 1.2 ad volatile u_int *ds_poll;
73 1.2 ad int ds_bad_pkts;
74 1.2 ad int ds_state;
75 1.2 ad int ds_escaped;
76 1.2 ad int ds_len;
77 1.2 ad int ds_ptr;
78 1.2 ad };
79 1.2 ad
80 1.2 ad struct dt_softc {
81 1.2 ad struct device sc_dv;
82 1.2 ad struct dt_msg sc_msg;
83 1.3 ad void *sc_sih;
84 1.2 ad SLIST_HEAD(, dt_msg) sc_free;
85 1.3 ad SIMPLEQ_HEAD(, dt_msg) sc_queue;
86 1.2 ad };
87 1.2 ad
88 1.2 ad struct dt_attach_args {
89 1.2 ad int dta_addr;
90 1.2 ad };
91 1.2 ad
92 1.2 ad #define DT_GET_ERROR -1
93 1.2 ad #define DT_GET_DONE 0
94 1.2 ad #define DT_GET_NOTYET 1
95 1.2 ad
96 1.2 ad void dt_cninit(void);
97 1.2 ad int dt_identify(int, struct dt_ident *);
98 1.2 ad int dt_msg_get(struct dt_msg *, int);
99 1.3 ad void dt_msg_dump(struct dt_msg *);
100 1.3 ad int dt_establish_handler(struct dt_softc *, struct dt_device *,
101 1.3 ad struct device *, void (*)(void *, struct dt_msg *));
102 1.2 ad
103 1.2 ad extern int dt_kbd_addr;
104 1.3 ad extern struct dt_device dt_kbd_dv;
105 1.3 ad extern int dt_ms_addr;
106 1.3 ad extern struct dt_device dt_ms_dv;
107 1.2 ad extern struct dt_state dt_state;
108 1.2 ad
109 1.2 ad #endif /* !_DTVAR_H_ */
110