Deleted Added
full compact
1/*-
2 * Copyright (c) 1991 The Regents of the University of California.
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

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

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $FreeBSD: head/sys/pc98/cbus/sio.c 119525 2003-08-28 11:20:54Z nyan $
33 * $FreeBSD: head/sys/pc98/cbus/sio.c 120491 2003-09-26 19:35:50Z phk $
34 * from: @(#)com.c 7.5 (Berkeley) 5/16/91
35 * from: i386/isa sio.c,v 1.234
36 */
37
38#include "opt_comconsole.h"
39#include "opt_compat.h"
40#include "opt_ddb.h"
41#include "opt_sio.h"

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

3958struct siocnstate {
3959 u_char dlbl;
3960 u_char dlbh;
3961 u_char ier;
3962 u_char cfcr;
3963 u_char mcr;
3964};
3965
3966/*
3967 * This is a function in order to not replicate "ttyd%d" more
3968 * places than absolutely necessary.
3969 */
3970static void
3971siocnset(struct consdev *cd, int unit)
3972{
3973
3974 cd->cn_unit = unit;
3975 sprintf(cd->cn_name, "ttyd%d", unit);
3976}
3977
3978#ifndef __alpha__
3979static speed_t siocngetspeed(Port_t, u_long rclk);
3980#endif
3981static void siocnclose(struct siocnstate *sp, Port_t iobase);
3982static void siocnopen(struct siocnstate *sp, Port_t iobase, int speed);
3983static void siocntxwait(Port_t iobase);
3984
3985#ifdef __alpha__

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

4192 outb(iobase + com_dlbl, divisor & 0xff);
4193 outb(iobase + com_dlbh, divisor >> 8);
4194 outb(iobase + com_cfcr, cfcr);
4195
4196 siocnopen(&sp, iobase, comdefaultrate);
4197
4198 splx(s);
4199 if (COM_CONSOLE(flags) && !COM_LLCONSOLE(flags)) {
4188 cp->cn_dev = makedev(CDEV_MAJOR, unit);
4200 siocnset(cp, unit);
4201 cp->cn_pri = COM_FORCECONSOLE(flags)
4202 || boothowto & RB_SERIAL
4203 ? CN_REMOTE : CN_NORMAL;
4204 siocniobase = iobase;
4205 siocnunit = unit;
4206 }
4207 if (COM_DEBUGGER(flags)) {
4208 printf("sio%d: gdb debugging port\n", unit);
4209 siogdbiobase = iobase;
4210 siogdbunit = unit;
4211#if DDB > 0
4200 gdbconsdev.cn_dev = makedev(CDEV_MAJOR, unit);
4212 siocnset(&gdbconsdev, unit);
4213 gdb_arg = &gdbconsdev;
4214 gdb_getc = siocngetc;
4215 gdb_putc = siocnputc;
4216#endif
4217 }
4218 }
4219 }
4220#ifdef __i386__

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

4226 */
4227 if (gdb_arg == NULL && (boothowto & RB_GDB)) {
4228 printf("Warning: no GDB port specified. Defaulting to sio%d.\n",
4229 siocnunit);
4230 printf("Set flag 0x80 on desired GDB port in your\n");
4231 printf("configuration file (currently sio only).\n");
4232 siogdbiobase = siocniobase;
4233 siogdbunit = siocnunit;
4222 gdbconsdev.cn_dev = makedev(CDEV_MAJOR, siocnunit);
4234 siocnset(&gdbconsdev, siocnunit);
4235 gdb_arg = &gdbconsdev;
4236 gdb_getc = siocngetc;
4237 gdb_putc = siocnputc;
4238 }
4239#endif
4240#endif
4241}
4242
4243static void
4244siocninit(cp)
4245 struct consdev *cp;
4246{
4235 comconsole = DEV_TO_UNIT(cp->cn_dev);
4247 comconsole = cp->cn_unit;
4248}
4249
4250static void
4251siocnterm(cp)
4252 struct consdev *cp;
4253{
4254 comconsole = -1;
4255}

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

4270 u_int divisor;
4271 struct siocnstate sp;
4272 int unit = 0; /* XXX random value! */
4273
4274 siocniobase = port;
4275 siocnunit = unit;
4276 comdefaultrate = speed;
4277 sio_consdev.cn_pri = CN_NORMAL;
4266 sio_consdev.cn_dev = makedev(CDEV_MAJOR, unit);
4278 siocnset(&sio_consdev, unit);
4279
4280 s = spltty();
4281
4282 /*
4283 * Initialize the divisor latch. We can't rely on
4284 * siocnopen() to do this the first time, since it
4285 * avoids writing to the latch if the latch appears
4286 * to have the correct value. Also, if we didn't

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

4314 int unit = 1; /* XXX random value! */
4315
4316 siogdbiobase = port;
4317 gdbdefaultrate = speed;
4318
4319 printf("sio%d: gdb debugging port\n", unit);
4320 siogdbunit = unit;
4321#if DDB > 0
4310 gdbconsdev.cn_dev = makedev(CDEV_MAJOR, unit);
4322 siocnset(&gdbconsdev, unit);
4323 gdb_arg = &gdbconsdev;
4324 gdb_getc = siocngetc;
4325 gdb_putc = siocnputc;
4326#endif
4327
4328 s = spltty();
4329
4330 /*

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

4350}
4351
4352#endif
4353
4354static int
4355siocncheckc(struct consdev *cd)
4356{
4357 int c;
4346 dev_t dev;
4358 Port_t iobase;
4359 int s;
4360 struct siocnstate sp;
4361 speed_t speed;
4362
4352 dev = cd->cn_dev;
4353 if (minor(dev) == siocnunit) {
4363 if (cd->cn_unit == siocnunit) {
4364 iobase = siocniobase;
4365 speed = comdefaultrate;
4366 } else {
4367 iobase = siogdbiobase;
4368 speed = gdbdefaultrate;
4369 }
4370 s = spltty();
4371 siocnopen(&sp, iobase, speed);
4372 if (inb(iobase + com_lsr) & LSR_RXRDY)
4373 c = inb(iobase + com_data);
4374 else
4375 c = -1;
4376 siocnclose(&sp, iobase);
4377 splx(s);
4378 return (c);
4379}
4380
4371
4381static int
4382siocngetc(struct consdev *cd)
4383{
4384 int c;
4376 dev_t dev;
4385 Port_t iobase;
4386 int s;
4387 struct siocnstate sp;
4388 speed_t speed;
4389
4382 dev = cd->cn_dev;
4383 if (minor(dev) == siocnunit) {
4390 if (cd->cn_unit == siocnunit) {
4391 iobase = siocniobase;
4392 speed = comdefaultrate;
4393 } else {
4394 iobase = siogdbiobase;
4395 speed = gdbdefaultrate;
4396 }
4397 s = spltty();
4398 siocnopen(&sp, iobase, speed);

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

4404 return (c);
4405}
4406
4407static void
4408siocnputc(struct consdev *cd, int c)
4409{
4410 int need_unlock;
4411 int s;
4405 dev_t dev;
4412 struct siocnstate sp;
4413 Port_t iobase;
4414 speed_t speed;
4415
4410 dev = cd->cn_dev;
4411 if (minor(dev) == siocnunit) {
4416 if (cd->cn_unit == siocnunit) {
4417 iobase = siocniobase;
4418 speed = comdefaultrate;
4419 } else {
4420 iobase = siogdbiobase;
4421 speed = gdbdefaultrate;
4422 }
4423 s = spltty();
4424 need_unlock = 0;

--- 674 unchanged lines hidden ---