pckbportvar.h revision 1.1 1 /* $NetBSD: pckbportvar.h,v 1.1 2004/03/13 17:31:33 bjh21 Exp $ */
2
3 /*
4 * Copyright (c) 2004 Ben Harris
5 * Copyright (c) 1998
6 * Matthias Drochner. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed for the NetBSD Project
19 * by Matthias Drochner.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
35
36 #ifndef _DEV_PCKBPORT_PCKBPORTVAR_H_
37 #define _DEV_PCKBPORT_PCKBPORTVAR_H_
38
39 #include <sys/callout.h>
40
41 typedef struct pckbport_tag *pckbport_tag_t;
42 typedef int pckbport_slot_t;
43
44 #define PCKBPORT_KBD_SLOT 0
45 #define PCKBPORT_AUX_SLOT 1
46 #define PCKBPORT_NSLOTS 2
47
48 typedef void (*pckbport_inputfcn) __P((void *, int));
49
50 struct pckbport_accessops {
51 /* Functions to be provided by controller driver (eg pckbc) */
52 int (*t_xt_translation)(void *, pckbport_slot_t, int);
53 int (*t_send_devcmd) (void *, pckbport_slot_t, u_char);
54 int (*t_poll_data1) (void *, pckbport_slot_t);
55 void (*t_slot_enable) (void *, pckbport_slot_t, int);
56 void (*t_intr_establish)(void *, pckbport_slot_t);
57 void (*t_set_poll) (void *, pckbport_slot_t, int);
58 };
59
60 /*
61 * external representation (pckbport_tag_t),
62 * needed early for console operation
63 */
64 struct pckbport_tag {
65 struct pckbport_slotdata *t_slotdata[PCKBPORT_NSLOTS];
66
67 struct callout t_cleanup;
68
69 pckbport_inputfcn t_inputhandler[PCKBPORT_NSLOTS];
70 void *t_inputarg[PCKBPORT_NSLOTS];
71 char *t_subname[PCKBPORT_NSLOTS];
72
73 struct pckbport_accessops const *t_ops;
74 /* First argument to all those */
75 void *t_cookie;
76 };
77
78 struct pckbport_attach_args {
79 pckbport_tag_t pa_tag;
80 pckbport_slot_t pa_slot;
81 };
82
83 extern const char * const pckbport_slot_names[];
84 extern struct pckbport_tag pckbport_consdata;
85 extern int pckbport_console_attached;
86
87 /* Calls from pckbd etc */
88 void pckbport_set_inputhandler __P((pckbport_tag_t, pckbport_slot_t,
89 pckbport_inputfcn, void *, char *));
90
91 void pckbport_flush __P((pckbport_tag_t, pckbport_slot_t));
92 int pckbport_poll_cmd __P((pckbport_tag_t, pckbport_slot_t, u_char *, int,
93 int, u_char *, int));
94 int pckbport_enqueue_cmd __P((pckbport_tag_t, pckbport_slot_t, u_char *, int,
95 int, int, u_char *));
96 int pckbport_poll_data __P((pckbport_tag_t, pckbport_slot_t));
97 void pckbport_set_poll __P((pckbport_tag_t, pckbport_slot_t, int));
98 int pckbport_xt_translation __P((pckbport_tag_t, pckbport_slot_t, int));
99 void pckbport_slot_enable __P((pckbport_tag_t, pckbport_slot_t, int));
100
101 /* calls from pckbc etc */
102 int pckbport_cnattach __P((void *, struct pckbport_accessops const *,
103 pckbport_slot_t));
104 pckbport_tag_t pckbport_attach __P((void *,
105 struct pckbport_accessops const *));
106 struct device *pckbport_attach_slot __P((struct device *, pckbport_tag_t,
107 pckbport_slot_t));
108 void pckbportintr __P((pckbport_tag_t, pckbport_slot_t, int));
109
110 /* md hook for use without mi wscons */
111 int pckbport_machdep_cnattach __P((pckbport_tag_t, pckbport_slot_t));
112
113 #endif /* _DEV_PCKBPORT_PCKBPORTVAR_H_ */
114