Commit Graph

219 Commits

Author SHA1 Message Date
Poul-Henning Kamp
bf6a29da66 Fix compiler warnings. 1995-11-20 12:13:32 +00:00
Bruce Evans
4ff3de8e80 Added `#include "ioconf.h"' to <machine/conf.h> and cleaned up the
misplaced extern declarations (mostly prototypes of interrupt handlers)
that this exposed.  The prototypes should be moved back to the driver
sources when the functions are staticalized.

Added idempotency guards to <machine/conf.h>.  "ioconf.h" can't be
included when building LKMs so define a wart in bsd.kmod.mk to help
guard against including it.
1995-11-04 17:08:13 +00:00
Bruce Evans
4fda91c705 Moved prototypes for devswitch functions from conf.c and driver sources
to <machine/conf.h>.  conf.h was mechanically generated by
`grep ^d_ conf.c >conf.h'.  This accounts for part of its ugliness.  The
prototypes should be moved back to the driver sources when the functions
are staticalized.
1995-11-04 13:25:33 +00:00
Bruce Evans
f668386c04 sio.c:
Fix the tests for being a console by reverting to the ones that
were used before the the RB_SERIAL changes.  RB_SERIAL only needs
to be tested in one place.  The initialization of comconsole was
wrong before the RB_SERIAL changes for the COMCONSOLE case.  This
may have been the cause of the unnecessary changes.

Start eliminating #includes of <i386/i386/cons.h>.  This header is
supposed to be included from <machine> although it should be
completely machine-independent and included from <sys>.

Remove a wrong XXX comment.  `comconsole' is used to test for being
a console and even the tests for deciding the default termios state
are necessary (the semi-reentrant i/o routines don't handle ordinary
device i/o).

cy.c:
Sync with sio.c.  The console tests are present but always fail.
1995-10-22 15:38:08 +00:00
Poul-Henning Kamp
b59d7f4673 A mixed bag of changes, relating to getting the state in "lsdev" right,
and pccard support to work sensibly.  Better by far, but still not good.
1995-10-21 00:55:36 +00:00
David Greenman
b025187719 siostop() is a void function, so don't return a value. 1995-09-24 04:59:16 +00:00
Poul-Henning Kamp
ccdbc84cba The stuff needed to remove a pccard with a sio port on it...
Not optimal, but pretty solid.
1995-09-19 12:37:41 +00:00
Poul-Henning Kamp
0d2966d3f2 Andrew McRae's pcmcia/pccard code, the kernel part.
This is still very green, but I have managed to get my modem working.
Lots of work still to do, but now at least we can commit it. /phk

Reviewed by:	phk
Submitted by:	Andrew McRae <andrew@mega.com.au>
1995-08-24 08:56:20 +00:00
Bruce Evans
6097a1e94f Disable fifos in sioclose(). Closes PR 576. 1995-08-13 07:49:35 +00:00
Bruce Evans
1856afe955 Sleep on a better address to wait for output to drain out of the
hardware.  Set the sleep-on flag for the address so there is more
than a small chance that the sleep address is actually used (this
used to work by timing out).  Don't bother clearing the sleep-on
flag after a timeout here or elsewhere since leaving it set just
generates a few null calls to wakeup().
1995-07-31 21:10:36 +00:00
Bruce Evans
f3b37f91c1 Improve input flow control.
Use input buffer watermarks of TTYHOG-512 (high) and (high)*7/8
(low) instead of TTYHOG/2 (high) and TTYHOG/5 (low) to agree with
some drivers.  512 is magic and some things depended on TTYHOG/2
>= TTYHOG-512 to work; now they depend on the 512 magic not changing
and TTYHOG-512 being significantly larger than 0.  This should be
handled in ttsetwater().

Separate the decision about whether to do input flow control from
doing it.  ttyblock() now just starts input flow control (hardware
and/or software) and there is a new function ttyunblock() to stop
it.  The decisions are the same except for the watermark changes
and allowing for input expansion for PARMRK.

When flushing input, try harder at first to send a start character
if required, but give up if the first attempt fails.

cy.c, rc.c, sio.c:
Simplify: let ttyinput() handle input flow control if it is not
being bypassed.  Use ttyblock() to start flow control otherwise.

rc.c:
Use same input flow control test as elsewhere: test in a more
efficient order and start flow control at >= highwater instead of
at > highwater.
1995-07-31 18:29:51 +00:00
Bruce Evans
611c22c117 Don't let IXOFF or ECHONL stop the setting of TS_CAN_BYPASS_L_RINT. IXOFF
is handled at a low level, and ECHONL only applies if ICANON is set,
although tty.c sometimes bogusly applies it when ICANON isn't set.
1995-07-29 08:33:13 +00:00
Bruce Evans
4ce7d32178 Always wake up writers after clearing TS_BUSY. This will soon be
essential when I fix excessive wakeups for output-below-low-water.
In cy.c and sio.c, wake up via the driver start routine to also
eliminate duplicated code involving the clearing of TS_TTSTOP.

Always (except in code to be replaced soon) call driver start
routine directly instead of going through ttstart().
1995-07-29 04:05:57 +00:00
Bruce Evans
abe8bea470 Obtained from: partly from ancient patches of mine via 1.1.5
Give names to the magic tty i/o sleep addresses and use them.  This makes
it easier to remember what the addresses are for and to keep them unique.
1995-07-22 16:45:22 +00:00
Bruce Evans
a16721a13a Move the inline code for waking up writers to a new function
ttwwakeup().  The conditions for doing the wakeup will soon become
more complicated and I don't want them duplicated in all drivers.

It's probably not worth making ttwwakeup() a macro or an inline
function.  The cost of the function call is relatively small when
there is a process to wake up.  There is usually a process to wake
up for large writes and the system call overhead dwarfs the function
call overhead for small writes.
1995-07-22 01:30:45 +00:00
Bruce Evans
2ce42987d3 Obtained from: partly from ancient patches of mine via 1.1.5
Move static termioschars() from a couple of drivers to tty.c.  Now there
is only one copy of ttydefchars[].
1995-07-21 22:52:01 +00:00
Bruce Evans
aa96081f8b Fix error logging:
- get the timeout countdown right
- report everything before turning timeouts off.
1995-07-05 14:30:07 +00:00
Andrey A. Chernov
5575abefeb Fight with hanging modems continued:
return EIO after t_timeout expired instead infinite looping in "siotx"
in comparam, consuming CPU time.
1995-06-28 17:58:14 +00:00
Bruce Evans
33dc7e1b84 Reduce timeout frequency from `hz' to 0 if no ports are open or to 1 if
no ports are active, provided there are no polled ports and no
`LOSESOUTINTS' ports.  Do a little more in the interrupt handler instead.
This is a little less efficient if there are are many active ports but
a little more efficient otherwise.  Polled ports are ones with no irq
specified (as before).  `LOSESOUTINTS' ports are ones with 0x08 set in
their config flags.  Unless this flag is set, it will now take up to one
second to recover from lost output interrupts, if any.  Some 8250s and
16450s lose output interrupts.

Improve output buffering: copy the clist buffer to 2 linear buffers if
necessary and possible instead of to 1.  Handle an arbitrary queue of
buffers in the interrupt handler.  Check for waking up sleepers after
copying characters out of the clist buffer instead of before.

Delay translation of TIOCM_DTR to MCR_DTR etc. so that the top level
routines are more machine independent.

Fix bogus device register in unused code.
1995-06-25 04:51:01 +00:00
Rodney W. Grimes
9b2e535452 Remove trailing whitespace. 1995-05-30 08:16:23 +00:00
Rodney W. Grimes
b2b795f07c Fix -Wformat warnings from LINT kernel. 1995-05-11 19:26:53 +00:00
Andrey A. Chernov
e73e1e3715 Add hook for pstat -t 1995-05-07 23:00:02 +00:00
Bruce Evans
8d98ed564c Move declarations of console functions to cons.h (they should be
config(8)ed).

Update other misplaced prototypes.
1995-04-23 12:41:57 +00:00
Bruce Evans
33242876a4 Fix initializations of kdc_state for serial consoles.
Change order of RTS flow control tests so that less tests are required
in the usual case.

Clean up parts of previous commits.  Cosmetic.
1995-04-15 21:45:16 +00:00
Garrett Wollman
ae60406da6 Forgot two things in yesterday's massive devconf update:
initialized class for sio
don't bogusly re-initialize it in sio_registerdev()
1995-04-13 15:03:29 +00:00
Andrey A. Chernov
3cf91c530d Move setcompat code to another place, initial/locked devices
not supposed to work with old style ioctls
1995-04-13 11:11:11 +00:00
Andrey A. Chernov
d17ad80fda Comment out ttcompat via COMPAT_SUNOS too
Fix error handling initial/callout devices
1995-04-13 09:22:40 +00:00
Poul-Henning Kamp
04a6a5a9ac ttsetcompat is a '#ifdef COMPAT_43' feature.
Dropping into the debugger when a break comes down the serial line is a
>MISFEATURE (1st class)< and has been put under it's own #ifdef.  This
should be a magic sequence of chars instead.
1995-04-12 22:00:41 +00:00
Garrett Wollman
6c0081e92b Add a class field to devconf and mst drivers.
For those where it was easy, drivers were also fixed to call
dev_attach() during probe rather than attach (in keeping with the
new design articulated in a mail message five months ago).  For
a few that were really easy, correct state tracking was added as well.
The `fd' driver was fixed to correctly fill in the description.
The CPU identify code was fixed to attach a `cpu' device.  The code
was also massively reordered to fill in cpu_model with somethingremotely
resembling what identifycpu() prints out.  A few bytes saved by using
%b to format the features list rather than lots of ifs.
1995-04-12 20:48:13 +00:00
Andrey A. Chernov
2178b9bb49 Call new ttsetcompat() function for proper working
old v7 ioctls with locking bits.
1995-04-11 17:58:09 +00:00
Andrey A. Chernov
a65a3dd65a Move unit structure member down to optimize com->state per Bruce
suggestion. Move hotchar setting to set_bypass routine and rename it
to disc_optim
1995-04-04 16:26:04 +00:00
Andrey A. Chernov
021ad37586 Allow serial console BREAK to DDB
Use com->unit in several places
1995-04-03 10:29:14 +00:00
Andrey A. Chernov
bedbd95393 Back out changes related to locked bits until more elegant
solution will be found. Remove some unused variables sneaked in.
1995-04-02 19:28:58 +00:00
Andrey A. Chernov
890bf1b00d Fix error:
old type (stty) ioctls can easily bypass locking bits.
It involves manual conversion from old ioctls to new ones,
large piece of code duplicated from tty_compat.c
1995-04-02 04:21:09 +00:00
Andrey A. Chernov
5fba2bf3bd Move SET_BYPASS macro to function per Bruce suggestion.
Add set_bypass() call after l_close.
Move ttioctl()/set_bypass() pair under spltty() protection
1995-04-02 01:47:06 +00:00
Andrey A. Chernov
5daae55cdf Move setting BYPASS state to macro, use it in several times,
after ttioctl too, because it can change t_line.
Remove (TS_CNTTB | TS_LNCH) test, it is always inherits from
old tty mode and can't be reach in currently setted mode.
1995-04-01 23:56:08 +00:00
Andrey A. Chernov
6a5f6acc8d Adjust TS_CAN_BYPASS_L_RINT state after l_open(), t_line
can be changed there.
1995-04-01 22:57:43 +00:00
Andrey A. Chernov
c6e19ceaa0 Use new TS_CAN_BYPASS_L_RINT state to avoid complex test
each time.
Remove unefficient loop of zeroing error chars in siopoll(),
now done at interrupt level.
1995-04-01 12:01:13 +00:00
Andrey A. Chernov
3d0b7a8e9f Check for never opened or closed device before testing
terminal flags at interrupt level
1995-04-01 06:55:24 +00:00
Andrey A. Chernov
29a75ef5be Fix serial error recording using new TTY_BI & TTY_OE 1995-03-29 20:20:01 +00:00
Andrey A. Chernov
9bbcea9480 Remove TTY_OE & TTY_BI definitions to allow translation,
more work required and will follow
1995-03-29 19:05:13 +00:00
Andrey A. Chernov
0e933b8841 Move discard check up and do it only for error status
(per Bruce suggestion). It speedup things for a little.
Remove l_start optimization, call l_start always (per Bruce suggestion)
1995-03-28 19:22:11 +00:00
Andrey A. Chernov
4e0df42774 Don't use
if (tp->t_line != 0)
test when CS_ODONE, it fails for NTTYDISC, use
		       if (linesw[tp->t_line].l_start != ttstart)
instead.

Reviewed by:
Submitted by:
Obtained from:
CVS:
1995-03-28 12:26:40 +00:00
Andrey A. Chernov
8eefd80d06 Forget to add LSR_FE to discard (see prev commit)
Reviewed by:
Submitted by:
Obtained from:
CVS:
1995-03-28 11:13:44 +00:00
Andrey A. Chernov
2cad35d11b Several fixes to help "raw" tty mode work correctly with
BREAK/parity/framing errors.
Term "correctly" assumes POSIX spec. and 4.4 ttyinput() behaviour.
1) Discard BREAK/parity at interrupt level when apropriate IGN*
is set in iflag. It helps "raw" mode works even IGN* is set.
2) Zero parity (if INPCK) and framing directly in buffer
before passing it to b_to_q() in "raw" mode.
Efficency:
interrupt level: if no error occurse, only two "test" commands added
"raw" mode: buf scan incc times for parity/framing added

Reviewed by:
Submitted by:
Obtained from:
CVS:
1995-03-28 10:51:59 +00:00
Andrey A. Chernov
243823db69 Raw ttyinput test was incomplete,
add !(IGNBRK | BRKINT | PARMRK) now.
1995-03-28 06:15:44 +00:00
Andrey A. Chernov
339b90b333 Fix break recording for ttyinput 1995-03-28 05:39:53 +00:00
Bruce Evans
b5e8ce9f12 Add and move declarations to fix all of the warnings from `gcc -Wimplicit'
(except in netccitt, netiso and netns) and most of the warnings from
`gcc -Wnested-externs'.  Fix all the bugs found.  There were no serious
ones.
1995-03-16 18:17:34 +00:00
Andrey A. Chernov
5d8619d1f2 Workaround IXOFF bug when output queue is full && RTS control is on 1995-02-28 23:21:33 +00:00
Paul Traina
8c5c37cd75 Incorporate bde's code-review comments.
(a) bring back ttselect, now that we have xxxdevtotty() it isn't dangerous.
(b) remove all of the wrappers that have been replaced by ttselect
(c) fix formatting in syscons.c and definition in syscons.h
(d) add cxdevtotty

NOT DONE:
(e) make pcvt work... it was already broken...when someone fixes pcvt to
	link properly, just rename get_pccons to xxxdevtotty and we're done
1995-02-28 00:21:11 +00:00
Bruce Evans
eecd3071a6 Don't confuse the frequency with the wavelength in DELAY() args. 960 cps
is close to 1000000 / 960 usec so the confusion probably didn't matter.

Test for COMCONSOLE before testing for RB_SERIAL so that the RB_SERIAL
test can be optimized away if COMCONSOLE is 1.

Simplify and Uniformize style of previous commit.
1995-02-26 02:30:18 +00:00
Paul Traina
77f77631e7 (a) remove the pointer to each driver's tty structure array from cdevsw
(b) add a function callback vector to tty drivers that will return a pointer
    to a valid tty structure based upon a dev_t
(c) make syscons structures the same size whether or not APM is enabled so
    utilities don't crash if NAPM changes (and make the damn kernel compile!)
(d) rewrite /dev/snp ioctl interface so that it is device driver and i386
    independant
1995-02-25 20:09:44 +00:00
Andrey A. Chernov
838dadc476 Revive input flow control, some ideas from iverson@leonheart.com
Get rid of TS_RTS_IFLOW, all kinds of input flow control handled
by only one flag now: TS_TBLOCK
Add missing put(VSTOP) when IXOFF control is active.
1995-02-24 00:11:01 +00:00
Bill Paul
2b237b4058 Submitted by: Bill Paul (wpaul@ctr.columbia.edu)
Obtained from:
sio.c and sioreg.c changed to allow autodetecting the RB_SERIAL flag
passed by the boot blocks so that the kernel can switch to 'serial
console' mode automagically. 'options COMCONSOLE' can still be specified
to force the kernel to always use the serial port as a console.
CONUNIT and CONADDR can also be specified in the kernel config file
if the user wants to shift the console to a different port.
1995-01-20 07:34:18 +00:00
Bruce Evans
123bcf5fda Fix scaling for TIOCM[SG]DTRWAIT to work when hz != 100.
Bruce
1995-01-06 15:03:41 +00:00
Andrey A. Chernov
33c38bd574 Fight against hanging modems: add timeout to ttywait.
Reviewed by: Bruce
1995-01-05 00:01:07 +00:00
Bruce Evans
0c4fe20e8a Keep track of the devconf state. 1994-12-27 13:07:07 +00:00
Andrey A. Chernov
92915f5044 Change wakeup to endtsleep, because wakeup don't produce timeout
state, cause infinite wakeups loop in ttywait
1994-12-01 23:48:09 +00:00
Bruce Evans
2f31d30b01 Work around microtime() enabling interrupts. 1994-11-06 00:23:45 +00:00
Bruce Evans
25dd4b72b8 Only log errors every second (instead of every 5-10 msec) and check for
errors at a lower ipl.  clist starvation problems can cause hundreds of
tty buffer overflows per second and logging them all amplified the
problems.  This problem was less serious in 1.1.5.

Avoid a race in the check for starting a new block of output.  com_events
was sometimes messed up and siopoll() looped endlessly.  This bug was
introduced in 2.0.

Clean up previous 2 commits.  Rename sio_registerdev() to sioregisterdev()
to match the (bad) surrounding naming conventions.  There should be a
generic_registerdev().
1994-11-01 23:09:29 +00:00
Garrett Wollman
2f86936a07 Finished device configuration database work for all ISA devices (except `ze')
and all SCSI devices (except that it's not done quite the way I want).  New
information added includes:

-	A text description of the device
-	A ``state''---unknown, unconfigured, idle, or busy
-	A generic parent device (with support in the m.i. code)
-	An interrupt mask type field (which will hopefully go away) so that
.	  ``doconfig'' can be written

This requires a new version of the `lsdev' program as well (next commit).
1994-10-23 21:28:03 +00:00
Poul-Henning Kamp
74fbff447d A missing bit from Peter Dufaults patches, as best I could guess... 1994-10-20 00:45:36 +00:00
Bruce Evans
633295cda7 Clean up previous commit. 1994-10-19 21:38:19 +00:00
Andrey A. Chernov
22171b7a33 Prevent modem hanging forever on close with CTS off:
use 1min timeout to wakeup ttywait
1994-10-15 18:05:25 +00:00
Bruce Evans
b2f6e97280 Work around FIFO bug in SMC UARTS.
Fix endless loop in siopoll() for an event on a tty with no tty struct.
Don't generate unwanted interrupts in the serial console driver.  These
bugs probably don't matter unless the tty struct is dynamically allocated.

Support polled mode.  To use it, leave out the irq and the vector in
the config file.  It only causes extra overhead for open polled ports.
The maximum usable speed is approximately 1000 bps for a 16450 and
15000 bps for a 16550.

Other cosmetic changes.
1994-10-12 19:49:11 +00:00
David Greenman
36317691a4 #if 0'd evil dynamic fifo trigger level adjustment; it just bit me and
a couple of other people again.
1994-09-21 19:39:25 +00:00
Poul-Henning Kamp
5b7ffe398f Digicom Systems Inc, makes "softmodems". What this means is simply that
you download the microcode to the DSP everytime you power on your system.
They provide a dos-program to do so, but no other support.  This commit adds
code to the sio-driver, which implement an ioctl, which will down-load the
micro-code.

To get this functionality, you must define DSI_SOFT_MODEM.

The program to actually employ the ioctl is not included, but the entire
source looks like this:

        #include <sys/ioctl.h>
        #include <stdio.h>

        main()
        {
                unsigned char buffer[100000];
                int i;

                read(0,buffer,100000);
                if((i = ioctl(1,TIOCDSIMICROCODE,buffer)) < 0)
                    perror("ioctl");
                return i;
        }

And you use it like this:
	smload < data144b.dsi > /dev/ttyid3

You need to copy the *.DSI files from the dos-media provide with your modem.
You can see what is downloaded by issuing the ATI3 command to the modem.
DSI's scheme for what code you can run on your modem isn't violated by this.

Poul-Henning Kamp
phk@freefall.cdrom.com
1994-09-13 03:30:31 +00:00
Bruce Evans
3e0a35fee4 Updated to final 1.1.5 version (revision 1.56).
Merged changes from 2.0 version (revisions 1.46-1.50) by hand.

Finished conversion to clists: removed flush of tty output buffer
in comflush() (most writes were truncated to 256 bytes) and restored
bypass of ttyinput() in siopoll().

Finished conversion to 2.0 types - more void *'s, less caddr_t's,
less casts, no Dev_t's.

Only these things are seriously broken now compared with 1.1.5:
waiting for output complete is impossible so ttywait() can deadlock;
sioclose() isn't called enough so sioopen() sometimes returns EBUSY
unnecessarily; input flow control is not implemented.
1994-08-25 10:15:28 +00:00
Paul Richards
d091793974 Ran ft.c through ident.
Added a missing #ifdef INET wrapper in lpt.c

Main change:
	Removed the timeout_func_t casts from timeout calls and
	correctly defined the timeout routines to conform to
	the new format.
lpt.c doesn't have this change.

Reviewed by:
Submitted by:
1994-08-23 07:52:29 +00:00
David Greenman
8912c0ed61 Bruce Evans' dynamic interrupt support.
/usr/src/sys/i386/isa/clock.c:
	o Garrett's statclock changes.
	o Wire xxxintr, not Vclk.
	o Wire using register_intr(), not setidt().

/usr/src/sys/i386/isa/icu.s:
	o Garrett's statclock changes.
	o Removed unused variable high_imask.
	o Fake int 8 for rtc as well as int 0 for clk.  Required for kernel
	  profiling with statclock, harmless otherwise.

/usr/src/sys/i386/isa/isa.c:
	o Allow isdp->id_irq and other things in *isdp to be changed by
	  probes.  Changing interrupts later requires direct calls to
	  register_intr() and unregister_intr() and more care.
	  ALLOW_CONFLICT_* is brought over from 1.1.5, except
	  ALLOW_CONFLICT_IRQ is not supported.  IRQ conflict checking is
	  delayed until after probing so that drivers can change the IRQ
	  to a free one; real conflicts require more cooperation between
	  drivers to handle.
	o Too many details to list.
	o This file requires splitting and a lot more work.

/usr/src/sys/i386/isa/isa_device.h:
	o Declare more things more completely.

/usr/src/sys/i386/isa/sio.c:
	o Prepare to register interrupt handlers as fast.

/usr/src/sys/i386/isa/vector.s:
	o Generate entry code for 16 fast interrupt handlers and 16 normal
	  interrupt handlers.  Changed some constants to variables:
	  # $unit is now intr_unit[intr].  Type is int.  Someday it should
	    be a cookie suitable for the handler (e.g., a struct com_s for
	    sio).
	  # $handler is now intr_handler[intr].
	  # intrcnt_actv[id_num] is now *intr_countp[intr].  The indirection
	    is required to get a contiguous range of counters for vmstat
	    and so that the drivers depend more in the driver than on the
	    interrupt number (drivers could take turns using an interrupt
	    and the counts would remain correct).  There is a separate
	    counter for each device and for each stray interrupt.  In
	    1.1.5, stray interrupt 7 clobbers the count for device 7 or
	    something worse if there is no device 7 :-(.
	  # mask is now intr_mask[intr] (was already indirect).
	 o Entry points are now _XintrI and _XfastintrI (I = intr = 0-15),
	   not _VdevU (U = unit).
	 o Removed BUILD_VECTORS stuff.  There's a trace of it left for
	   the string table for vmstat but config now generates the
	   string in one piece because nothing more is required.
	 o Removed old handling of stray interrupts and older comments
	   about it.

Submitted by:	 Bruce Evans
1994-08-18 05:09:36 +00:00
Garrett Wollman
f540b1065a Change all #includes to follow the current Berkeley style. Some of these
``changes'' are actually not changes at all, but CVS sometimes has trouble
telling the difference.

This also includes support for second-directory compiles.  This is not
quite complete yet, as `config' doesn't yet do the right thing.  You can
still make it work trivially, however, by doing the following:

rm /sys/compile
mkdir /usr/obj/sys/compile
ln -s M-. /sys/compile
cd /sys/i386/conf
config MYKERNEL
cd ../../compile/MYKERNEL
ln -s /sys @
rm machine
ln -s @/i386/include machine
make depend
make
1994-08-13 03:50:34 +00:00
Rodney W. Grimes
35c2e6db96 Since we have removed com.c and renamed comreg.h to sioreg.h I need to
fix sio.c to #include sioreg.h.
1994-05-26 13:31:40 +00:00
Rodney W. Grimes
26f9a76710 The big 4.4BSD Lite to FreeBSD 2.0.0 (Development) patch.
Reviewed by:	Rodney W. Grimes
Submitted by:	John Dyson and David Greenman
1994-05-25 09:21:21 +00:00
David Greenman
f66fdd6803 Added support for the 16 port Boca via a flag to specify that there is
no master port.
1994-04-23 02:11:43 +00:00
Andrey A. Chernov
9cc0e7b511 Add declaration missing from previous bde's version 1994-04-03 12:25:57 +00:00
Andrey A. Chernov
fd59ff8180 CHANGES from Bruce:
---
This list of changes is in approximately chronological order (oldest first).

	o Many cosmetic changes - renamed comintr1 -> siointr1, moved
	  things around and fixed whitespace.
	o Reduced SLIP latency (FRAME_END hack) from 20-30 ms to 16 ms
	  at 115200 bps (you won't notice the average 10 ms improvement
	  on slow lines).  ppp seems to use only counted transfers so
	  there's no similar hack available.  It's too hard for the
	  driver to know the count.
	o Temporary #ifdefs for new and old interrupt handling
	  (OLD_INTERRUPT_HANDLING decided by setsofttty() not being
	  externally defined.
	o Don't test for the IIR_NOPEND bit being set - test for the
	  non-fifo part of the iir equalling it like the docs say to.
	  States with other IIR_NOPEND set in combination with the
	  other iir bits are undefined.  The docs may be stupid - the
	  old test would not have broken when the fifo bits were
	  introduced.
	o Noted more problems with DTR wait.
	o Rewrote console stuff.  Still some initialization and state
	  preservation problems.  Same for kgdb stuff.  The driver
	  doesn't do anything about the console close bug.  It needs
	  to be fixed entirely in i386/cons.c.  I like chmr's version
	  where the the console driver revectors the device open and
	  close routines.
	o Temporary (?) #ifdefs for references to tty buffers.
	o Noted further things to do in (2 comments about 3 places) for
	  phk's change to not touch RTS unless it is being used for flow
	  control.
	o Temporary #ifdefs for timestamp handling.  It needs fixing.
	  The microtime() call breaks the first rule of writing fast
	  interrupt handlers: NO calls to functions that might do slow
	  and bad things.  microtime() enables interrupts.  This turns
	  out to be only moderately harmful.  Also, I want the timestamp
	  copy outside of the normal interrupt handler.
	o Don't init com->tp early for the !DONT_MALLOC_TTYS case -
	  both sides are NULL.
	o Worry about com->tp == NULL in siopoll.  I don't see how you
	  survived the (incc <= 0 || !(tp->state & TS_ISOPEN)) test.
	  Perhaps early sttys or comcontrols set up the tp's for _all_
	  the ports before this code is reached.
1994-04-03 11:41:11 +00:00
David Greenman
d230622648 New interrupt code from Bruce Evans. In additional to Bruce's attached
list of changes, I've made the following additional changes:

1) i386/include/ipl.h renamed to spl.h as the name conflicts with the
   file of the same name in i386/isa/ipl.h.
2) changed all use of *mask (i.e. netmask, biomask, ttymask, etc) to
   *_imask (net_imask, etc).
3) changed vestige of splnet use in if_is to splimp.
4) got rid of "impmask" completely (Bruce had gotten rid of netmask),
   and are now using net_imask instead.
5) dozens of minor cruft to glue in Bruce's changes.

   These require changes I made to config(8) as well, and thus it must
be rebuilt.

-DG

from Bruce Evans:

sio:
	o No diff is supplied.  Remove the define of setsofttty().  I hope
	  that is enough.

*.s:
	o i386/isa/debug.h no longer exists.  The event counters became too
	  much trouble to maintain.  All function call entry and exception
	  entry counters can be recovered by using profiling kernel (the new
	  profiling supports all entry points; however, it is too slow to
	  leave enabled all the time; it also).  Only BDBTRAP() from debug.h
	  is now used.  That is moved to exception.s.  It might be worth
	  preserving SHOW_BITS() and calling it from _mcount() (if enabled).
	o T_ASTFLT is now only set just before calling trap().
	o All exception handlers set SWI_AST_MASK in cpl as soon as possible
	  after entry and arrange for _doreti to restore it atomically with
	  exiting.  It is not possible to set it atomically with entering
	  the kernel, so it must be checked against the user mode bits in
	  the trap frame before committing to using it.  There is no place
	  to store the old value of cpl for syscalls or traps, so there are
	  some complications restoring it.

Profiling stuff (mostly in *.s):
	o Changes to kern/subr_mcount.c, gcc and gprof are not supplied yet.
	o All interesting labels `foo' are renamed `_foo' and all
	  uninteresting labels `_bar' are renamed `bar'.  A small change
	  to gprof allows ignoring labels not starting with underscores.
	o MCOUNT_LABEL() is to provide names for counters for times spent
	  in exception handlers.
	o FAKE_MCOUNT() is a version of MCOUNT() suitable for exception
	  handlers.  Its arg is the pc where the exception occurred.  The
	  new mcount() pretends that this was a call from that pc to a
	  suitable MCOUNT_LABEL().
	o MEXITCOUNT is to turn off any timer started by MCOUNT().

/usr/src/sys/i386/i386/exception.s:
	o The non-BDB BPTTRAP() macros were doing a sti even when interrupts
	  were disabled when the trap occurred.  The sti (fixed) sti is
	  actually a no-op unless you have my changes to machdep.c that make
	  the debugger trap gates interrupt gates, but fixing that would
	  make the ifdefs messier.  ddb seems to be unharmed by both
	  interrupts always disabled and always enabled (I had the branch in
	  the fix back to front for some time :-().
	o There is no known pushal bug.
	o tf_err can be left as garbage for syscalls.

/usr/src/sys/i386/i386/locore.s:
	o Fix and update BDE_DEBUGGER support.
	o ENTRY(btext) before initialization was dangerous.
	o Warm boot shot was longer than intended.

/usr/src/sys/i386/i386/machdep.c:
	o DON'T APPLY ALL OF THIS DIFF.  It's what I'm using, but may require
	  other changes.
	  Use the following:
		o Remove aston() and setsoftclock().
	  Maybe use the following:
		o No netisr.h.
		o Spelling fix.
		o Delay to read the Rebooting message.
		o Fix for vm system unmapping a reduced area of memory
		  after bounds_check_with_label() reduces the size of
		  a physical i/o for a partition boundary.  A similar
		  fix is required in kern_physio.c.
		o Correct use of __CONCAT.  It never worked here for non-
		  ANSI cpp's.  Is it time to drop support for non-ANSI?
		o gdt_segs init.  0xffffffffUL is bogus because ssd_limit
		  is not 32 bits.  The replacement may have the same
		  value :-), but is more natural.
		o physmem was one page too low.  Confusing variable names.
	  Don't use the following:
		o Better numbers of buffers.  Each 8K page requires up to
		  16 buffer headers.  On my system, this results in 5576
		  buffers containing [up to] 2854912 bytes of memory.
		  The usual allocation of about 384 buffers only holds
		  192K of disk if you use it on an fs with a block size
		  of 512.
		o gdt changes for bdb.
		o *TGT -> *IDT changes for bdb.
		o #ifdefed changes for bdb.

/usr/src/sys/i386/i386/microtime.s:
	o Use the correct asm macros.  I think asm.h was copied from Mach
	  just for microtime and isn't used now.  It certainly doesn't
	  belong in <sys>.  Various macros are also duplicated in
	  sys/i386/boot.h and libc/i386/*.h.
	o Don't switch to and from the IRR; it is guaranteed to be selected
	  (default after ICU init and explicitly selected in isa.c too, and
	  never changed until the old microtime clobbered it).

/usr/src/sys/i386/i386/support.s:
	o Non-essential changes (none related to spls or profiling).
	o Removed slow loads of %gs again.  The LDT support may require
	  not relying on %gs, but loading it is not the way to fix it!
	  Some places (copyin ...) forgot to load it.  Loading it clobbers
	  the user %gs.  trap() still loads it after certain types of
	  faults so that fuword() etc can rely on it without loading it
	  explicitly.  Exception handlers don't restore it.  If we want
	  to preserve the user %gs, then the fastest method is to not
	  touch it except for context switches.  Comparing with
	  VM_MAXUSER_ADDRESS and branching takes only 2 or 4 cycles on
	  a 486, while loading %gs takes 9 cycles and using it takes
	  another.
	o Fixed a signed branch to unsigned.

/usr/src/sys/i386/i386/swtch.s:
	o Move spl0() outside of idle loop.
	o Remove cli/sti from idle loop.  sw1 does a cli, and in the
	  unlikely event of an interrupt occurring and whichqs becoming
	  zero, sw1 will just jump back to _idle.
	o There's no spl0() function in asm any more, so use splz().
	o swtch() doesn't need to be superaligned, at least with the
	  new mcounting.
	o Fixed a signed branch to unsigned.
	o Removed astoff().

/usr/src/sys/i386/i386/trap.c:
	o The decentralized extern decls were inconsistent, of course.
	o Fixed typo MATH_EMULTATE in comments. */
	o Removed unused variables.
	o Old netmask is now impmask; print it instead.  Perhaps we
	  should print some of the new masks.
	o BTW, trap() should not print anything for normal debugger
	  traps.

/usr/src/sys/i386/include/asmacros.h:
	o DON'T APPLY ALL OF THIS DIFF.  Just use some of the null macros
	  as necessary.

/usr/src/sys/i386/include/cpu.h:
	o CLKF_BASEPRI() changes since cpl == SWI_AST_MASK is now normal
	  while the kernel is running.
	o Don't use var++ to set boolean variables.  It fails after a mere
	  4G times :-) and is slower than storing a constant on [3-4]86s.

/usr/src/sys/i386/include/cpufunc.h:
	o DON'T APPLY ALL OF THIS DIFF.  You need mainly the include of
	  <machine/ipl.h>.  Unfortunately, <machine/ipl.h> is needed by
	  almost everything for the inlines.

/usr/src/sys/i386/include/ipl.h:
	o New file.  Defines spl inlines and SWI macros and declares most
	  variables related to hard and soft interrupt masks.

/usr/src/sys/i386/isa/icu.h:
	o Moved definitions to <machine/ipl.h>

/usr/src/sys/i386/isa/icu.s:
	o Software interrupts (SWIs) and delayed hardware interrupts (HWIs)
	  are now handled uniformally, and dispatching them from splx() is
	  more like dispatching them from _doreti.  The dispatcher is
	  essentially *(handler[ffs(ipending & ~cpl)]().
	o More care (not quite enough) is taken to avoid unbounded nesting
	  of interrupts.
	o The interface to softclock() is changed so that a trap frame is
	  not required.
	o Fast interrupt handlers are now handled more uniformally.
	  Configuration is still too early (new handlers would require
	  bits in <machine/ipl.h> and functions to vector.s).
	o splnnn() and splx() are no longer here; they are inline functions
	  (could be macros for other compilers).  splz() is the nontrivial
	  part of the old splx().

/usr/src/sys/i386/isa/ipl.h
	o New file.  Supposed to have only bus-dependent stuff.  Perhaps
	  the h/w masks should be declared here.

/usr/src/sys/i386/isa/isa.c:
	o DON'T APPLY ALL OF THIS DIFF.  You need only things involving
	  *mask and *MASK and comments about them.  netmask is now a pure
	  software mask.  It works like the softclock mask.

/usr/src/sys/i386/isa/vector.s:
	o Reorganize AUTO_EOI* macros.
	o Option FAST_INTR_HANDLER_USERS_ES for people who don't trust
	  fastintr handlers.
	o fastintr handlers need to metamorphose into ordinary interrupt
	  handlers if their SWI bit has become set.  Previously, sio had
	  unintended latency for handling output completions and input
	  of SLIP framing characters because this was not done.

/usr/src/sys/net/netisr.h:
	o The machine-dependent stuff is now imported from <machine/ipl.h>.

/usr/src/sys/sys/systm.h
	o DON'T APPLY ALL OF THIS DIFF.  You need mainly the different
	  splx() prototype.  The spl*() prototypes are duplicated as
	  inlines in <machine/ipl.h> but they need to be duplicated here
	  in case there are no inlines.  I sent systm.h and cpufunc.h
	  to Garrett.  We agree that spl0 should be replaced by splnone
	  and not the other way around like I've done.

/usr/src/sys/kern/kern_clock.c
	o splsoftclock() now lowers cpl so the direct call to softclock()
	  works as intended.
	o softclock() interface changed to avoid passing the whole frame
	  (some machines may need another change for profile_tick()).
	o profiling renamed _profiling to avoid ANSI namespace pollution.
	  (I had to improve the mcount() interface and may as well fix it.)
	  The GUPROF variant doesn't actually reference profiling here,
	  but the 'U' in GUPROF should mean to select the microtimer
	  mcount() and not change the interface.
1994-04-02 07:00:53 +00:00
Andrey A. Chernov
e330356ffb Change got_status/modem_status assignment per Bruce suggestion,
because inb clears modem status port.
1994-04-01 16:47:01 +00:00
Andrey A. Chernov
827f6dbf32 1) Better fix for false carrier detect on bidir port
2) ttyclose moved after comhardclose, because clears t_state
3) slpx(s) moved after l_open to prevent undetected carrier down
1994-03-26 13:40:18 +00:00
Andrey A. Chernov
70c0dd79d8 Fix false carrier detection on incoming bidir port. 1994-03-25 15:10:50 +00:00
Andrey A. Chernov
83bd7ca8b0 1) Change dtrwait 300 to 3 * hz (to be more kosher)
2) Protect sioclose by spltty()
1994-03-23 17:28:35 +00:00
Andrey A. Chernov
7116e6b71c Add siostop to sioclose, because ttyflush called from
wrong places removed now.
1994-03-21 22:19:56 +00:00
Andrey A. Chernov
67a850fc67 Increase default DTR wait time up to 3 secs.
Also hardw. specs says 2.5 secs is enough, many modems needs
at least 3 secs.
1994-03-21 15:18:27 +00:00
Andrey A. Chernov
65f120b86a Remove ttyfree from sioclose
Example:
Application use port cua01
Getty open ttyd1 (allocates rawq,outq,etc) and waits while application
done
Application quits, sioclose issued, ttyfree issued (getty calls revoke)
Getty awakes and goes to panic into initrb (NULL rawq)
1994-03-18 23:35:37 +00:00
Andrey A. Chernov
05e5086aab Checking l_close in unneeded (one of my previous fixes),
so back it out.
1994-03-14 18:52:14 +00:00
Andrey A. Chernov
2109bd5c86 Don't call ttyclose twice into sioclose and move ttyclose
before comhardclose
1994-03-10 10:06:27 +00:00
Andrey A. Chernov
3b2b53aa9a First open:
now HUPCL set only in bidir case for callin lines
(this prevents set HUPCL on mouse)
comhardclose:
in addition to HUPCL case now DTR dropped for bidir case
if line was active in and no carrier present now.
(this prevents DTR sleep on mouse)
1994-03-08 22:11:10 +00:00
Guido van Rooij
79bdab6c87 Ttys structures are now allocated dynamically via ttymalloc/ttyfree.
This inetrface should be used from now on.
pseudo device pty xx still keeps its meaning: a maximum of
xx ptys is allowed.
A ringbuffer is now 2040 bytes long, per Garrett Wollman's request.
The changes are inspired by the way NetBSD did it (thanks for that!),
though I made it slihghtly different, including the interface so
at least 75% of the allocated space is deallocated when the tty is
closed.
Note further that it is easy to modify the ringbuffer length runtime.
This will have to wait untill some later date...


-Guido
1994-03-02 20:28:38 +00:00
Poul-Henning Kamp
bfbc1f09d4 RTS shouldn't be touched unless CS_RTS_IFLOW is set. 1994-02-26 00:04:03 +00:00
Poul-Henning Kamp
e3757377ff TIOCTIMESTAMP capability. The port in question must be configured with
"vector siointrts".  Thus only a compare is added for the other ports.
1994-02-24 16:39:48 +00:00
Andrey A. Chernov
63ba5191a4 Change all siointr (expect in Vsio, of course) to comintr1
This saves two commands per each direct comintr1 call,
allows some strict check in siointr and also
fix bug with suspended output on multiport cards
1994-02-07 18:37:21 +00:00
Andrey A. Chernov
4eab82a59a 1) Proper fix for suspended output in multiport case
2) IIR_NOPEND is really *one* bit, we don't need to check whole MASK
1994-02-06 11:59:35 +00:00
Andrey A. Chernov
04af1a4e41 Fix error in multiport part:
while input char not entered, output was suspended
1994-02-02 16:41:26 +00:00
Andrey A. Chernov
6405a87b09 Remove CALLOUTMASK, if non-bidir case. 1994-01-31 19:07:59 +00:00
Andrey A. Chernov
6df720041a 1) Set ipending back to 4, because (16 + 4) bit not in
netmask or impmask.

2) Fixes from Bruce:
	o Changed name of schedsoftcom() to setsofttty() to match
	  setsoftclock()
	o Bool_t isn't used.
	o tx_fifo_size is 1 for chips without fifos, 16 for 16550's, to
	  help to output more efficiently for 16550's (LSR_TXRDY means
	  that the fifo is empty, not that it has space for one char).
	o Changed name of softsio1() to siopoll() and merged compoll()
	  into siopoll().
	o The probe forgot to clear com_mcr after it failed.  This is
	  harmful for 4 single serial ports on 2 interrupts.  It makes
	  partial misconfigurations worse.
	o Don't bother initializing static variables that are 0 (bidir
	  stuff).
	o Only initialize t_oflag to TTYDEF_OFLAG if unit == COMCONSOLE,
	  not if COMCONSOLE is defined.
	o Don't call siointr() from comparam() if there is no output in
	  progress.  For the call from sioopen(), there's no output in
	  progress, and siointr() often saw silo overflows for stale
	  input because it was called before sioopen() discarded the
	  input.
	o Let ttselect() do the work for select(), so that the fixes for
	  ttselect() don't have to be duplicated in zillions of drivers.
1994-01-31 08:52:12 +00:00
David Greenman
d6eb591433 Patch from Brian Smith (modified a little by me) to allow kernel config
file override to disable fifo on 16550s:

I bought a board with two 16550's, but one of those ports has a mouse
on it.  The sio driver always enables the fifo, which is a bad thing
for mice and X.  The mouse is jerky and hard to use.  The simple thing
is be to treat one of the ports as a non-fifo'ed UART, and I use the
flags option in my config file.

So, my config file has:
device      sio0    at isa? port "IO_COM1" tty irq 4 flags 0x2 vector siointr
device      sio1    at isa? port "IO_COM2" tty irq 3 vector siointr

(patch deleted)
1994-01-31 06:12:18 +00:00
Andrey A. Chernov
e58072bda5 From ache:
Choose older MULTIPORT version, because lastest bde version
	not worked.
	Don't force HUPCL for bidirectional case.
From bde:
	Use bit (1 << (16 + 4)) in schedsoftcom() to avoid clash with
	non-serial h/w on IRQ4.
	Allow FIFO_TRIGGER in config.
	Clear com->mcr_image when clearing mcr for init of 4port.  The
	usual value MCR_IENABLE should have broken 4ports unless
	something happened to clear it later.
	Turn off interrupts as well as DTR after an error waiting for
	carrier (bidir dialin case).
	Drain fifo more carefully.
	Don't hang up if debugging.
	Rearrange siointr() -> siointr1() for multiport case for speed,
	lower latency and clarity.
	Use suser() to check perms.
	Provide missing splx() after failed perms checks.
	c_ispeed == 0 means c_ispeed = c_ospeed (POSIX).
	Set parameters (except speed) for c_ospeed == 0 as well as
	hanging up.
	Better initialization for console (fifo stuff...).
	Misc. cleanups.
	Fix dead hang if modem power is off.
1994-01-11 18:31:45 +00:00
Andrey A. Chernov
879d1ff90a Temporary plug CLOCAL security hole, while sticky bits
yet not implemented. Only for bidirectional case.
1994-01-02 10:17:29 +00:00
Andrey A. Chernov
cf197426bb Change default dtrwait value to 2 seconds.
Change C-style into static initializer per Bruce request.
1993-12-16 04:38:27 +00:00
David Greenman
d39cf18213 set output flags to ttydefault if COMCONSOLE is defined. 1993-12-13 13:20:50 +00:00
Andrey A. Chernov
04201cd182 Force HUPCL in bidirectional port open.
This don't allow it hangs forever.
1993-12-11 00:36:14 +00:00
Andrey A. Chernov
25915e75e3 1) Fix error with port recognition, speed initialization code
added to probe.
2) Force CLOCAL=on for outgoing ports and CLOCAL=off for
incoming ports into open in bidirectional case.
3) Add DELAY after writing to com_ier for fifo drain into probe.
1993-12-09 17:24:19 +00:00
Garrett Wollman
381fe1aaf4 Make the LINT kernel compile with -W -Wreturn-type -Wcomment -Werror, and
add same (sans -Werror) to Makefile for future compilations.
1993-11-25 01:38:01 +00:00
Andrey A. Chernov
aa0028f8cf Fix attach message, make separate line for it
(old version assumed that line is probe line)
1993-11-17 23:38:23 +00:00
Andrey A. Chernov
0d04ba084f New sio driver from Bruce. 1993-11-14 23:29:01 +00:00
Andrey A. Chernov
fe04cbf968 Add missing read flush code to siostop 1993-11-08 19:36:32 +00:00
Rodney W. Grimes
dd05fde699 Removed all patch kit headers, sccsid and rcsid strings, put $Id$ in, some
minor cleanup.  Added $Id$ to files that did not have any version info, etc
1993-10-16 19:17:18 +00:00
Rodney W. Grimes
6f78ca6026 Removed all patch kit headers, sccsid and rcsid strings, put $Id$ in, some
minor cleanup.  Added $Id$ to files that did not have any version info, etc
1993-10-16 13:48:52 +00:00
David Greenman
cc44412791 Disassociate DTR and RTS. They were coupled together and shouldn't have
been. This was necessary to work around problems with some equipment
that don't respond favorably to having these both dropped simultaneously.
1993-10-14 09:13:54 +00:00
David Greenman
357eebce38 incorporated patches from Marc Frajola (marc@escargot.rain.com) to
unset TS_TBLOCK when the RBLEN falls below the low water mark.
1993-10-12 06:32:28 +00:00
Jordan K. Hubbard
fae56ff15f Change to sio for recognising the last serial port on a multiport
card correctly.

Updated syscons to 0.2e, added features for upcoming XFree86 2.0,
fixed crashbug.
1993-09-28 00:01:18 +00:00
Rodney W. Grimes
e793dbb026 From guido@gvr.win.tue.nl Wed Sep 8 13:34:16 1993
That is because TIOCMGET was broken. Yes...this is known for some time
and no, we (Bruce and me) never posted it. Why? Simply because we choose
to post fixes when we fixed most of the bugs.

Anyway..now that the slip problems are coming, here is a fix for
correct TIOCMGET behaviour.

-Guido
Note: this should be tested first (Rich?).  Tested by rgrimes
1993-09-10 16:59:16 +00:00
Rodney W. Grimes
bfdbfb98fd From michaele@vice.ico.tek.com Wed Sep 8 09:50:45 1993
Subject: Re: Some small errors in GAMMA
4.      Move printf("\n"); at line 491 in "/sys/i386/isa/sio.c" to after
        COM_MULTIPORT block at line 512.
From rgrimes:
The above would cause the word (multiport) with out a new line to
appear after the uart type message if you had COM_MULTIPORT enabled.
1993-09-08 17:38:05 +00:00
Rodney W. Grimes
89bc97311a xxxprobe now returns the correct number of I/O registers used so that
the probe output during boot gives the I/O range instead of just the
starting address
1993-08-28 03:02:52 +00:00
Jordan K. Hubbard
ba52f64934 Applied Andrew's patch to fix loop-on-logout problem. 1993-07-20 02:06:49 +00:00
Jordan K. Hubbard
bb5d729efe Removed check for interrupting board before interrupts were enabled.
This should result in more AST clones getting seen.
1993-07-20 00:22:30 +00:00
Rodney W. Grimes
7ea04e18b1 Fixed sccs id to be From:\n com.c xxxx. The sccs id was changed by the
patch kit and it should not have been.
1993-07-18 21:27:57 +00:00
David Greenman
2a6c898016 Modified attach printf's so that the output is compatible with the "new"
way of doing things. There still remain several drivers that need to
be updated.  Also added a compile-time option to pccons to switch the
control and caps-lock keys (REVERSE_CAPS_CTRL) - added for my personal
sanity.
1993-07-15 17:53:14 +00:00
Rodney W. Grimes
5b81b6b301 Initial import, 0.1 + pk 0.2.4-B1 1993-06-12 14:58:17 +00:00