2 * Copyright (c) 2000 Doug Rabson
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/param.h>
32 #include <sys/kernel.h>
34 #include <sys/module.h>
35 #include <sys/mutex.h>
38 #include <sys/systm.h>
40 #include <machine/md_var.h>
43 #include <vm/vm_param.h>
44 #include <vm/vm_kern.h>
45 #include <vm/vm_page.h>
46 #include <vm/vm_map.h>
47 #include <vm/vm_object.h>
48 #include <vm/vm_extern.h>
49 #include <vm/vm_pageout.h>
50 #include <vm/vm_pager.h>
52 #define SSC_GETCHAR 21
53 #define SSC_PUTCHAR 31
55 #define SSC_POLL_HZ 50
57 static tsw_open_t ssc_open;
58 static tsw_outwakeup_t ssc_outwakeup;
59 static tsw_close_t ssc_close;
61 static struct ttydevsw ssc_class = {
62 .tsw_flags = TF_NOPREFIX,
64 .tsw_outwakeup = ssc_outwakeup,
65 .tsw_close = ssc_close,
69 static struct callout_handle ssc_timeouthandle
70 = CALLOUT_HANDLE_INITIALIZER(&ssc_timeouthandle);
72 static void ssc_timeout(void *);
75 ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which)
77 register u_int64_t ret0 __asm("r8");
79 __asm __volatile("mov r15=%1\n\t"
82 : "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3));
87 ssc_cnprobe(struct consdev *cp)
90 strcpy(cp->cn_name, "ssccons");
91 cp->cn_pri = CN_INTERNAL;
95 ssc_cninit(struct consdev *cp)
100 ssc_cnterm(struct consdev *cp)
105 ssc_cnattach(void *arg)
109 tp = tty_alloc(&ssc_class, NULL);
110 tty_makedev(tp, NULL, "ssccons");
113 SYSINIT(ssc_cnattach, SI_SUB_DRIVERS, SI_ORDER_ANY, ssc_cnattach, 0);
116 ssc_cnputc(struct consdev *cp, int c)
118 ssc(c, 0, 0, 0, SSC_PUTCHAR);
122 ssc_cngetc(struct consdev *cp)
125 c = ssc(0, 0, 0, 0, SSC_GETCHAR);
132 ssc_open(struct tty *tp)
135 polltime = hz / SSC_POLL_HZ;
138 ssc_timeouthandle = timeout(ssc_timeout, tp, polltime);
144 ssc_close(struct tty *tp)
147 untimeout(ssc_timeout, tp, ssc_timeouthandle);
151 ssc_outwakeup(struct tty *tp)
157 len = ttydisc_getc(tp, buf, sizeof buf);
163 ssc_cnputc(NULL, buf[c++]);
174 while ((c = ssc_cngetc(NULL)) != -1)
175 ttydisc_rint(tp, c, 0);
176 ttydisc_rint_done(tp);
179 ssc_timeouthandle = timeout(ssc_timeout, tp, polltime);