1 /* $NetBSD: ssc.c,v 1.5 2016/05/13 13:40:55 christos Exp $ */
2
3 /*-
4 * Copyright (c) 2000 Doug Rabson
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 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD$
29 */
30
31 #include <sys/param.h>
32
33 #include <machine/ssc.h>
34
35 #include <dev/cons.h>
36
37
38 #define SSC_POLL_HZ 50
39
40 void sscconsattach(device_t, device_t, void *);
41
42 void ssccnprobe(struct consdev *);
43 void ssccninit(struct consdev *);
44 void ssccnputc(dev_t, int);
45 int ssccngetc(dev_t);
46 void ssccnpollc(dev_t, int);
47
48
49 __attribute__((__noinline__))
50 uint64_t
ssc(uint64_t in0,uint64_t in1,uint64_t in2,uint64_t in3,int which)51 ssc(uint64_t in0, uint64_t in1, uint64_t in2, uint64_t in3, int which)
52 {
53 register uint64_t ret0 __asm("r8");
54
55 __asm __volatile("mov r15=%1\n\t"
56 "break 0x80001"
57 : "=r"(ret0)
58 : "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3));
59 return ret0;
60 }
61
62
63 void
sscconsattach(device_t parent,device_t self,void * aux)64 sscconsattach(device_t parent, device_t self, void *aux)
65 {
66 /* not yet */
67 }
68
69 void
ssccnprobe(struct consdev * cp)70 ssccnprobe(struct consdev *cp)
71 {
72
73 cp->cn_dev = ~NODEV; /* XXXX: And already exists */
74 cp->cn_pri = CN_INTERNAL;
75 }
76
77 void
ssccninit(struct consdev * cp)78 ssccninit(struct consdev *cp)
79 {
80 /* nothing */
81 }
82
83 void
ssccnputc(dev_t dev,int c)84 ssccnputc(dev_t dev, int c)
85 {
86
87 ssc(c, 0, 0, 0, SSC_PUTCHAR);
88 }
89
90 int
ssccngetc(dev_t dev)91 ssccngetc(dev_t dev)
92 {
93 int c;
94
95 do {
96 c = ssc(0, 0, 0, 0, SSC_GETCHAR);
97 } while (c == 0);
98
99 return c;
100 }
101
102 void
ssccnpollc(dev_t dev,int on)103 ssccnpollc(dev_t dev, int on)
104 {
105 /* nothing */
106 }
107
108 /* XXX: integrate the rest of the ssc.c stuff from FreeBSD to plug into wsdisplay */
109