Commit Graph

112 Commits

Author SHA1 Message Date
Mark Murray
d888fc4e73 RIP <machine/lock.h>.
Some things needed bits of <i386/include/lock.h> - cy.c now has its
own (only) copy of the COM_(UN)LOCK() macros, and IMASK_(UN)LOCK()
has been moved to <i386/include/apic.h> (AKA <machine/apic.h>).
Reviewed by:	jhb
2001-02-11 10:44:09 +00:00
John Baldwin
16d92c70f1 Revert the spin mutex for the cy(4) driver.
Requested by:	bde
2001-02-09 22:37:24 +00:00
John Baldwin
6221adac84 - Use a spin mutex instead of COM_LOCK, since COM_LOCK is going away.
The same name from the sio(4) driver was used and an appropriate
  dictionary item added at the top to reduce diffs.
- Catch up to the new swi API.
2001-02-09 17:55:32 +00:00
Bruce Evans
a89bda90b1 Added used include of <sys/mutex.h>. The SMP case was broken by
incompletely converting simplelocks to mutexes (COM_LOCK() is supposed
to hide the SMP locking internals, but it now depends on mutex interfaces
being visible).
2001-01-30 17:05:58 +00:00
David Malone
7cc0979fd6 Convert more malloc+bzero to malloc+M_ZERO.
Submitted by:	josh@zipperup.org
Submitted by:	Robert Drehmel <robd@gmx.net>
2000-12-08 21:51:06 +00:00
Poul-Henning Kamp
cf9fa8e725 Move suser() and suser_xxx() prototypes and a related #define from
<sys/proc.h> to <sys/systm.h>.

Correctly document the #includes needed in the manpage.

Add one now needed #include of <sys/systm.h>.
Remove the consequent 48 unused #includes of <sys/proc.h>.
2000-10-29 16:06:56 +00:00
John Baldwin
49e0078b0f - Catch up to new software interrupt code.
- Add a missing curly brace.

Noticed by:	phk
2000-10-25 21:13:42 +00:00
John Baldwin
8088699f79 - Overhaul the software interrupt code to use interrupt threads for each
type of software interrupt.  Roughly, what used to be a bit in spending
  now maps to a swi thread.  Each thread can have multiple handlers, just
  like a hardware interrupt thread.
- Instead of using a bitmask of pending interrupts, we schedule the specific
  software interrupt thread to run, so spending, NSWI, and the shandlers
  array are no longer needed.  We can now have an arbitrary number of
  software interrupt threads.  When you register a software interrupt
  thread via sinthand_add(), you get back a struct intrhand that you pass
  to sched_swi() when you wish to schedule your swi thread to run.
- Convert the name of 'struct intrec' to 'struct intrhand' as it is a bit
  more intuitive.  Also, prefix all the members of struct intrhand with
  'ih_'.
- Make swi_net() a MI function since there is now no point in it being
  MD.

Submitted by:	cp
2000-10-25 05:19:40 +00:00
Poul-Henning Kamp
db7e3af111 Remove unneeded #include <machine/clock.h> 2000-10-15 14:19:01 +00:00
Bruce Evans
00d8d16417 Don't depend on <machine/cpufunc.h> unnecessarily including <machine/lock.h>. 2000-10-12 16:15:24 +00:00
Bruce Evans
db8ec2a244 Use schedsofttty() again (SMPng casualty with intentionally wrong fix
in rev.1.101).

Made this file compile again after move of stuff from <machine.ipl.h>
to <sys/ipl.h>.
2000-10-08 14:37:39 +00:00
Poul-Henning Kamp
2404c3f99d Make LINT link.
cy driver is broken post SMPng.
2000-09-16 19:04:24 +00:00
Poul-Henning Kamp
3045b21279 Make LINT compile. 2000-09-16 18:48:11 +00:00
Jason Evans
0384fff8c5 Major update to the way synchronization is done in the kernel. Highlights
include:

* Mutual exclusion is used instead of spl*().  See mutex(9).  (Note: The
  alpha port is still in transition and currently uses both.)

* Per-CPU idle processes.

* Interrupts are run in their own separate kernel threads and can be
  preempted (i386 only).

Partially contributed by:	BSDi (BSD/OS)
Submissions by (at least):	cp, dfr, dillon, grog, jake, jhb, sheldonh
2000-09-07 01:33:02 +00:00
Peter Wemm
6a4c2576dc Mass update of isa drivers using compatability shims to use
COMPAT_ISA_DRIVER() so that we can get rid of the evil isa_compat.h table.
2000-05-28 13:40:48 +00:00
Peter Wemm
1816634e49 Clean up some more loose ends..
isa_device->id_ri_flags and RI_FAST were not implemented and did nothing.
The two drivers that were mistakenly thinking this was working were
cy.c and loran.c - these should be converted to newbus.
GC (garbage collect) isa_device->id_alive
GC userconfig.c references to isa_device->id_scsiid (!).
2000-01-23 11:50:43 +00:00
Poul-Henning Kamp
1ab305ef60 Introduce ttyread() and ttywrite() which do the canonical thing.
Use them in many tty drivers.

Reviewed by: julian, bde
1999-09-28 11:45:31 +00:00
Poul-Henning Kamp
d6a0e38a1b Remove five now unused fields from struct cdevsw. They should never
have been there in the first place.  A GENERIC kernel shrinks almost 1k.

Add a slightly different safetybelt under nostop for tty drivers.

Add some missing FreeBSD tags
1999-09-25 18:24:47 +00:00
Poul-Henning Kamp
ae8e1d08d7 This patch clears the way for removing a number of tty related
fields in struct cdevsw:

        d_stop          moved to struct tty.
        d_reset         already unused.
        d_devtotty      linkage now provided by dev_t->si_tty.

These fields will be removed from struct cdevsw together with
d_params and d_maxio Real Soon Now.

The changes in this patch consist of:

        initialize dev->si_tty in *_open()
        initialize tty->t_stop
        remove devtotty functions
        rename ttpoll to ttypoll
        a few adjustments to these changes in the generic code
        a bump of __FreeBSD_version
        add a couple of FreeBSD tags
1999-09-25 16:21:39 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Poul-Henning Kamp
9dcbe2404a Convert DEVFS hooks in (most) drivers to make_dev().
Diskslice/label code not yet handled.

Vinum, i4b, alpha, pc98 not dealt with (left to respective Maintainers)

Add the correct hook for devfs to kern_conf.c

The net result of this excercise is that a lot less files depends on DEVFS,
and devtoname() gets more sensible output in many cases.

A few drivers had minor additional cleanups performed relating to cdevsw
registration.

A few drivers don't register a cdevsw{} anymore, but only use make_dev().
1999-08-23 20:59:21 +00:00
Bruce Evans
216b6d2da0 Really fix cy-driver-related panics when SMP is configured. Rev.1.88 only
fixed half the problem.

Tested by:	Michael Scott Boers <mboers@datacompusa.com>
1999-06-04 18:13:25 +00:00
Poul-Henning Kamp
2447bec829 Simplify cdevsw registration.
The cdevsw_add() function now finds the major number(s) in the
struct cdevsw passed to it.  cdevsw_add_generic() is no longer
needed, cdevsw_add() does the same thing.

cdevsw_add() will print an message if the d_maj field looks bogus.

Remove nblkdev and nchrdev variables.  Most places they were used
bogusly.  Instead check a dev_t for validity by seeing if devsw()
or bdevsw() returns NULL.

Move bdevsw() and devsw() functions to kern/kern_conf.c

Bump __FreeBSD_version to 400006

This commit removes:
        72 bogus makedev() calls
        26 bogus SYSINIT functions

if_xe.c bogusly accessed cdevsw[], author/maintainer please fix.

I4b and vinum not changed.  Patches emailed to authors.  LINT
probably broken until they catch up.
1999-05-31 11:29:30 +00:00
Poul-Henning Kamp
4e2f199e0c This commit should be a extensive NO-OP:
Reformat and initialize correctly all "struct cdevsw".

        Initialize the d_maj and d_bmaj fields.

        The d_reset field was not removed, although it is never used.

I used a program to do most of this, so all the files now use the
same consistent format.  Please keep it that way.

Vinum and i4b not modified, patches emailed to respective authors.
1999-05-30 16:53:49 +00:00
Bruce Evans
4011dfccd2 Don't call disable_intr() when interrupts are already disabled, since
disable_intr() does non-recursive locking in the SMP case.  This should
fix cy-driver-related panics when SMP is configured.

Broken in:	rev.1.73 (3.1 and -current)
1999-05-28 13:23:21 +00:00
Poul-Henning Kamp
f711d546d2 Suser() simplification:
1:
  s/suser/suser_xxx/

2:
  Add new function: suser(struct proc *), prototyped in <sys/proc.h>.

3:
  s/suser_xxx(\([a-zA-Z0-9_]*\)->p_ucred, \&\1->p_acflag)/suser(\1)/

The remaining suser_xxx() calls will be scrutinized and dealt with
later.

There may be some unneeded #include <sys/cred.h>, but they are left
as an exercise for Bruce.

More changes to the suser() API will come along with the "jail" code.
1999-04-27 11:18:52 +00:00
Bruce Evans
89955e6330 YAMFsio.c (1.227-1.228: set up input buffering dynamically). 1999-02-04 15:54:02 +00:00
Poul-Henning Kamp
4e2d2aa1cd Use suser() to check for super user rather than examining cr_uid directly.
Use TTYDEF_SPEED rather than 9600 a couple of places.

Reviewed by:	bde, with a few grumbles.
1999-01-30 12:17:38 +00:00
Matthew Dillon
0a5e03dda5 Fix warnings in preparation for adding -Wall -Wcast-qual to the
kernel compile
1999-01-28 01:59:53 +00:00
Bruce Evans
2a32c15f45 Unspammed includes in <machine/cpufunc.h> in the !SMP case. Partially
unspammed them in the SMP case.
1999-01-08 19:17:49 +00:00
Bruce Evans
223f865ada Flush the fifos at the correct place in cyopen(). Various things
in cyopen() were done in a different order than in sioopen(), partly
to (ab)use a side effect of comparam() and partly because I didn't
understand what the reset was doing (it flushes the fifos).  This
turned out to be more than a cosmetic problem.  Flushing the fifos
quite late is good for discarding input that arrived while the line
state was being initialized, and in the cy driver it also seems to
reduce a problem with input that arrived long ago during the previous
close (the UART loses sync too easily and for too long).
1998-12-24 14:17:57 +00:00
Bruce Evans
3bc124d470 Wait for channel commands to complete after issuing the commands.
The optimisation of only waiting before issuing new commands is
obviously invalid in general and it caused many errors in NIST-PCTS.
I think the errors were mostly for characters sent with the wrong
parity, etc., after a half complete tcsetattr().

Use microtime() instead of a magic loop count to limit the wait.
The wait is a busy-wait :-( and normally takes about 500 usec.
1998-12-19 16:28:57 +00:00
Bruce Evans
747c608e8d Flush the tx fifo in cystop(). Now ttyflush() (and thus tcflush(3))
almost works properly.  Unfortunately, there is no way to flush
the rx fifo without resetting the channel, which also flushes the
tx fifo.  We avoid resetting even when both fifos need to be flushed,
since resetting seems to cause the rx to lose sync if it is done
while data is arriving.

Reminded by:	NIST-PCTS
1998-12-17 19:23:09 +00:00
Bruce Evans
f9828cced4 Fixed handling of BREAK in input. BREAK was not being converted into an
escape sequence in the `-ignbrk -brkint parmrk' case.

Found by:	NIST-PCTS
1998-12-17 18:43:08 +00:00
Bruce Evans
7cfc9b133e Oops, this should have been in the previous commit (ensure atomic update
of com->cor[1]).
1998-12-17 18:18:06 +00:00
Bruce Evans
657365cdd7 Implemented sending of BREAKs. This is quite complicated because the
hardware is interrupt-driven to a fault and sending a BREAK requires
mode switching.  Always running in the BREAK-capable mode as in PR 8318
would double the overhead for sending \0's.

Reminded by:	PR 8318
1998-12-17 17:40:13 +00:00
Bruce Evans
d21c930ccb Fixed sloppy clearing of TS_BUSY. Don't clear it until the transmitter
is completely empty.  There is an interrupt for output completion.  It
is painful to use, but polling method used in the corresponding fix in
sio.c (rev.1.152) can't be used because there is no status bit for
transmitter-empty.  Now ttywait() works right.

Reminded by:	NIST-PCTS
1998-11-28 15:48:09 +00:00
Bruce Evans
4635f7acc0 Merge from sio.c rev.1.163:
Don't call timeout() for DTR wakeup if the relevant timeout is already
active.  This fixes "timeout table full" panics when sufficiently many
cyopen()s are interrupted while they are sleeping waiting for the
timeout to expire.
1998-11-28 13:18:16 +00:00
Bruce Evans
976d09b9f2 Untangled the Cyclades offsets a little. CY16_RESET and CY_CLEAR_INTR
were half of their physical offsets for ISA and 1/4 of their physical
offsets for PCI, while all other Cyclades offsets were physical/1 for
ISA and physical/2 for PCI.  Logically wrong macros were used to scale
CY16_RESET and CY_CLEAR_INTR to the correct physical offsets.

Fixed some style bugs (mostly long lines).
1998-11-23 13:58:55 +00:00
Bruce Evans
a84c84f5b0 Reduce i/o overheads by not preserving the channel access register in
interrupt handlers.  Instead, load and use it atomically as necessary.
This reduces mode switching overhead for "polled" mode interrupt handling
from 5 i/o's to 3 (per service type, per port) so that polled mode is only
slightly more inefficient than "interrupt" mode.
1998-11-22 17:40:32 +00:00
Bruce Evans
fe310de802 Initialize isa_devtab entries for interrupt handlers in individual
device drivers, not in ioconf.c.  Use a different hack in isa_device.h
so that a new config(8) is not required yet.

pc98 parts approved by: kato
1998-10-22 05:58:45 +00:00
Bruce Evans
cf8c7b0963 Added D_TTY to the cdevswitch flags for all tty drivers. This is required
for the Lite2 fix for always returning EIO in dead_read().

Cleaned up the cdevswitch initializers for all tty drivers.

Removed explicit calls to ttsetwater() from all (tty) drivers.  ttsetwater()
is now called centrally for opens, not just for parameter changes.
1998-08-23 08:26:42 +00:00
Bruce Evans
4a74956bf7 Fixed devfs initialization which I broke in the previous commit.
Fixed an old name and disorder in the sio dictionary.
1998-08-20 05:21:50 +00:00
Bruce Evans
3fd2d29816 Enabled dynamically sized tty input buffers (with enough buffering
for 1 second's worth of input) and larger tty output buffers.  The
interrupt-level buffers are still too small for speeds above 115200
bps (only a little too small for 230400 bps if RTS flow control is
enabled).

Don't call ttsetwater() explicitly in open().  It is now called for
the TTYDISC l_open() and should be static.

Don't attempt to register the cdevsw more than once.
1998-08-19 04:17:38 +00:00
Bruce Evans
87543489d0 Cleaned up previous commit, mainly by moving repetitive calculations
of invariants to cyattach().

Fixed minor bugs:
- cyparam() returned without restoring the ipl in the error cases.  This
  was harmless because cyparam() is always called at spltty().
- one check for "rev. J or higher" actually checked for precisely rev. J.
1998-08-13 19:03:22 +00:00
Bruce Evans
fc64b69498 Updated for not-so-new version of Cyclom-Y boards (with 60MHz clock and
swapped RTS/DTR).  Merge the vendor's modification of the 2.2.6-release
version into -current for reference.  Will be cleaned up in next commit.

Obtained from:	ftp://ftp.cyclades.com/pub/cyclades/cyclom-y/freebsd/2.2.6/cyy226.tar.gz
1998-08-13 13:54:10 +00:00
Bruce Evans
92971f1fd7 Register tty software interrupt handlers at run time using register_swi()
instead of at compile time using ifdefs.

Use _swi_null instead of dummycamisr.  CAM and dpt should call
register_swi() instead of hacking on ihandlers[] directly.
1998-08-11 17:01:32 +00:00
Bruce Evans
7010319f16 Fixed sign extension bugs awoken by changing speed_t to an unsigned
type.  19200, 1200 and other relatively uninteresting speeds were
broken.

Submitted by:	Rob Mallory <rmallory@qualcomm.com>
1998-07-29 18:48:20 +00:00
Bruce Evans
18da528d41 Changed %n to %r in devfs name format strings. %n has almost gone away. 1998-07-15 12:18:34 +00:00
Doug Rabson
ecbb00a262 This commit fixes various 64bit portability problems required for
FreeBSD/alpha.  The most significant item is to change the command
argument to ioctl functions from int to u_long.  This change brings us
inline with various other BSD versions.  Driver writers may like to
use (__FreeBSD_version == 300003) to detect this change.

The prototype FreeBSD/alpha machdep will follow in a couple of days
time.
1998-06-07 17:13:14 +00:00