dtvar.h revision 1.6 1 1.6 tsutsui /* $NetBSD: dtvar.h,v 1.6 2011/06/04 01:37:36 tsutsui 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 *
19 1.2 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.2 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.2 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.2 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.2 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.2 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.2 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.2 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.2 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.2 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.2 ad * POSSIBILITY OF SUCH DAMAGE.
30 1.2 ad */
31 1.2 ad
32 1.2 ad #ifndef _DTVAR_H_
33 1.2 ad #define _DTVAR_H_
34 1.2 ad
35 1.2 ad #define DT_DEVICE_NO(a) (((a) - DT_ADDR_FIRST) >> 1)
36 1.3 ad #define DT_GET_SHORT(b0, b1) (((b0) << 8) | (b1))
37 1.2 ad
38 1.2 ad struct dt_msg {
39 1.2 ad uint8_t dst;
40 1.2 ad uint8_t src;
41 1.3 ad uint8_t ctl;
42 1.2 ad
43 1.2 ad /* varzise, checksum byte at end */
44 1.2 ad uint8_t body[DT_MAX_MSG_SIZE-3];
45 1.2 ad
46 1.2 ad union {
47 1.2 ad SLIST_ENTRY(dt_msg) slist;
48 1.2 ad SIMPLEQ_ENTRY(dt_msg) simpleq;
49 1.2 ad } chain;
50 1.2 ad };
51 1.2 ad
52 1.3 ad #define DT_CTL(l, s, p) \
53 1.3 ad ((l & 0x1f) | ((s & 0x03) << 5) | ((p & 0x01) << 7))
54 1.3 ad #define DT_CTL_P(c) ((c >> 7) & 0x01)
55 1.3 ad #define DT_CTL_SUBADDR(c) ((c >> 5) & 0x03)
56 1.3 ad #define DT_CTL_LEN(c) (c & 0x1f)
57 1.3 ad
58 1.2 ad struct dt_device {
59 1.6 tsutsui void *dtdv_arg;
60 1.3 ad void (*dtdv_handler)(void *, struct dt_msg *);
61 1.2 ad };
62 1.2 ad
63 1.2 ad struct dt_state {
64 1.2 ad volatile u_int *ds_data;
65 1.2 ad volatile u_int *ds_poll;
66 1.2 ad int ds_bad_pkts;
67 1.2 ad int ds_state;
68 1.2 ad int ds_escaped;
69 1.2 ad int ds_len;
70 1.2 ad int ds_ptr;
71 1.2 ad };
72 1.2 ad
73 1.2 ad struct dt_softc {
74 1.6 tsutsui device_t sc_dev;
75 1.2 ad struct dt_msg sc_msg;
76 1.3 ad void *sc_sih;
77 1.2 ad SLIST_HEAD(, dt_msg) sc_free;
78 1.3 ad SIMPLEQ_HEAD(, dt_msg) sc_queue;
79 1.2 ad };
80 1.2 ad
81 1.2 ad struct dt_attach_args {
82 1.2 ad int dta_addr;
83 1.2 ad };
84 1.2 ad
85 1.2 ad #define DT_GET_ERROR -1
86 1.2 ad #define DT_GET_DONE 0
87 1.2 ad #define DT_GET_NOTYET 1
88 1.2 ad
89 1.2 ad void dt_cninit(void);
90 1.2 ad int dt_identify(int, struct dt_ident *);
91 1.2 ad int dt_msg_get(struct dt_msg *, int);
92 1.3 ad void dt_msg_dump(struct dt_msg *);
93 1.3 ad int dt_establish_handler(struct dt_softc *, struct dt_device *,
94 1.6 tsutsui void *, void (*)(void *, struct dt_msg *));
95 1.2 ad
96 1.2 ad extern int dt_kbd_addr;
97 1.3 ad extern struct dt_device dt_kbd_dv;
98 1.3 ad extern int dt_ms_addr;
99 1.3 ad extern struct dt_device dt_ms_dv;
100 1.2 ad extern struct dt_state dt_state;
101 1.2 ad
102 1.2 ad #endif /* !_DTVAR_H_ */
103