Deleted Added
full compact
ofw_console.c (130585) ofw_console.c (131016)
1/*
2 * Copyright (C) 2001 Benno Rice.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 10 unchanged lines hidden (view full) ---

19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
1/*
2 * Copyright (C) 2001 Benno Rice.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 10 unchanged lines hidden (view full) ---

19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_console.c 130585 2004-06-16 09:47:26Z phk $");
27__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_console.c 131016 2004-06-24 02:57:11Z obrien $");
28
29#include "opt_ddb.h"
30#include "opt_comconsole.h"
28
29#include "opt_ddb.h"
30#include "opt_comconsole.h"
31#include "opt_ofw.h"
31
32#include <sys/param.h>
33#include <sys/kernel.h>
34#include <sys/systm.h>
35#include <sys/types.h>
36#include <sys/conf.h>
37#include <sys/cons.h>
38#include <sys/consio.h>
39#include <sys/tty.h>
40
41#include <dev/ofw/openfirm.h>
42
43#include <ddb/ddb.h>
44
32
33#include <sys/param.h>
34#include <sys/kernel.h>
35#include <sys/systm.h>
36#include <sys/types.h>
37#include <sys/conf.h>
38#include <sys/cons.h>
39#include <sys/consio.h>
40#include <sys/tty.h>
41
42#include <dev/ofw/openfirm.h>
43
44#include <ddb/ddb.h>
45
45#define OFW_POLL_HZ 4
46#ifndef OFWCONS_POLL_HZ
47#define OFWCONS_POLL_HZ 4 /* 50-100 works best on Ultra2 */
48#endif
49#define OFBURSTLEN 128 /* max number of bytes to write in one chunk */
46
47static d_open_t ofw_dev_open;
48static d_close_t ofw_dev_close;
49
50static struct cdevsw ofw_cdevsw = {
51 .d_version = D_VERSION,
52 .d_open = ofw_dev_open,
53 .d_close = ofw_dev_close,

--- 66 unchanged lines hidden (view full) ---

120 tp->t_stop = ofw_tty_stop;
121 tp->t_dev = dev;
122
123 if ((tp->t_state & TS_ISOPEN) == 0) {
124 tp->t_state |= TS_CARR_ON;
125 ttychars(tp);
126 tp->t_iflag = TTYDEF_IFLAG;
127 tp->t_oflag = TTYDEF_OFLAG;
50
51static d_open_t ofw_dev_open;
52static d_close_t ofw_dev_close;
53
54static struct cdevsw ofw_cdevsw = {
55 .d_version = D_VERSION,
56 .d_open = ofw_dev_open,
57 .d_close = ofw_dev_close,

--- 66 unchanged lines hidden (view full) ---

124 tp->t_stop = ofw_tty_stop;
125 tp->t_dev = dev;
126
127 if ((tp->t_state & TS_ISOPEN) == 0) {
128 tp->t_state |= TS_CARR_ON;
129 ttychars(tp);
130 tp->t_iflag = TTYDEF_IFLAG;
131 tp->t_oflag = TTYDEF_OFLAG;
128 tp->t_cflag = TTYDEF_CFLAG|CLOCAL;
132 tp->t_cflag = TTYDEF_CFLAG;
129 tp->t_lflag = TTYDEF_LFLAG;
130 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
131 ttsetwater(tp);
132
133 setuptimeout = 1;
134 } else if ((tp->t_state & TS_XCLUDE) && suser(td)) {
135 return (EBUSY);
136 }
137
138 error = ttyld_open(tp, dev);
139
140 if (error == 0 && setuptimeout) {
133 tp->t_lflag = TTYDEF_LFLAG;
134 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
135 ttsetwater(tp);
136
137 setuptimeout = 1;
138 } else if ((tp->t_state & TS_XCLUDE) && suser(td)) {
139 return (EBUSY);
140 }
141
142 error = ttyld_open(tp, dev);
143
144 if (error == 0 && setuptimeout) {
141 polltime = hz / OFW_POLL_HZ;
145 polltime = hz / OFWCONS_POLL_HZ;
142 if (polltime < 1) {
143 polltime = 1;
144 }
145
146 ofw_timeouthandle = timeout(ofw_timeout, tp, polltime);
147 }
148
149 return (error);

--- 7 unchanged lines hidden (view full) ---

157
158 unit = minor(dev);
159 tp = ofw_tp;
160
161 if (unit != 0) {
162 return (ENXIO);
163 }
164
146 if (polltime < 1) {
147 polltime = 1;
148 }
149
150 ofw_timeouthandle = timeout(ofw_timeout, tp, polltime);
151 }
152
153 return (error);

--- 7 unchanged lines hidden (view full) ---

161
162 unit = minor(dev);
163 tp = ofw_tp;
164
165 if (unit != 0) {
166 return (ENXIO);
167 }
168
169 /* XXX Should be replaced with callout_stop(9) */
170 untimeout(ofw_timeout, tp, ofw_timeouthandle);
165 ttyld_close(tp, flag);
166 ttyclose(tp);
167
168 return (0);
169}
170
171
172static int
173ofw_tty_param(struct tty *tp, struct termios *t)
174{
175
176 return (0);
177}
178
179static void
180ofw_tty_start(struct tty *tp)
181{
171 ttyld_close(tp, flag);
172 ttyclose(tp);
173
174 return (0);
175}
176
177
178static int
179ofw_tty_param(struct tty *tp, struct termios *t)
180{
181
182 return (0);
183}
184
185static void
186ofw_tty_start(struct tty *tp)
187{
188 struct clist *cl;
189 int len;
190 u_char buf[OFBURSTLEN];
182
191
183 if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
184 ttwwakeup(tp);
192
193 if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))
185 return;
194 return;
186 }
187
188 tp->t_state |= TS_BUSY;
195
196 tp->t_state |= TS_BUSY;
189 while (tp->t_outq.c_cc != 0) {
190 ofw_cons_putc(NULL, getc(&tp->t_outq));
191 }
197 cl = &tp->t_outq;
198 len = q_to_b(cl, buf, OFBURSTLEN);
199 OF_write(stdout, buf, len);
192 tp->t_state &= ~TS_BUSY;
193
194 ttwwakeup(tp);
195}
196
197static void
198ofw_tty_stop(struct tty *tp, int flag)
199{

--- 108 unchanged lines hidden ---
200 tp->t_state &= ~TS_BUSY;
201
202 ttwwakeup(tp);
203}
204
205static void
206ofw_tty_stop(struct tty *tp, int flag)
207{

--- 108 unchanged lines hidden ---