1 /* $NetBSD: dcm.c,v 1.6 2005/12/11 12:17:19 christos Exp $ */
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * @(#)dcm.c 8.1 (Berkeley) 6/10/93
38 * Copyright (c) 1988 University of Utah.
40 * This code is derived from software contributed to Berkeley by
41 * the Systems Programming Group of the University of Utah Computer
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by the University of
55 * California, Berkeley and its contributors.
56 * 4. Neither the name of the University nor the names of its contributors
57 * may be used to endorse or promote products derived from this software
58 * without specific prior written permission.
60 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * @(#)dcm.c 8.1 (Berkeley) 6/10/93
76 #include <sys/param.h>
79 #include <hp300/dev/dcmreg.h>
81 #include <hp300/stand/common/consdefs.h>
82 #include <hp300/stand/common/samachdep.h>
83 #include <hp300/stand/common/device.h>
85 struct dcmdevice
*dcmcnaddr
= NULL
;
87 #define DCMCONUNIT 1 /* XXX */
90 dcmprobe(struct consdev
*cp
)
93 struct dcmdevice
*dcm
;
95 for (hw
= sc_table
; hw
< &sc_table
[MAXCTLRS
]; hw
++)
96 if (HW_ISDEV(hw
, D_COMMDCM
) && !badaddr((void *)hw
->hw_kva
))
98 if (!HW_ISDEV(hw
, D_COMMDCM
)) {
102 dcmcnaddr
= (struct dcmdevice
*) hw
->hw_kva
;
104 #ifdef FORCEDCMCONSOLE
105 cp
->cn_pri
= CN_REMOTE
;
108 switch (dcm
->dcm_rsid
) {
110 cp
->cn_pri
= CN_NORMAL
;
113 cp
->cn_pri
= CN_REMOTE
;
116 cp
->cn_pri
= CN_DEAD
;
120 curcons_scode
= hw
->hw_sc
;
125 dcminit(struct consdev
*cp
)
127 struct dcmdevice
*dcm
= dcmcnaddr
;
128 int port
= DCMCONUNIT
;
131 while (dcm
->dcm_thead
[port
].ptr
!= dcm
->dcm_ttail
[port
].ptr
)
133 dcm
->dcm_data
[port
].dcm_baud
= BR_9600
;
134 dcm
->dcm_data
[port
].dcm_conf
= LC_8BITS
| LC_1STOP
;
136 dcm
->dcm_cmdtab
[port
].dcm_data
|= CT_CON
;
137 dcm
->dcm_cr
|= (1 << port
);
145 dcmgetchar(dev_t dev
)
147 struct dcmdevice
*dcm
= dcmcnaddr
;
148 struct dcmrfifo
*fifo
;
154 pp
= dcm_preg(dcm
, port
);
155 head
= pp
->r_head
& RX_MASK
;
156 if (head
== (pp
->r_tail
& RX_MASK
))
158 fifo
= &dcm
->dcm_rfifos
[3-port
][head
>>1];
160 stat
= fifo
->data_stat
;
161 pp
->r_head
= (head
+ 2) & RX_MASK
;
169 dcmgetchar(dev_t dev
)
178 dcmputchar(dev_t dev
, int c
)
180 struct dcmdevice
*dcm
= dcmcnaddr
;
187 pp
= dcm_preg(dcm
, port
);
188 tail
= pp
->t_tail
& TX_MASK
;
190 while (tail
!= (pp
->t_head
& TX_MASK
) && --timo
)
192 dcm
->dcm_tfifos
[3-port
][tail
].data_char
= c
;
193 pp
->t_tail
= tail
= (tail
+ 1) & TX_MASK
;
195 dcm
->dcm_cmdtab
[port
].dcm_data
|= CT_TX
;
196 dcm
->dcm_cr
|= (1 << port
);
199 while (tail
!= (pp
->t_head
& TX_MASK
) && --timo
)