1 /* $NetBSD: ite_compat.c,v 1.9 2005/12/11 12:18:02 christos Exp $ */
4 * Copyright (C) 2000 Scott Reynolds
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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.
31 * The main thing to realize about this emulator is that the old console
32 * emulator was largely compatible with the DEC VT-220. Since the
33 * wsdiplay driver has a more complete emulation of that terminal, it's
34 * reasonable to pass virtually everything up to that driver without
38 #include <sys/cdefs.h>
39 __KERNEL_RCSID(0, "$NetBSD: ite_compat.c,v 1.9 2005/12/11 12:18:02 christos Exp $");
42 #include "wsdisplay.h"
44 #include <sys/param.h>
45 #include <sys/systm.h>
47 #include <sys/device.h>
48 #include <sys/ioctl.h>
49 #include <sys/ttycom.h>
53 #include <machine/cpu.h>
54 #include <machine/iteioctl.h>
56 dev_type_open(iteopen
);
57 dev_type_close(iteclose
);
58 dev_type_read(iteread
);
59 dev_type_write(itewrite
);
60 dev_type_ioctl(iteioctl
);
62 dev_type_poll(itepoll
);
63 dev_type_kqfilter(itekqfilter
);
65 const struct cdevsw ite_cdevsw
= {
66 iteopen
, iteclose
, iteread
, itewrite
, iteioctl
,
67 nostop
, itetty
, itepoll
, nommap
, itekqfilter
, D_TTY
71 extern const struct cdevsw wsdisplay_cdevsw
;
76 static int ite_initted
= 0;
77 static int ite_bell_freq
= 1880;
78 static int ite_bell_length
= 10;
79 static int ite_bell_volume
= 100;
89 maj
= cdevsw_lookup_major(&wsdisplay_cdevsw
);
92 if (maj
!= major(cn_tab
->cn_dev
))
100 * Tty handling functions
105 iteopen(dev_t dev
, int mode
, int devtype
, struct lwp
*l
)
107 return ite_initted
? (0) : (ENXIO
);
112 iteclose(dev_t dev
, int flag
, int mode
, struct lwp
*l
)
114 return ite_initted
? (0) : (ENXIO
);
119 iteread(dev_t dev
, struct uio
*uio
, int flag
)
122 (*wsdisplay_cdevsw
.d_read
)(cn_tab
->cn_dev
, uio
, flag
) : (ENXIO
);
127 itewrite(dev_t dev
, struct uio
*uio
, int flag
)
130 (*wsdisplay_cdevsw
.d_write
)(cn_tab
->cn_dev
, uio
, flag
) : (ENXIO
);
137 return ite_initted
? (*wsdisplay_cdevsw
.d_tty
)(cn_tab
->cn_dev
) : (NULL
);
142 iteioctl(dev_t dev
, u_long cmd
, void *addr
, int flag
, struct lwp
*l
)
148 case ITEIOC_RINGBELL
:
149 return mac68k_ring_bell(ite_bell_freq
,
150 ite_bell_length
, ite_bell_volume
);
153 struct bellparams
*bp
= (void *)addr
;
155 /* Do some sanity checks. */
156 if (bp
->freq
< 10 || bp
->freq
> 40000)
158 if (bp
->len
< 0 || bp
->len
> 3600)
160 if (bp
->vol
< 0 || bp
->vol
> 100)
163 ite_bell_freq
= bp
->freq
;
164 ite_bell_length
= bp
->len
;
165 ite_bell_volume
= bp
->vol
;
170 struct bellparams
*bp
= (void *)addr
;
172 ite_bell_freq
= bp
->freq
;
173 ite_bell_length
= bp
->len
;
174 ite_bell_volume
= bp
->vol
;
178 return ((*wsdisplay_cdevsw
.d_ioctl
)(cn_tab
->cn_dev
, cmd
,
187 itepoll(dev_t dev
, int events
, struct lwp
*l
)
190 (*wsdisplay_cdevsw
.d_poll
)(cn_tab
->cn_dev
, events
, l
) : (ENXIO
);
194 itekqfilter(dev_t dev
, struct knote
*kn
)
197 (*wsdisplay_cdevsw
.d_kqfilter
)(cn_tab
->cn_dev
, kn
) : (ENXIO
);