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