sio.c (119525) | sio.c (120491) |
---|---|
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 * | 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 | 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 |
|
3966#ifndef __alpha__ 3967static speed_t siocngetspeed(Port_t, u_long rclk); 3968#endif 3969static void siocnclose(struct siocnstate *sp, Port_t iobase); 3970static void siocnopen(struct siocnstate *sp, Port_t iobase, int speed); 3971static void siocntxwait(Port_t iobase); 3972 3973#ifdef __alpha__ --- 206 unchanged lines hidden (view full) --- 4180 outb(iobase + com_dlbl, divisor & 0xff); 4181 outb(iobase + com_dlbh, divisor >> 8); 4182 outb(iobase + com_cfcr, cfcr); 4183 4184 siocnopen(&sp, iobase, comdefaultrate); 4185 4186 splx(s); 4187 if (COM_CONSOLE(flags) && !COM_LLCONSOLE(flags)) { | 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); |
4189 cp->cn_pri = COM_FORCECONSOLE(flags) 4190 || boothowto & RB_SERIAL 4191 ? CN_REMOTE : CN_NORMAL; 4192 siocniobase = iobase; 4193 siocnunit = unit; 4194 } 4195 if (COM_DEBUGGER(flags)) { 4196 printf("sio%d: gdb debugging port\n", unit); 4197 siogdbiobase = iobase; 4198 siogdbunit = unit; 4199#if DDB > 0 | 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); |
4201 gdb_arg = &gdbconsdev; 4202 gdb_getc = siocngetc; 4203 gdb_putc = siocnputc; 4204#endif 4205 } 4206 } 4207 } 4208#ifdef __i386__ --- 5 unchanged lines hidden (view full) --- 4214 */ 4215 if (gdb_arg == NULL && (boothowto & RB_GDB)) { 4216 printf("Warning: no GDB port specified. Defaulting to sio%d.\n", 4217 siocnunit); 4218 printf("Set flag 0x80 on desired GDB port in your\n"); 4219 printf("configuration file (currently sio only).\n"); 4220 siogdbiobase = siocniobase; 4221 siogdbunit = siocnunit; | 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); |
4223 gdb_arg = &gdbconsdev; 4224 gdb_getc = siocngetc; 4225 gdb_putc = siocnputc; 4226 } 4227#endif 4228#endif 4229} 4230 4231static void 4232siocninit(cp) 4233 struct consdev *cp; 4234{ | 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; |
4236} 4237 4238static void 4239siocnterm(cp) 4240 struct consdev *cp; 4241{ 4242 comconsole = -1; 4243} --- 14 unchanged lines hidden (view full) --- 4258 u_int divisor; 4259 struct siocnstate sp; 4260 int unit = 0; /* XXX random value! */ 4261 4262 siocniobase = port; 4263 siocnunit = unit; 4264 comdefaultrate = speed; 4265 sio_consdev.cn_pri = CN_NORMAL; | 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); |
4267 4268 s = spltty(); 4269 4270 /* 4271 * Initialize the divisor latch. We can't rely on 4272 * siocnopen() to do this the first time, since it 4273 * avoids writing to the latch if the latch appears 4274 * to have the correct value. Also, if we didn't --- 27 unchanged lines hidden (view full) --- 4302 int unit = 1; /* XXX random value! */ 4303 4304 siogdbiobase = port; 4305 gdbdefaultrate = speed; 4306 4307 printf("sio%d: gdb debugging port\n", unit); 4308 siogdbunit = unit; 4309#if DDB > 0 | 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); |
4311 gdb_arg = &gdbconsdev; 4312 gdb_getc = siocngetc; 4313 gdb_putc = siocnputc; 4314#endif 4315 4316 s = spltty(); 4317 4318 /* --- 19 unchanged lines hidden (view full) --- 4338} 4339 4340#endif 4341 4342static int 4343siocncheckc(struct consdev *cd) 4344{ 4345 int c; | 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; | |
4347 Port_t iobase; 4348 int s; 4349 struct siocnstate sp; 4350 speed_t speed; 4351 | 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) { |
4354 iobase = siocniobase; 4355 speed = comdefaultrate; 4356 } else { 4357 iobase = siogdbiobase; 4358 speed = gdbdefaultrate; 4359 } 4360 s = spltty(); 4361 siocnopen(&sp, iobase, speed); 4362 if (inb(iobase + com_lsr) & LSR_RXRDY) 4363 c = inb(iobase + com_data); 4364 else 4365 c = -1; 4366 siocnclose(&sp, iobase); 4367 splx(s); 4368 return (c); 4369} 4370 | 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 | |
4372static int 4373siocngetc(struct consdev *cd) 4374{ 4375 int c; | 4381static int 4382siocngetc(struct consdev *cd) 4383{ 4384 int c; |
4376 dev_t dev; | |
4377 Port_t iobase; 4378 int s; 4379 struct siocnstate sp; 4380 speed_t speed; 4381 | 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) { |
4384 iobase = siocniobase; 4385 speed = comdefaultrate; 4386 } else { 4387 iobase = siogdbiobase; 4388 speed = gdbdefaultrate; 4389 } 4390 s = spltty(); 4391 siocnopen(&sp, iobase, speed); --- 5 unchanged lines hidden (view full) --- 4397 return (c); 4398} 4399 4400static void 4401siocnputc(struct consdev *cd, int c) 4402{ 4403 int need_unlock; 4404 int s; | 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; | |
4406 struct siocnstate sp; 4407 Port_t iobase; 4408 speed_t speed; 4409 | 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) { |
4412 iobase = siocniobase; 4413 speed = comdefaultrate; 4414 } else { 4415 iobase = siogdbiobase; 4416 speed = gdbdefaultrate; 4417 } 4418 s = spltty(); 4419 need_unlock = 0; --- 674 unchanged lines hidden --- | 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 --- |