ite_compat.c revision 1.1.2.2 1 1.1.2.2 scottr /* $NetBSD: ite_compat.c,v 1.1.2.2 2000/02/07 08:20:48 scottr Exp $ */
2 1.1.2.1 scottr
3 1.1.2.1 scottr /*
4 1.1.2.2 scottr * Copyright (C) 2000 Scott Reynolds
5 1.1.2.2 scottr * All rights reserved.
6 1.1.2.2 scottr *
7 1.1.2.2 scottr * Redistribution and use in source and binary forms, with or without
8 1.1.2.2 scottr * modification, are permitted provided that the following conditions
9 1.1.2.2 scottr * are met:
10 1.1.2.2 scottr * 1. Redistributions of source code must retain the above copyright
11 1.1.2.2 scottr * notice, this list of conditions and the following disclaimer.
12 1.1.2.2 scottr * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.2.2 scottr * notice, this list of conditions and the following disclaimer in the
14 1.1.2.2 scottr * documentation and/or other materials provided with the distribution.
15 1.1.2.2 scottr * 3. The name of the author may not be used to endorse or promote products
16 1.1.2.2 scottr * derived from this software without specific prior written permission.
17 1.1.2.2 scottr *
18 1.1.2.2 scottr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1.2.2 scottr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1.2.2 scottr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1.2.2 scottr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1.2.2 scottr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 1.1.2.2 scottr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 1.1.2.2 scottr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 1.1.2.2 scottr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 1.1.2.2 scottr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 1.1.2.2 scottr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.1.2.1 scottr */
29 1.1.2.1 scottr
30 1.1.2.1 scottr #include "ite.h"
31 1.1.2.1 scottr
32 1.1.2.1 scottr #include <sys/param.h>
33 1.1.2.1 scottr #include <sys/systm.h>
34 1.1.2.1 scottr #include <sys/conf.h>
35 1.1.2.1 scottr #include <sys/device.h>
36 1.1.2.1 scottr #include <sys/ioctl.h>
37 1.1.2.1 scottr
38 1.1.2.1 scottr #include <machine/cpu.h>
39 1.1.2.1 scottr #include <machine/iteioctl.h>
40 1.1.2.1 scottr #include <mac68k/dev/itevar.h>
41 1.1.2.1 scottr
42 1.1.2.1 scottr cdev_decl(ite);
43 1.1.2.1 scottr cdev_decl(wsdisplay);
44 1.1.2.1 scottr void iteattach __P((int));
45 1.1.2.1 scottr
46 1.1.2.1 scottr dev_t wscdev;
47 1.1.2.1 scottr static int bell_freq = 1880;
48 1.1.2.1 scottr static int bell_length = 10;
49 1.1.2.1 scottr static int bell_volume = 100;
50 1.1.2.1 scottr
51 1.1.2.1 scottr
52 1.1.2.1 scottr /*ARGSUSED*/
53 1.1.2.1 scottr void
54 1.1.2.1 scottr iteattach(n)
55 1.1.2.1 scottr int n;
56 1.1.2.1 scottr {
57 1.1.2.1 scottr /* Do nothing; there's only one console. */
58 1.1.2.1 scottr }
59 1.1.2.1 scottr
60 1.1.2.1 scottr /*ARGSUSED*/
61 1.1.2.1 scottr void
62 1.1.2.1 scottr ite_attach(parent, dev)
63 1.1.2.1 scottr struct device *parent;
64 1.1.2.1 scottr dev_t dev;
65 1.1.2.1 scottr {
66 1.1.2.1 scottr wscdev = dev;
67 1.1.2.1 scottr }
68 1.1.2.1 scottr
69 1.1.2.1 scottr /*
70 1.1.2.1 scottr * Tty handling functions
71 1.1.2.1 scottr */
72 1.1.2.1 scottr
73 1.1.2.1 scottr int
74 1.1.2.1 scottr iteopen(dev, mode, devtype, p)
75 1.1.2.1 scottr dev_t dev;
76 1.1.2.1 scottr int mode;
77 1.1.2.1 scottr int devtype;
78 1.1.2.1 scottr struct proc *p;
79 1.1.2.1 scottr {
80 1.1.2.1 scottr return wsdisplayopen(wscdev, mode, devtype, p);
81 1.1.2.1 scottr }
82 1.1.2.1 scottr
83 1.1.2.1 scottr int
84 1.1.2.1 scottr iteclose(dev, flag, mode, p)
85 1.1.2.1 scottr dev_t dev;
86 1.1.2.1 scottr int flag;
87 1.1.2.1 scottr int mode;
88 1.1.2.1 scottr struct proc *p;
89 1.1.2.1 scottr {
90 1.1.2.1 scottr return wsdisplayclose(wscdev, flag, mode, p);
91 1.1.2.1 scottr }
92 1.1.2.1 scottr
93 1.1.2.1 scottr int
94 1.1.2.1 scottr iteread(dev, uio, flag)
95 1.1.2.1 scottr dev_t dev;
96 1.1.2.1 scottr struct uio *uio;
97 1.1.2.1 scottr int flag;
98 1.1.2.1 scottr {
99 1.1.2.1 scottr return wsdisplayread(wscdev, uio, flag);
100 1.1.2.1 scottr }
101 1.1.2.1 scottr
102 1.1.2.1 scottr int
103 1.1.2.1 scottr itewrite(dev, uio, flag)
104 1.1.2.1 scottr dev_t dev;
105 1.1.2.1 scottr struct uio *uio;
106 1.1.2.1 scottr int flag;
107 1.1.2.1 scottr {
108 1.1.2.1 scottr return wsdisplaywrite(wscdev, uio, flag);
109 1.1.2.1 scottr }
110 1.1.2.1 scottr
111 1.1.2.1 scottr struct tty *
112 1.1.2.1 scottr itetty(dev)
113 1.1.2.1 scottr dev_t dev;
114 1.1.2.1 scottr {
115 1.1.2.1 scottr return wsdisplaytty(wscdev);
116 1.1.2.1 scottr }
117 1.1.2.1 scottr
118 1.1.2.1 scottr void
119 1.1.2.1 scottr itestop(struct tty *tp, int flag)
120 1.1.2.1 scottr {
121 1.1.2.1 scottr }
122 1.1.2.1 scottr
123 1.1.2.1 scottr int
124 1.1.2.1 scottr iteioctl(dev, cmd, addr, flag, p)
125 1.1.2.1 scottr dev_t dev;
126 1.1.2.1 scottr u_long cmd;
127 1.1.2.1 scottr caddr_t addr;
128 1.1.2.1 scottr int flag;
129 1.1.2.1 scottr struct proc *p;
130 1.1.2.1 scottr {
131 1.1.2.1 scottr switch (cmd) {
132 1.1.2.1 scottr case ITEIOC_RINGBELL:
133 1.1.2.1 scottr return mac68k_ring_bell(bell_freq, bell_length, bell_volume);
134 1.1.2.1 scottr case ITEIOC_SETBELL:
135 1.1.2.1 scottr {
136 1.1.2.1 scottr struct bellparams *bp = (void *)addr;
137 1.1.2.1 scottr
138 1.1.2.1 scottr /* Do some sanity checks. */
139 1.1.2.1 scottr if (bp->freq < 10 || bp->freq > 40000)
140 1.1.2.1 scottr return (EINVAL);
141 1.1.2.1 scottr if (bp->len < 0 || bp->len > 3600)
142 1.1.2.1 scottr return (EINVAL);
143 1.1.2.1 scottr if (bp->vol < 0 || bp->vol > 100)
144 1.1.2.1 scottr return (EINVAL);
145 1.1.2.1 scottr
146 1.1.2.1 scottr bell_freq = bp->freq;
147 1.1.2.1 scottr bell_length = bp->len;
148 1.1.2.1 scottr bell_volume = bp->vol;
149 1.1.2.1 scottr return (0);
150 1.1.2.1 scottr }
151 1.1.2.1 scottr case ITEIOC_GETBELL:
152 1.1.2.1 scottr {
153 1.1.2.1 scottr struct bellparams *bp = (void *)addr;
154 1.1.2.1 scottr
155 1.1.2.1 scottr bell_freq = bp->freq;
156 1.1.2.1 scottr bell_length = bp->len;
157 1.1.2.1 scottr bell_volume = bp->vol;
158 1.1.2.1 scottr return (0);
159 1.1.2.1 scottr }
160 1.1.2.1 scottr default:
161 1.1.2.1 scottr return wsdisplayioctl(wscdev, cmd, addr, flag, p);
162 1.1.2.1 scottr }
163 1.1.2.1 scottr
164 1.1.2.1 scottr return (ENOTTY);
165 1.1.2.1 scottr }
166