Home | History | Annotate | Download | only in ic
History log of /src/sys/dev/ic/com.c
RevisionDateAuthorComments
 1.388  12-Feb-2025  imil Set a skip_attach_delay property to "true" for com port in virtual machines
to avoid a delay(10000) at attach
 1.387  09-Feb-2025  skrll Trailing whitespace
 1.386  20-Jan-2025  martin Backout previous, this needs to be done differently
 1.385  20-Jan-2025  imil Avoid delay(10000) for virtual machines
 1.384  11-Apr-2023  riastradh com(4): Note ttylock in comment, not tty_lock.
 1.383  11-Apr-2023  riastradh com(4): Note timecounter_lock in lock order comments.
 1.382  09-Dec-2022  knakahara Revert com.c:r1.381 because i386/qemu cannot boot. Pointed out by gson@n.o and martin@n.o.
 1.381  08-Dec-2022  knakahara Fix hang up writing /dev/console rarely in specific environments.

Some BMC seems to require these syncronous operations. If not,
it does not send transmit completion interrupts for some reason.
 1.380  03-Dec-2022  skrll KNF a comment
 1.379  26-Oct-2022  riastradh ddb/db_active.h: New home for extern db_active.

This can be included unconditionally, and db_active can then be
queried unconditionally; if DDB is not in the kernel, then db_active
is a constant zero. Reduces need for #include opt_ddb.h, #ifdef DDB.
 1.378  03-Oct-2022  riastradh com(4): Nix quirky `integrate' macro.

Just use `static inline' like everything else.
 1.377  03-Oct-2022  riastradh com(4): Omit needless spltty in comstart.

This is called either via tp->t_oproc, which is done with tty_lock
held (thus, at IPL_VM = IPL_TTY), or from comparam which is called at
IPL_TTY, either via comopen or tp->t_param.
 1.376  03-Oct-2022  riastradh com(4): Nix dead code.

This was introduced in rev. 1.292, whose commit message was...
`Delete dead code.' I guess December 6, 2009 was Opposite Day?
 1.375  03-Oct-2022  riastradh com(4): Comment on lock order.
 1.374  03-Oct-2022  riastradh com(4): Update confusing comment from decades ago to reflect now.

No functional change.
 1.373  12-Nov-2021  jmcneill com: Add support for 32-bit IO accesses.
 1.372  30-Oct-2021  jmcneill For the DW APB busy bit workaround, only attempt to re-apply LCR and DLB
settings for non-console devices. In the console case, simply clear the
busy bit and continue. Fixes an interrupt storm observed on Macchiatobin.
 1.371  21-Oct-2021  jmcneill Restore 16-byte FIFO for ns16550a, accidentally lost in r1.344.

Spotted by msaitoh. Thanks!
 1.370  20-Oct-2021  jmcneill - microtime -> microuptime
- avoid kpause with timeo=0
 1.369  14-Oct-2021  jmcneill - use microtime instead of getmicrotime, suggested by thorpej
- use ttclos for wchan even though we are sleeping in comopen now
 1.368  12-Oct-2021  kre Note that while sleeping (HUPCL), time passes.
Try to avoid the otherwise infinite loop.
 1.367  12-Oct-2021  kre Now Jason has made this build, avoid a 50+ year
sleep to implement HUPCL.
 1.366  11-Oct-2021  jmcneill com: speed up close with HUPCL set

Instead of incurring a 1s penalty on close of a com device with HUPCL set,
defer the sleep until the next open, and only sleep if necessary.

This has a side effect of making `ttyflags -a` with a default install not
pause for 1s for every non-console com device, which happens every boot
via /etc/rc.d/ttys.
 1.365  31-Jul-2021  tnn only read cpr register if we're going to use the value
 1.364  30-Jul-2021  tnn com(4): fix FIFO for DW_APB on Allwinner A20 (got broken by com.c 1.360)

Older DesignWare UARTs do not advertise their FIFO length so we must
provide it via device properties.
 1.363  25-Mar-2021  rin branches: 1.363.2;
Introduce COM_HW_BROKEN_ETXRDY bit in sc_hwflags; push TX queue if
possible in comintr() even if IIR_NOPEND is asserted.

Combined with sc_poll_ticks, this flag works around HW bug, by which
ETXRDY interrupts are (sometimes) lost.
 1.362  25-Mar-2021  rin Introduce sc_poll_ticks and obsolete COM_HW_POLL bit in sc_hwflags.
Polling is scheduled at every sc_poll_ticks ticks.

This is useful to work around H/W bug, by which interrupts are lost
*sometimes*; interrupt-based I/O mostly works and no need for polling
every counter ticks.
 1.361  30-Sep-2020  jmcneill branches: 1.361.2; 1.361.4;
Set sc_fifolen=1 for the no fifo case
 1.360  28-Sep-2020  jmcneill Auto-detect DW APB UART FIFO length and print the FIFO length when enabled
instead of just "working fifo".
 1.359  26-May-2020  martin Make the readahead-while-sending-output code conditional in
com_common_putc(), only erquest readahead before interrupts are enabled
and when called from comcnputc().
Fixes PR kern/55286.
 1.358  01-May-2020  simonb Get rid of needless __predict_true() and move a comment slightly.
 1.357  01-Feb-2020  skrll Use designated initializers
 1.356  10-Nov-2019  chs branches: 1.356.2;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.355  11-Jan-2019  thorpej Simplify regmap initialization, and fix an regmap issue that
affected TI OMAP (LCR register would get clobbered due to
using the wrong offset for the MDR1 register) reported by Lwazi Dube
(who also found the root cause).
 1.354  11-Dec-2018  thorpej Add a convenience function, com_init_regs_stride(), that shifts the register
offsets and size by the specified amount. Use in front-ends as appropriate.
 1.353  09-Dec-2018  thorpej sparc64 doesn't have a scalar bus_space_handle_t, so cope with this.
Also, add a comment about why we're using the dummy / nil space handle
in the first place.
 1.352  08-Dec-2018  thorpej Remove the COM_REGMAP option -- just use it all the time. While here,
garbage-collect the COM_FUNCMAP and COM_AU1X00 options, as there are
not used anywhere.
 1.351  08-Dec-2018  thorpej Clean up initialization of com_regs structure, in preparation for
some additional changers.
 1.350  30-Nov-2018  jmcneill Add support for com(4) without an interrupt by setting the COM_HW_POLL flag
 1.349  28-Nov-2018  jmcneill Add support for a "force_console" property, where when set, reuses the console dev configuration
 1.348  27-May-2018  jmcneill branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB
 1.347  08-Apr-2018  jmcneill Remove COM_AWIN option
 1.346  04-Dec-2017  bouyer branches: 1.346.2;
Put back SUNXI definitions in the COM_REGMAP case; com.c uses them
without #ifdef COM_AWIN.
To be safe, expand the register map to 42 entries.
 1.345  31-Oct-2017  martin As discussed on tech-kern: define a new tty internal state flag: TS_KERN_ONLY

Implement it in a few tty drivers. If this flag is set, the underlying
hardware is used by another driver and userland has no right to open
it. A few uses will appear soon in sys/dev/sun/sun{kbd,ms}.c.
 1.344  29-Oct-2017  jmcneill Make all of the COM_xxx type options runtime selectable. Kernel configs
with the existing options (COM_16650, COM_16750, COM_AWIN, COM_HAYESP, and
COM_PXA2X0) will select the correct type in com_attach_subr. New code
should specify the com type by passing COM_TYPE_xxx to comcnattach and/or
setting sc_type.
 1.343  28-Oct-2017  riastradh Kill some more extern struct cfdriver declarations.

Down with externs in .c!
 1.342  10-Aug-2017  nat Report AUXUART fifo size on rpi3 to 1 byte. This prevents bluetooth
errors using the h5 protocol.
 1.341  31-Jul-2017  jmcneill Broadcom AUX UART doesn't seem to set LSR RXRDY bit when data is available
in the RX FIFO.
 1.340  31-Jul-2017  jmcneill Add COM_TYPE_BCMAUXUART type for BCM2835 AUX UART.
 1.339  27-May-2016  bouyer branches: 1.339.10;
The UART in the allwiner SoCs is not full-compatible with the 16550, and
it's not a 16750 either. Like the 16750 it has the IIR_BUSY interrupt,
which is triggered when writing to LCR while the chip
can't accept it. But unlike the 16750, it has a specific register,
HALT, to allow writing to the LCR and divisor registers, and then
commit the changes.
Tested on an A20 SoC, changing the baud rate while keeping the
tty device open and incoming data.
 1.338  14-Dec-2015  jmcneill Fix TX FIFO on Tegra
 1.337  02-Nov-2015  christos PR/50395: Vicente Chaves de Melo: Loss of characters in serial port
communication between gdb and kgdb_stub: switch to line break interrupt
both when entering KGDB and also on shutdown so we can re-enter the debugger
with BREAK.
 1.336  04-May-2015  jmcneill For Tegra K1, set IE_RX_TIMEOUT (bit 4) in IER register. RX_TIMEOUT occurs
when data has been sitting in the Rx FIFO for more than 4 character times
without being read because there is not enough data to reach the trigger
level. With this change, enable FIFO usage for Tegra UARTs.
 1.335  04-May-2015  macallan fix pasto, use SET() and CLR()
thanks jmcneill@
 1.334  03-May-2015  jmcneill add COM_TYPE_TEGRA
 1.333  13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.332  07-Mar-2015  skrll KNF
 1.331  07-Mar-2015  skrll Fix build.

Hi mipsallan
 1.330  07-Mar-2015  macallan more Ingenic support:
- make sure we always set FIFO_UART_ON
- deal with the absence of DCD support
- enable the TX FIFO timeout interrupt
- set COM_HW_NOIEN
- pretend the FIFO is only 16 bytes deep ( supposed to be 64 but I get
overruns with that )
now this works as CI20 console
 1.329  22-Nov-2014  macallan branches: 1.329.2;
deal with quirk in Ingenic UARTs
( they have a bit in the FIFO control register which turns the entire
port off if not set )
 1.328  15-Nov-2014  christos centralize the dialout/call unit macros.
 1.327  10-Aug-2014  tls branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.
 1.326  25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.325  08-Apr-2014  christos Clear dtr on transition from !0 to 0, and set it on the opposite.
This leaves dtr alone in the normal case.
 1.324  06-Apr-2014  christos PR/48720: John Kelly: com driver does not allow B0 to be set. The code to
handle B0 was commented out for no reason given at revision 1.99. POSIX
mandates to hangup on B0:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcsetattr.html
 1.323  16-Mar-2014  dholland branches: 1.323.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.322  22-Dec-2013  matt Now that cngetc supports -1 as a return value from the cn_getc routine,
let cngetc loop until a character is available so it can call the critpoll
hooks.
 1.321  16-Dec-2013  skrll Use #if defined in previous.
 1.320  16-Dec-2013  htodd Fix build.
 1.319  15-Dec-2013  mbalmer lcr is only used when COM_16650 is defined; unbreak the build
 1.318  15-Dec-2013  skrll Only attempt to set 64byte fifo for 16750 when COM_16750 is defined.

Hi kiyohara.

PR/48359 NetBSD/cobalt 6.99.25 GENERIC kernel freeze at initializing com0
 1.317  03-Oct-2013  kiyohara Revirt 'Move the Marvell extension to com_mv.c' at Sun Sep 1 04:51:24 UTC 2013.
build test only.
 1.316  12-Sep-2013  martin Minor tweaks for newer gcc
 1.315  03-Sep-2013  jmcneill no EFR on tl16c750, use AFE bit on MCR reg instead for flow control
 1.314  01-Sep-2013  kiyohara Add support 16750 64Byte FIFO. But not test.
 1.313  01-Sep-2013  kiyohara Move the Marvell extension to com_mv.c.
 1.312  27-Jul-2013  kiyohara As for the console of ns16750, comintr() may be called before comopen().
If sc_lcr is not initialized at this time, console will be in an ugly state.
 1.311  27-Jul-2013  kiyohara Remove white-spaces, null-line and new-line.
 1.310  01-May-2013  mlelstv branches: 1.310.4;
For a polled console incoming characters are buffered on output.
The buffer is never passed to the regular tty routines and can
survive from early boot to halt where it is read by the "press
any continue to reboot" loops.
As a workaround, just kill the read-ahead buffer when switching
from and to polled mode.
 1.309  20-Apr-2013  rkujawa Add support for 16750 style UARTs. Activated by defining COM_16750.

Obtained from Marvell, Semihalf.
 1.308  24-Feb-2013  matt Initialize t_softc.
 1.307  10-Jan-2013  macallan don't try to become console if we get is_console=false as device property
 1.306  21-May-2012  skrll branches: 1.306.2;
Remove empty line.
 1.305  22-Apr-2012  christos don't include <sys/rnd.h> before we define cn_trap, because it might bring
in <sys/systm.h>
 1.304  02-Feb-2012  tls branches: 1.304.2;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.303  27-Nov-2011  jakllsch branches: 1.303.2;
more whitespace and comment spelling fixes
 1.302  27-Nov-2011  jakllsch whitespace consistency adjustment
 1.301  28-May-2011  matt branches: 1.301.4;
Allow COM_TOLERANCE to be tweakable. If comspeed returns an invalid
rate, don't use that error value to set the speed.
 1.300  24-Apr-2011  rmind Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.299  22-Jan-2011  tsutsui Revert part of changes in rev 1.298:
- it breaks cobalt's serial console as mentioned in PR port-cobalt/44292
- MCR_PRESCALE doesn't affect unless EFR_EFCR is set in the EFR register
- even if MCR_PRESCALE is enabled we should define appropriate sc_type
variants and BRG values should be adjusted in comspeed() per sc_type
- sc_frequency should be adjusted in MD attachment if necessary
Tested on cobalt by several people, ok from jklos@
 1.298  20-Jul-2010  jklos branches: 1.298.2; 1.298.4;
Add support for 16650's prescaler from Frank Wille. Tested with
IOblix on Amiga.
 1.297  19-Apr-2010  dyoung Add default implementations for bus_space_is_equal(9),
bus_space_tag_create(9), and bus_space_tag_destroy(9). Use
bus_space_is_equal(9) throughout the kernel to compare
bus_space_tag_t's. Tested on i386 and on sparc64.
 1.296  22-Mar-2010  dyoung MI code should not compare bus_space_tag_t! Introduce tags_are_equal()
for "comparing" two bus_space_tag_t's. It is always true.

Everywhere that com(4) compares two tags, it compares to I/O base
addresses, too; comparing the base addresses should suffice.

TBD Clean this up more thoroughly.
 1.295  24-Feb-2010  dyoung branches: 1.295.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.294  09-Jan-2010  tsutsui branches: 1.294.2;
To print bus_addr_t value, cast it to u_long rather than size_t.
 1.293  08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.292  06-Dec-2009  dyoung Delete dead code.
 1.291  23-Nov-2009  rmind Remove some unecessary includes sys/user.h header.
 1.290  12-Nov-2009  dyoung Remove some dead code.
 1.289  12-Nov-2009  dyoung Move the code in com_activate() to com_detach(), where it always
belonged. Remove com_activate().

Consolidate information about the console on com(4) in a new struct
comcons_info.

Support detachment & re-attachment of a system console on com(4).
Re-attachment is somehow incomplete. Ideally, if some other device
could take over as console, it would, but we're not quite there,
yet.
 1.288  06-May-2009  cegger add KASSERT to identify when PR kern/40734 happens again.
It happened to me twice and to Emmanuel Dreyfus (reported on port-amd64 ML)
 1.287  03-Jan-2009  yamt branches: 1.287.2;
remove extra semicolons.
 1.286  25-Oct-2008  matt branches: 1.286.2; 1.286.10; 1.286.14;
Simplify NOERS case. Revert most changes back to 1.283.
 1.285  25-Oct-2008  tsutsui Fix a botch in an FIFO check for 16650.
 1.284  25-Oct-2008  he Replace a "type" with "sc->sc_type" to make this build again for cobalt
(and I'm sure a few others as well).
 1.283  24-Oct-2008  matt Add support for 16550 chips without an Enhanced Register Set.
 1.282  14-Jul-2008  matt Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.
 1.281  28-Apr-2008  matt branches: 1.281.2; 1.281.4; 1.281.6;
More forgotten changes from matt-armv6.
 1.280  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.279  21-Apr-2008  ad branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.
 1.278  11-Apr-2008  tsutsui branches: 1.278.2;
If it's a high speed, trim the trigger level down to prevent overflows,
as comment says. The piece of code was removed in rev 1.230,
but it looks an error on reverting of rev 1.228.
 1.277  14-Mar-2008  cube Fix compilation under options RND_COM and COM_DEBUG.
Reported by Kurt Schreiner on current-users@.
 1.276  14-Mar-2008  cube Split device_t and softc for all com(4) devices (well, everything that
uses a com_softc backend). Use proper types and ansify where appropriate.
 1.275  07-Mar-2008  dyoung In com_detach(), don't destroy the lock twice.
 1.274  07-Mar-2008  dyoung Use device_t and its accessors.
 1.273  29-Feb-2008  dyoung Use pmf_device_register1() instead of shutdownhook_establish() to
register com_cleanup() as the shutdown hook.

Add a generic suspend routine. Suspend and resume com@isa.

Protect against dereferencing a NULL softc in comioctl().

Destroy both a mutex and a callout in com_detach().

Cosmetic: use aprint_*_dev(). Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.272  28-Jan-2008  dyoung branches: 1.272.2; 1.272.6;
Do not allow the system console to detach, because that will lead
to a panic.
 1.271  24-Jan-2008  ad Destroy mutex when detaching. PR kern/37819.
 1.270  20-Jan-2008  joerg Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.
 1.269  05-Jan-2008  ad Work around com hangs with pcmcia. PR kern/37462.
 1.268  14-Dec-2007  dyoung Add a resume handler for com@isa, using Jared McNeill's suggested
code from current-users. com@acpi, et cetera, remain to be done.
 1.267  05-Dec-2007  ad branches: 1.267.4;
Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
 1.266  19-Nov-2007  ad branches: 1.266.2;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.265  19-Oct-2007  ad branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.264  17-Oct-2007  ad branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.
 1.263  08-Oct-2007  ad Merge from vmlocking: use mutexes and the softint API.
 1.262  16-Aug-2007  martin branches: 1.262.2; 1.262.4;
Remove all locking from com_enable_debugport() - it is either called at
attach time, where we don't need further locking, or from comopen(),
where the caller does proper locking already.
 1.261  14-Jul-2007  ad branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.
 1.260  09-Jul-2007  ad Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.259  04-Mar-2007  christos branches: 1.259.2; 1.259.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.258  10-Jan-2007  cube branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.
 1.257  10-Dec-2006  uwe aprint_naive("\n") to terminate "Found" line for quiet boot.
Use aprint_error to report that we are unable to establish power hook.
 1.256  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.255  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.254  01-Oct-2006  elad More from Matt Fleming:

Adapt to KAUTH_DEVICE_TTY_PRIVSET and KAUTH_DEVICE_TTY_OPEN.
 1.253  01-Oct-2006  elad Adapt MD code to KAUTH_DEVICE_TTY_OPEN, batch #2 from Matt Fleming, thanks!

Also, add forgotten splx() calls in some places.
 1.252  24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.251  08-Aug-2006  mrg branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.
 1.250  22-Jul-2006  elad branches: 1.250.2;
oops, no 'p' here. from xtraeme@.
 1.249  22-Jul-2006  elad don't call kauth_authorize_generic() when holding a lock, from yamt@.
 1.248  21-Jul-2006  ad - Use the LWP cached credentials where sane.
- Minor cosmetic changes.
 1.247  13-Jul-2006  gdamore Add an option COM_REGMAP to allow com(4) to use an array of register indices.
This allows us to convert aucom to just another com attachment, and cleanup
some code in the com_arbus.c.

Additionally, we use a common com_cleanup routine rather than having a
zillion copies of it in the attachment points.

This has been tested on a number architectures, and it has been shown to get
close to comparable performance when COM_REGMAP is defined, and comparable
when it is not defined.

Approved by core@. Fixes PR port-evbmips/32362.
 1.246  25-Jun-2006  jmcneill Make sure that a powerhook was successfully established before trying to
disestablish it on detach.
 1.245  25-Jun-2006  perry Add a power hook for the com device.
 1.244  07-Jun-2006  kardel branches: 1.244.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.243  14-May-2006  elad branches: 1.243.2;
integrate kauth.
 1.242  28-Mar-2006  thorpej Use device_unit().
 1.241  20-Feb-2006  thorpej branches: 1.241.2; 1.241.4; 1.241.6;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.
 1.240  08-Jan-2006  dsl branches: 1.240.2; 1.240.4;
Save console baud rate as both the input and output rates.
This is what I thought I'd done in rev 1.237
 1.239  27-Dec-2005  chs branches: 1.239.2;
remove the COM_MPLOCK option. always include the spinlock in the softc
and always call the simple_* locking functions. the locking functions
are compiled out if they are not needed anyway, so a separate option
for this doesn't gain anything.

this also fixes the serial console on my alpha ES40 (which doesn't make much
sense since the com driver should still be under the big lock on alpha,
but whatever).
 1.238  11-Dec-2005  christos merge ktrace-lwp.
 1.237  06-Nov-2005  dsl Explicitly default the input baud rate (c_ispeed) to the output baud rate (c_ospeed)
instead of setting it to zero. Otherwise nothing ever sets it unless some code
explicitly changes the baud rate. For a serial console (in particular) we want
to use the baud rate set by the bios (or whatever) and used by theboot code.
This is the way it was before a 'new version of com driver' was added in 1997 (rev 1.99)
 1.236  06-Sep-2005  kleink Change the driver open function's conditional for overriding exclusive tty
use from checking the proc's uid to suser(9), and account for the use of
privileges. Noted by David Holland in PR kern/31126.
 1.235  04-Sep-2005  kleink Make COM_DEBUG compile again in the wake of -Wwrite-strings;
from Nicolas Joly in PR kern/31141.
 1.234  21-Jun-2005  ws branches: 1.234.2;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.
 1.233  12-Jun-2005  tls Revert the part of revision 1.228 that made HW_NO_TXPRELOAD the default:
it appears to break output on the Soekris net4501, which is a rather
popular platform.

This should fix PR kern/29612 -- if not, I will probably revert it again.
 1.232  27-Feb-2005  perry branches: 1.232.2;
nuke trailing whitespace
 1.231  09-Aug-2004  mycroft branches: 1.231.4; 1.231.6;
Do an extra read of the IIR during initialization, just to ack any pending
interrupt.
 1.230  04-Jul-2004  mycroft Back off the trigger level a little. Testing shows that it's not terribly
reliable at 14.
 1.229  04-Jul-2004  mycroft Minor simplification.
 1.228  04-Jul-2004  mycroft Incorporate 4 changes that have been suggested:
* At high speed, set the FIFO trigger to the maximum value to reduce interrupt
load. PR 15448.
* Handler the case of IIR=RXRDY and LSR=!LSR_RCV_MASK differently, to avoid a
hang with some chips. PR 21184, and possibly PR 10974 and PR 8248.
* Remove the extra wait at the end of com_common_putc(), after writing a
character out, so that we get another TXRDY interrupt. This prevents stalls
when normal output and kernel output are mixed. PR 4263.
* Do not "preload" the TX FIFO; wait for a TXRDY interrupt to come in after
enabling it.
 1.227  01-May-2004  thorpej Rename the COM16650 option to COM_16650, for consistency with other
com variant options.
 1.226  01-May-2004  thorpej Wait just a little longer for console output to finish when we're
attaching the console uart.
 1.225  05-Apr-2004  enami Fix race condition introduced in rev 1.189; after the change, if there is
THRE interrupt occurs between the LSR read and IIR read, we won't see the
LSR_TXRDY bit when testing it in the variable `lsr' and we don't interrupted
again (as the corresponding bit in the IIR is cleared by reading, except
for some broken device).

Tested by Matthias Scheler and me, reviewed by Allen Briggs.
Closes PR#25010.
 1.224  23-Jan-2004  simonb branches: 1.224.2;
Fix NTP PPSAPI support (enabled with "options PPS_SYNC"):

From PR kern/13702 from Charles Carvalho. Tested on alpha and
i386 with a Laipac TF10 PPS-capable GPS. The com.c change was
copied wholesale from Charles' z8530tty.c patch.
 1.223  12-Nov-2003  simonb Use just "type" and not "sc->sc_type" in cominit().

Pointed out by Shoichi Miyake in private mail.
 1.222  08-Nov-2003  simonb Make comsoft_callout static; it's not referenced outside this file.
 1.221  06-Nov-2003  simonb Be consistent with other COM_TYPE_PXA2x0 checks.
 1.220  06-Nov-2003  simonb White space nit.
 1.219  03-Sep-2003  simonb Add missing semicolon.
 1.218  01-Sep-2003  christos fix debugging printfs
 1.217  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.216  29-Jun-2003  fvdl branches: 1.216.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.215  29-Jun-2003  simonb Restore parentheses around return value that were removed with the
previous commit.
 1.214  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.213  23-Jun-2003  martin Make sure to include opt_foo.h if a defflag option FOO is used.
 1.212  18-Jun-2003  bsh in cominit(), turn on UUE bit in IER register if it is PXA2x0's
built-in UART.
 1.211  15-Jun-2003  simonb Wrap some long lines.
 1.210  14-Jun-2003  thorpej Also pass a type argument to comcnattach() and com_kgdb_attach().
comspeed() (and thus cominit()) may need this information.
 1.209  14-Jun-2003  thorpej Introduce a new "type" field in the softc which is used to indicate
the general UART type. Currently, we have "normal", "hayesp" and
"pxa2x0" types. Replace the corresponding hw flags with the new type
values.
 1.208  05-Jun-2003  scw Add support, via a kernel config file option, for the 16550-compatible
com ports found on Intel PXA2x0 processors.

Re-arrange the code which detects the FIFO configuration to defer
printing until _after_ com_fifo is cleared. Some supposedly compatible
chips clear the Tx/Rx FIFOs when this happens, resulting in previous
output being lost.
 1.207  18-May-2003  fvdl Inialize sc_tty->t_dev early for serial console, so that cn_check_magic
will match in the case of a break before the console was opened for the
first time. Makes BREAKing into DDB work (again) as soon as interrupts
are enabled.
 1.206  28-Apr-2003  briggs Allow the console to be used for kgdb if both DDB and KGDB are defined.
 1.205  21-Apr-2003  gson Ignore input when the port is not open. This change is functionally
identical to the patch in kern/6502 (which is hereby fixed), but
modelled after the corresponding fix to the 8530 driver in
z8530tty.c revision 1.60 to maintain consistency with that driver.
 1.204  14-Mar-2003  simonb Fix some white-space niggles.
 1.203  06-Mar-2003  matt Add cn_halt and cn_flush entries to consdevs. (needed for dma-only console
devices).
 1.202  31-Jan-2003  thorpej Use aprint_*().
 1.201  07-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.200  23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.199  06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.198  29-Jul-2002  simonb Don't name parameters in a function declaration.
 1.197  29-Jul-2002  simonb ANSIfy, KNF.
 1.196  13-Apr-2002  christos branches: 1.196.2; 1.196.4;
PR/16058: Tero Kivinen: Don't free rbuf or detach tty if rbuf allocation
failed during attach phase.
 1.195  12-Apr-2002  thorpej * Add a new hwflag, COM_HW_NO_TXPRELOAD, which tells comstart() to
not pre-load the chip's Tx buffer, but instead waits for the Tx Ready
interrupt to transmit the first chunk of data.
* On the IOP310, set COM_HW_NO_TXPRELOAD, rather than COM_HW_TXFIFO_DISABLE.

This solves the "UART hangs" problem on the Npwr in a nicer way (i.e. we
get to use the FIFO, whee). The COM_HW_NO_TXPRELOAD happens to match the
Linux 16550 driver's Tx algorithm, and the "UART hang" was never observed
on the Npwr running Linux.

Eventually, we might want to eliminate the COM_HW_NO_TXPRELOAD, and simply
always use its algorithm. But it should be tested on more 16x50 variants
before we do that.

Kudos to Valeriy Ushakov <uwe@netbsd.org> for pointing out this solution
(which also happens to fix the stray UART interrupt issue on the Krups
Javastation), and to Allen Briggs <briggs@netbsd.org> for experimenting
with various methods of fixing this.
 1.194  17-Mar-2002  atatat Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.193  20-Nov-2001  lukem - pull in opt_kgdb.h where necessary
- replace opt_kgdb_machdep.h with opt_kgdb.h
- defparam opt_kgdb.h:
KGDB_DEV KGDB_DEVNAME KGDB_DEVADDR KGDB_DEVRATE KGDB_DEVMODE
- move from opt_ddbparam.h to opt_ddb.h:
DDB_FROMCONSOLE DDB_ONPANIC DDB_HISTORY_SIZE DDB_BREAK_CHAR SYMTAB_SPACE
- replace KGDBDEV with KGDB_DEV
- replace KGDBADDR with KGDB_DEVADDR
- replace KGDBMODE with KGDB_DEVMODE
- replace KGDBRATE with KGDB_DEVRATE
- use `9600' instead of `0x2580' for 9600 baud rate
- use correct quotes for options KGDB_DEVNAME="\"com\""
- use correct quotes for options KGDB_DEV="17*256+0"
- remove unnecessary dependancy on Makefile for kgdb_stub.o
- minor whitespace cleanup
 1.192  15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.191  13-Nov-2001  lukem add/cleanup RCSID
 1.190  05-Nov-2001  fvdl Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).
 1.189  17-Sep-2001  briggs branches: 1.189.2;
Patch to handle odd behavior from exar ST16C1550 UART. It does not set
IIR_NOPEND if the TXRDY condition is true. Apparently, other chips do
not take TXRDY into account in the IIR_NOPEND case.

Also remove useless assignment (iir = IIR_NOPEND;) in one case.

No response from patch posted on tech-kern 29Aug2001.
 1.188  27-Aug-2001  enami branches: 1.188.2;
For hayes esp card, set prescaler if specified rate is grater than 115200.
 1.187  22-Aug-2001  simonb Cosmetic cleanups:
- cominit() is local to com.c, remove prototype from comvar.h.
- Don't prototype comstop(), cdev_decl(com) does this.
- Don't use a block device switch table declaration(!).
- No need to include "com.h".
 1.186  20-Jun-2001  uwe branches: 1.186.2;
Convert to use cnmagic(9). Unifdef DDB and DDB_BREAK_CHAR.
While I'm here, s/ungetc/readahead/ in com_common_* because that's
what it _really_ is, "ungetc" is a very confusing name.
 1.185  30-May-2001  lukem add missing #include "opt_kgdb.h"
 1.184  02-May-2001  scw Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.183  14-Jan-2001  thorpej branches: 1.183.2;
Rename __GENERIC_SOFT_INTERRUPTS to __HAVE_GENERIC_SOFT_INTERRUPTS,
and place the definition in <machine/types.h>. This can now be used
as a flag to indicate whether or not <machine/intr.h> can be included
to get the generic soft interrupt API.
 1.182  18-Nov-2000  sommerfeld Initialize ring buffer pointers when the ring buffer is allocated.
(comsoft() can be invoked before comopen() on serial consoles; a character
received before the console is opened "for real" can result in a fatal trap
unless the ring buffer pointers are initialized early)
 1.181  01-Nov-2000  eeh Adapt to the new line discipline scheme.
 1.180  26-Sep-2000  sommerfeld Add missing '&& defined(COM_MPLOCK)'
 1.179  23-Sep-2000  sommerfeld Add `COM_MPLOCK' option to use a device-instance-specific spinlocks
when running at splserial(). This is a temporary measure (until
there's a MP-safe interrupt handling structure); until then, it should
be used when MULTIPROCESSOR and IPL_SERIAL > IPL_SCHED.
 1.178  22-Sep-2000  eeh paddr_t -> bus_addr_t.
 1.177  21-Sep-2000  eeh Support for SPARC machines with `su' devices.
 1.176  17-Sep-2000  toshii Change tiocm_to_{com,zs}'s second argument to u_long to match with
the type in their caller.
 1.175  18-Aug-2000  sommerfeld Avoid calling tsleep when running above splhigh()
 1.174  03-Aug-2000  jeffs Add options DDB_BREAK_CHAR. This overrides break on the serial console
break character with the supplied one. This is useful for cases where
break is hard to generate, or you are connected to a PC that "sends"
breaks when power cycled. For this mode in com, interpret break char
in the polling section, which allows entry into the debugger before
the tty is opened. Only supported in the com driver currently.
 1.173  06-Jul-2000  thorpej Use device_lookup().
 1.172  03-May-2000  thorpej Remove unnecessary junk on #undef line that some C preprocessors
get cranky about.
 1.171  30-Mar-2000  simonb Delete redundant decl of com_attach_subr(), it's in comvar.h.
 1.170  23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.169  06-Mar-2000  thorpej - Implement cnbell() -- ring the console bell. The cn_bell entrypoint
is optional.
- Add cn_bell to statically allocated consdevs as appropriate.
 1.168  07-Feb-2000  jonathan Fix thinko in previous revision: it wouldn't catch deassert.
Revert the code inside the new test to the previous-but-one revision.
 1.167  06-Feb-2000  jonathan Check for DCD status change interrupts which signal PPS events, even
if the line discipline is ignoring carrier (e.g., via comparam()'s
setting of sc->sc_msr_mask). Move PPS timestamp outside the normal
status-change processing, and ignore sc_msr_mask when testing
for PPS events.
 1.166  23-Jan-2000  soda kluge to make this work with NEC M403 (arc/magnum).
 1.165  21-Dec-1999  drochner set carrier early if used as console or kgdb line, fixes PR kern/6547
by Andreas Gustafsson, gson@iengines.com
 1.164  22-Nov-1999  sommerfeld defopt COM_DEBUG, COM_HAYESP, and COM16650
 1.163  04-Nov-1999  jonathan Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.
 1.162  15-Oct-1999  jonathan branches: 1.162.2; 1.162.4;
Fix nanosecond/microsecond botch in PPSAPI:
remove bogus TIMESPEC_TO_TIMEVAL() after applying any {assert,clear} offset.
 1.161  19-Apr-1999  ross branches: 1.161.2;
Get rid of delay() in com_common_putc() because the Shark delay() is borked
and can't be called until after the timers are setup. (It should not use
a timer, or it should have a fallback algorithm.)
 1.160  18-Apr-1999  thorpej Revert revision 1.159. The correct answer was not to re-break the
serial console support, but rather to fix the Shark delay().
 1.159  31-Mar-1999  mrg branches: 1.159.2;
back date this file to version 1.155 which works on the shark.
 1.158  29-Mar-1999  mycroft Nuke bogus extra variable, too.
 1.157  29-Mar-1999  mycroft Fix bogons in previous change:
* The fact that IIR_NOPEND was not set on entry does *not* mean that no
transmission was in progress. Besides, we don't want to throw away receive
interrupts either.
* In the !clearirq case, we didn't splx().
 1.156  29-Mar-1999  ross Mods to com_common_putc(). When doing kprintf() or kgdb output:
1. don't clear the irq unless it was clear before transmitting
2. also do various bus_space_barrier() ops
Stops console from freezing when kprintf interrupts tty driver output.
 1.155  28-Feb-1999  explorer Update to slightly altered rnd_attach_source() api
 1.154  12-Feb-1999  drochner make the probe stricter to catch cases where the chipset doesn't pull
the data lines to "high" for not-existant devices
 1.153  03-Feb-1999  mycroft Separate the tiocm code into functions, like the z8530 code, and fix the same
DTR bug.
 1.152  03-Feb-1999  mycroft Fix an inconsistency: PPS was turned off on first open, but the mode may have
still claimed it was enabled.
 1.151  03-Feb-1999  mycroft Slight redux in PPS code.
 1.150  26-Jan-1999  drochner Debugger() -> console_debugger() to honour the ddb_fromconsole sysctl
 1.149  18-Nov-1998  thorpej Add support for detaching "com" instances.
 1.148  16-Sep-1998  is Garbage collect unused 3rd parameter to comprobe1().
 1.147  09-Sep-1998  thorpej Don't use M_WAITOK to allocate the ring buffer; we could be in interrupt
context. Reported by Lennart Augustsson.
 1.146  15-Aug-1998  mycroft Assign my copyrights to TNF.
 1.145  04-Jul-1998  jonathan defopt DDB.
 1.144  10-Jun-1998  jonathan PPS support from April, reworked and extended to match the PPS-API
Internet Draft (draft-mogul-pps-api-02.txt).
 1.143  22-Mar-1998  mycroft Move the code to wait for carrier on a tty into a common function, since it
depends only on device-independent state bits.
Implement SunOS-style `dialout' devices.
 1.142  21-Mar-1998  mycroft Remove a bogus initializer.
 1.141  21-Mar-1998  mycroft Replace TS_WOPEN with t_wopen, per mail on tech-kern.
 1.140  25-Feb-1998  ross Add dummy }} after comsoft() to keep ctags(1) bashing on.
 1.139  22-Feb-1998  enami Disable the device if we fail to open and nobody else has the device open.
(Thanks Charles and Marc for your advices).
 1.138  22-Feb-1998  mycroft Fix bonehead error in previous change.
 1.137  19-Feb-1998  mycroft Remove stray label from last change.
 1.136  19-Feb-1998  mycroft Arrange to call com_break() and com_modem() at splserial().
It's simpler this way. Really.
 1.135  09-Feb-1998  thorpej Fix serial console support, which was broken by the previous revision:
- In the console getc routine, block until a character becomes ready
(no, really, we mean it). This routine should _never_ time out.
- In the console putc routine, if the UART has trouble, do NOT proceed
to print a diagnostic message, which would recursively invoke the
console putc routine ad nauseum.
 1.134  06-Feb-1998  enami Restore system priority level before return from comopen().
 1.133  02-Feb-1998  cgd change #ifdefs keying on "alpha" to key on "__NO_SOFT_SERIAL_INTERRUPT"
instead, and define that on NetBSD/alpha and NetBSD/arm32.
 1.132  02-Feb-1998  cgd Implement a flag to indicate that the driver attached correctly.
This is useful in the case where an attachment's probe routine
verifies that there is indeed hardware present but something goes
"wrong" in the attach causing the device to be unusable. (Without
keeping track of this, in that case incorrect ports could be
accessed or uninitted pointers could be deferenced on open or at
other times.)
 1.131  01-Feb-1998  marc split com_attach_subr into attach stuff and per-open initialization stuff
add timeouts to all splserial() while loops so bugs elsewhere don't cause
the com driver to wedge the machine
add power management support
 1.130  12-Jan-1998  thorpej Adjust for config changes.
 1.129  16-Dec-1997  mycroft Don't do anything in comparam() if the line speed and flags are the same.
 1.128  03-Nov-1997  mycroft Slight optimization in soft input routine.
 1.127  03-Nov-1997  mycroft Mostly cosmetic and performance changes:
* Make the ring buffer size and water marks patchable, and allocate the buffer
separately.
* Do the ttymalloc() at attach time.
* Reorganize the receive buffer so the status and data pair are next to each
other. This is slightly faster.
* Make sure we actually do turn off interrupts in comclose() if we have DDB
configured and it's not the console. (D'oh!!!!)
* When we exhaust the current transmit run, turn off transmit interrupts in
comintr(), so we're fairly sure we don't get another one.
* Nuke the silly lsrmap[] idea; it's slower in the normal case.
* Cache the l_rint pointer in the soft interrupt routine.
 1.126  02-Nov-1997  mycroft Slight code rearrangement.
 1.125  02-Nov-1997  mycroft Slight code rearrangement.
 1.124  02-Nov-1997  mycroft Rearrange *param() slightly to eliminate a spl.
Also fix another comment regarding DTR.
 1.123  02-Nov-1997  mycroft Add another splserial()/splzs().
 1.122  02-Nov-1997  mycroft Minimize some spl regions slightly.
 1.121  01-Nov-1997  mycroft Correct a comment regarding our behaviour with DTR.
 1.120  01-Nov-1997  mycroft Add additional splserial()s in comopen() and comclose(). These are not
necessary on the i386 port, but may be on others.
 1.119  29-Oct-1997  drochner Print probe result after the LCR is restored. Otherwise, bad
things happen if we are the console.
Restore to the prevoius value (not to hardwired 8N1) because this
could be set by the serial console initialization.
Closed PR kern/4373 (Dave Huang)
 1.118  21-Oct-1997  fvdl branches: 1.118.2;
Make 16650 probe optional on COM16650 define. It breaks on some
multiport Startech chips.
 1.117  19-Oct-1997  mycroft Initialize the IER to 0 in com_attach_subr().
 1.116  19-Oct-1997  fvdl Add 16650 hardware flowcontrol support. Basically PR 3844 from
Dave Huang <khym@bga.com>, with added check for broken early versions
of the 16650, taken from the Linux driver.

This should be extended to use, for example, higher trigger levels for
the bigger 16650 FIFO, and its capability for using a smaller divisor
and thus higher speeds. But this patch is very useful for 16650 users
already.
 1.115  19-Oct-1997  explorer Add hooks for entropy collection. Right now, you must place
options RND_COM
in your kernel config file (along with the
pseudo-device rnd
line) to enable this. If results are positive, I will make this enabled
by default.
 1.114  18-Oct-1997  is Use long long in bitrate tolerance computation, else we'll overflow for
higher than standard-pc chip clocks.
 1.113  16-Oct-1997  thorpej branches: 1.113.2;
"com" driver files copied by repository copy magick to sys/dev/ic, and
adjusted for their new home.
 1.112  03-Oct-1997  mikel fix missing com_kgdb_attached() argdecl, from Michael C. Richardson in PR 4196
 1.111  30-Sep-1997  christos Add TIOCM{BI{C,S},{S,G}ET} from revision 1.98. As Charles says these
interfaces are slightly broken and should be obsoleted, but some programs
are using them and also they are useful for debugging.
 1.110  19-Sep-1997  enami Cosmetic Changes; make coding style closer to other part of this file.
(This version is identical with version 1.109 except whitespace changes.)
 1.109  16-Sep-1997  is Support for the upcoming NetBSD/Amiga Hypercom driver family:
* support chip clocks != COM_FREQ, by introducing sc_frequency (for the
mainline code) and adding a frequency parameter right after the rate
parameter to comcnattach() and com_kgdb_attach().
- Make com_isa and com_multi initialize sc_frequency to COM_FREQ.
- Make i386/machdep.c and alpha/dec_xxx.c call com*attach() with the freq.
parameter.
* supio_attach_args get two more fields: a sc_ipl and a sc_arg, both ints.
- com_supio uses the first for interupt establishment (all childs will, as
soon as they exist) and the 2nd for sc_frequency.
- drsupio passes sc_ipl alway as 5, and for the "com"s, sc_arg as 16*115200
- hyper will pass sc_ipl as 6, and sc_arg as 16 * 460800
 1.108  27-Aug-1997  is Make this work with __GENERIC_SOFT_INTERRUPTS.
 1.107  24-Aug-1997  drochner Check for KGDB port == console port in a consistent way.
 1.106  23-Aug-1997  drochner clean up the serial console / KGDB attachment:
-put all early console / KGDB initialization into 1 exported function
(com_*_attach()) each, dont use global variables anymore
-use the passed tcflag_t for port settings instead of hardwiring 8N1
-at autoconfiguration attach time, decide if the attaching device is
already console / KGDB by comparing bus tag and base addr (cgd's wish)
-export a function "com_is_console()" for use by driver frontends for
this comparision
-delay setting of cn_tab->cn_dev until autoconfiguration attach
to get the minor number right
-delete unused comcnprobe() and comcninit()
 1.105  16-Aug-1997  drochner Bring back the "comconsattached" flag. It is necessary for starred
com devices (on non "__BROKEN_INDIRECT_CONFIG" ISA).
 1.104  14-Aug-1997  drochner -Export variables needed for system console initialization.
-Enable line break interrupt for DDB on a serial console.
-Share initialization code between DDB and KGDB.
 1.103  12-Aug-1997  drochner KGDB improvements:
-Separate KGDB port initialization and softc related stuff to allow
KGDB to be attached in early system startup, before autoconfiguration.
-Export the variables needed by md code to hand-craft bus tag/handle.
-Fix initialization to enable interrupt by line break.
-Call DDB/KGDB at line break (move DDB call from the softirq handler
to the hard handler because it should work without a tty attached too).
 1.102  05-Jul-1997  thorpej branches: 1.102.2;
Add support for remote serial KGDB.
 1.101  15-Jun-1997  mycroft Implement a better backpressure mechanism so that data is collected
in the driver's buffer if the tty buffer is full. If the driver's buffer
becomes full, turn off receive interrupts until it drains a bit.
 1.100  26-May-1997  mycroft Remove unneeded call to comstop() in commsrint(). This fixes a problem
where the driver would sometimes retransmit bytes.
 1.99  04-Apr-1997  mycroft New version of com driver. Uses a different queueing mechanism and a split
hardware/software interrupt mechanism for improved performance. Many odd
protocols bugs also fixed.
 1.98  04-Apr-1997  mycroft comdefaultrate -> comconsrate
comconsbah -> comconsioh
Only use comconsrate on the console.
 1.97  30-Jan-1997  cgd don't clobber IER in cominit(). (suggested by mycroft.)
 1.96  14-Dec-1996  mycroft If attaching the console, reinitialize it immediately.
 1.95  14-Dec-1996  mycroft Turn off the baud rate changing optimization.
 1.94  05-Dec-1996  cgd update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.93  13-Nov-1996  cgd move cominit() prototype to comvar.h, so that ports which use 'com'
for serial console, but don't use the (i386-specific)
comcninit()/comcnprobe() functions, can do the right thing.
 1.92  22-Oct-1996  cgd add missing argument to bus_space_map in ESP code
 1.91  21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.90  13-Oct-1996  christos backout kprintf changes
 1.89  10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.88  06-Oct-1996  mycroft If we get a RXRDY interrupt, but RXRDY is not set in the LSR, briefly set IER
to 0. This fixes a condition where some UARTs send an infinite stream of
RXRDY interrupts.
 1.87  06-Oct-1996  mycroft Serial console changes:
* Enable FIFO with trigger level 1.
* Set DTR and RTS so terminals are happy.
 1.86  05-Sep-1996  mycroft compoll() -> comsoft()
 1.85  02-Sep-1996  mycroft tty stop functions really should return void, not int, and certainly not both.
 1.84  10-Jul-1996  cgd move DDB-only label inside an #ifdef, so that -Wall works
 1.83  30-May-1996  cgd add tty_attach() where appropriate.
 1.82  12-May-1996  mycroft branches: 1.82.4;
Use intr.h.
 1.81  05-May-1996  christos Move comintr() prototype to comvar.h; needed by the multi-port cards.
 1.80  29-Apr-1996  christos - prototype fixes
 1.79  15-Apr-1996  cgd define and export the global variable "comconscflag", the default tty
'cflag' for the console. Normally set to TTYDEF_CFLAG, may be
overridden by machine-dependent console attachment code, as necessary.
(Alpha uses it to set cs8 -parenb.) Files including comvar.h now
need to include <sys/termios.h>, because comconscflag is of type
tcflag_t.
 1.78  11-Apr-1996  cgd update for addition of a machine-dependent cookie as the first argument
to isa_intr_{,dis}establish().
 1.77  17-Mar-1996  cgd Add #ifdef's at the right places, on NCOM_ISA and NCOM_COMMULTI, to
only include the relevant code in the probe & attach functions. Still
one probe and one attach function, with #ifdefs, but this is a step
in the right direction and saves a few hundred bytes (ooh, ahh!).
 1.76  17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.75  10-Mar-1996  cgd convert these to use new <machine/bus.h> interfaces. This involved
substantial reworking of the multi-port drivers, as they need to frob
bits in the io-port spaces of their children. As a result, the
commulti->com attachment interface is substantially more complex.
(This may be fixable in the future by making some of the code common,
but as long as io-port allocation checking is planned, it's necessary.)
 1.74  09-Mar-1996  cgd include comvar.h for comprobe1() prototype
 1.73  26-Feb-1996  scottr Fix typo (PR 2123, from Michael VanLoon)
 1.72  20-Feb-1996  mycroft Add more debugging code.
 1.71  19-Feb-1996  mycroft Update copyright notice.
 1.70  19-Feb-1996  mycroft Set IER_ETXRDY before outputting any bytes, to prevent race condition.
 1.69  19-Feb-1996  mycroft Handle break more correctly.
Make IER_ETXRDY track TS_BUSY. (Prevents a loop in comintr() if no output
is available.)
Add a bunch of debugging code.
 1.68  18-Feb-1996  mycroft Fix a race condition where we might stop outputting if a write follows a
flush too closely.
 1.67  17-Feb-1996  mycroft Add some text describing the UART lossage worked around in the previous.
 1.66  17-Feb-1996  mycroft Drain the transmitter FIFO before changing the baud rate or FIFO depth
registers. Fixes PR 2046.
Also, if COMCONSOLE is defined, expect CONSPEED to be the baud rate.
 1.65  10-Feb-1996  christos Hayes ESP patches [from PR database]
 1.64  14-Jan-1996  christos Hayes ESP support from Michael Van Loon, with minor cleanups. Tested on
a single port ESP card; works great!
 1.63  24-Dec-1995  mycroft The IST_* and IPL_* constants are not bus-specific; don't treat them as such.
Change splimp -> splnet in Ethernet, ARCnet, and FDDI drivers.
 1.62  15-Oct-1995  mycroft Use SET(), CLR(), and ISSET() macros.
Rename CFCR to LCR, and cache its value.
Check MSR before transmitting, for better flow control.
Preserve LCR_SBREAK inside comparam().
 1.61  04-Jul-1995  mycroft Fix a condition where ttywait() wouldn't be woken up. Also, short-circuit
the case of no pending input in compoll().
 1.60  28-Jun-1995  cgd note that most of dev/ic's contents have changed names
 1.59  05-Jun-1995  mycroft Various:
* Check for CTS in the correct register.
* Only do a selwakeup() if we output something.
* Don't make assumptions about what TTYDISC does.
 1.58  04-Jun-1995  mycroft Handle BREAK correctly when not entering DDB.
 1.57  04-Jun-1995  mycroft Add an input FIFO, and fix several flow control problems. Based on code from
Felix A. Croes.
 1.56  01-Jun-1995  jtc Changed ns82450 to ns8250 and dropped ns82550 from probe console messages.
 1.55  28-May-1995  mycroft Only use the `no pending interrupt' bit in the IIR; the other bits
are too unreliable on clone chips.
 1.54  12-May-1995  cgd (1) conditionalize debugger usage in comeint with DDB, not COMCONSOLE;
latter would lead to undefined symbols if DDB not defined.
(2) check for break on console, and therefore debugger entry (if ddb
in kernel) earlier, so that the device doesn't need to be open.
(3) return immediately after breaking into the debugger in comeint().
(4) only do the normal character input routine in comintr if receive
mask yeilds _EXACLTY_ LSR_RXRDY. if there's only a receive
error, or there's a receive error _and_ a received character,
do comeint().
(former two by me. latter two from Bob Baron <rvb@cs.cmu.edu>.)
 1.53  28-Apr-1995  hpeyerl <break> --> ddb if defined(comconsole).
(if you have a serial console and you hit break, you get ddb).
 1.52  19-Apr-1995  mycroft Fix thinko in previous change.
 1.51  19-Apr-1995  mycroft Garbage collect #includes.
 1.50  19-Apr-1995  mycroft Implement comtty().
 1.49  17-Apr-1995  cgd clean up several ISA device interfaces: autoconfiguration, header
inclusion, and interrupt configuration. more work still needs to be done,
but it's getting better...
 1.48  10-Apr-1995  mycroft Most of the console functions return void. Also change interrupt logic
slightly.
 1.47  29-Jan-1995  cgd lip service to making ISA support machine-independent. This is the first
round: moving the drivers into a machine-independent directory.
Some drivers (e.g. fd.c) not moved because they use other pc features (e.g.
CMOS settings), and none of the non-driver files moved, because they're
still pretty much PC specific. eventually (when other ports with ISA
busses really start using this code), more 'high-level' ISA support will
live here.
 1.46  29-Jan-1995  cgd use chip headers in /dev/ic
 1.45  11-Jan-1995  pk Explicitly test the RXRDY status bit on incoming characters.
 1.44  04-Jan-1995  mycroft Fix oversight in previous.
 1.43  03-Jan-1995  mycroft Add interrupt sharing types.
 1.42  25-Nov-1994  mycroft Minor update for new autoconfig.
 1.41  18-Nov-1994  mycroft Convert port, IRQ, and DRQ numbers to ints.
 1.40  03-Nov-1994  mycroft Update to match autoconfig code.
 1.39  30-Oct-1994  cgd be more careful with types, also pull in headers where necessary.
 1.38  27-Oct-1994  cgd new RCS ID format.
 1.37  26-Oct-1994  mycroft Implement *cnpollc().
 1.36  16-Sep-1994  mycroft Only reset FIFO if changing baud rate. From John Kohl (slightly edited).
 1.35  24-Aug-1994  mycroft Set the FIFO threshold based on the receive speed, per Mark Weaver.
 1.34  21-Aug-1994  mycroft Look for MDMBUF in cflag, not lflag.
 1.33  07-Aug-1994  mycroft Count up the silo overflows and only log a warning at most once per minute.
 1.32  31-Jul-1994  mycroft Bug fixes from Mark Weaver.
 1.31  10-Apr-1994  cgd branches: 1.31.2;
allow MDMBUF flags to be set (oops)
 1.30  07-Apr-1994  mycroft Implement dynamic IRQ configuration and IRQ sharing. Inline spl*() calls.
Reorganize and clean up the relevant code.
 1.29  29-Mar-1994  mycroft Updates for new autoconfig.
 1.28  25-Mar-1994  mycroft Fix off-by-one error in comopen() unit number sanity check. From Brian de
Alwis.
 1.27  23-Mar-1994  mycroft Some stylistic cleanup, and a very minor speedup.
 1.26  23-Mar-1994  cgd add AST-style serial multiport support, from Roland McGrath
<roland@@frob.com>. Needs light clean by Mr. I386, but mostly
OK. For some reason, Bad Things (TM) happened on the last cvs commit.
 1.25  18-Mar-1994  cgd add reasonable support for MDMBUF output flow control. input to be done later
 1.24  12-Mar-1994  cgd copy appropriate hardware config bits from config's flags
 1.23  12-Mar-1994  cgd fix some of the last; thanks to charles for looking it over...
 1.22  12-Mar-1994  cgd support new ioctls. fix the way CRTSCTS is used, etc. Seperate 'hardware'
and 'software' flags. beginnings of multiport support.
 1.21  08-Mar-1994  mycroft Major cleanup and many bugs fixed; based in part on Brad Huntting's version
for BSD/386. More to be done when the low-level interrupt system is replaced.
 1.20  06-Mar-1994  mycroft DELAY() --> delay(). This is not a macro.
 1.19  09-Feb-1994  mycroft All ioctl routines take a struct proc * now.
 1.18  01-Feb-1994  cgd oops
 1.17  01-Feb-1994  cgd new cons.h location, etc.
 1.16  30-Jan-1994  ws Traditional behaviour is to reset all modes if device isn't open already
 1.15  13-Jan-1994  mycroft Junk comselect(); it's the same at ttselect().
 1.14  20-Dec-1993  mycroft Canonicalize all #includes, and add pio.h where appropriate.
 1.13  29-Sep-1993  cgd ifdef out the ttyfree()'s, so that fill_eproc doesn't panic when
a process's session still holds a ref to a tty which has been deallocated
and reused.
 1.12  29-Aug-1993  deraadt branches: 1.12.2;
tty XXstart() routines return void
 1.11  12-Jul-1993  mycroft Change tty code to use clist interface, but with ring buffer implementation.
Also, fix a couple of bugs in tty.c and pccons.c, and some gross kluginess
in the hp300 stuff.
 1.10  07-Jul-1993  deraadt pccons.c now dynamically allocates it's "struct tty"
cons.c's "struct tty *cn_tty" wasn't used by any of the kernel, and goes away.
 1.9  06-Jun-1993  cgd make getc() and ungetc() be rb{un,}getc(), so getc() and ungetc()
don't conflict w/ansi prototypes...
 1.8  26-May-1993  deraadt tty dynamic allocation
 1.7  18-May-1993  cgd make kernel select interface be one-stop shopping & clean it all up.
 1.6  10-Apr-1993  glass fixed to be compliant, subservient, and to take advantage of the newly
hacked config(8)
 1.5  09-Apr-1993  cgd have probe return size of io space on successful return, rather
than simply 1.
 1.4  08-Apr-1993  deraadt dmesg output at boottime now tries to print out information as
soon as it is available. The output looks much more like Sunos.
 1.3  27-Mar-1993  cgd moved closing #endif to include comselect
 1.2  21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.12.2.17  01-Feb-1994  mycroft Updates from main branch.
 1.12.2.16  29-Oct-1993  mycroft Minor cleanup.
 1.12.2.15  29-Oct-1993  mycroft c_cflag is a tcflag_t, not a u_char. (Duh.)
 1.12.2.14  18-Oct-1993  mycroft Fix a small typo.
 1.12.2.13  18-Oct-1993  mycroft Check bits in the fifo reg during probe to make sure they are on.
 1.12.2.12  17-Oct-1993  mycroft Minor cleanup.
 1.12.2.11  16-Oct-1993  mycroft Add missing dv_class entry to cfdrivers, and use dv_xname where appropriate.
 1.12.2.10  15-Oct-1993  mycroft Nuke a wakeup() I left in accidentally.
 1.12.2.9  15-Oct-1993  mycroft Flush any pending I/O on open. After a transmit interrupt, don't call
comstart() if TS_FLUSH is set.
 1.12.2.8  13-Oct-1993  mycroft Use stupid indirection to avoid a compiler warning.
 1.12.2.7  12-Oct-1993  mycroft Minor cleanup.
 1.12.2.6  11-Oct-1993  mycroft #include pio.h where needed, and remove cpufunc.h.
 1.12.2.5  07-Oct-1993  mycroft Don't #include isa.h.
 1.12.2.4  06-Oct-1993  mycroft Change comforceintr() to not use loopback. Change attach messages.
 1.12.2.3  30-Sep-1993  mycroft Change some uses of IRQUNK to IRQNONE. #include isa.h and icu.h.
 1.12.2.2  30-Sep-1993  mycroft clock.c: Remove unnecessary casts.
com.c: Update for new config. Add bis() and bic() macros like BSDI's.
Add comspeed() and tiocm_xxx2mcr() from BSDI.
comreg.h: Add COM_FREQ, COM_TOLERANCE, and COM_NPORTS.
fd.c: Remove casts and clean up fdioctl().
[lm]ms.c: Add necessary gunk to [lm]ms_softc and remove casts.
 1.12.2.1  14-Sep-1993  mycroft New i386 code.
 1.31.2.5  16-Sep-1994  cgd from trunk.
 1.31.2.4  24-Aug-1994  mycroft update from trunk
 1.31.2.3  21-Aug-1994  mycroft update from trunk
 1.31.2.2  07-Aug-1994  mycroft update from trunk
 1.31.2.1  01-Aug-1994  cgd From trunk.
 1.82.4.3  16-Feb-1997  rat Patch supplied by Charles Hannmum.
 1.82.4.2  10-Dec-1996  mycroft From trunk:
Set serial port parameters sanely for a serial console.
 1.82.4.1  02-Jun-1996  mrg pull up tty stats "bug fix".
 1.102.2.4  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.102.2.3  22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.102.2.2  27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.102.2.1  23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.113.2.2  16-Oct-1997  thorpej Sync w/ trunk.
 1.113.2.1  16-Oct-1997  thorpej file com.c was added on branch marc-pcmcia on 1997-10-16 00:04:07 +0000
 1.118.2.5  05-May-1998  mycroft Pull up 1.136-1.138, per request of scottr.
 1.118.2.4  17-Dec-1997  mellon Pull rev 1.129 up from trunk (mycroft)
 1.118.2.3  04-Nov-1997  mellon Pull up rev 1.120 through 1.128 (mycroft)
 1.118.2.2  30-Oct-1997  mellon Pull rev 1.119 up from trunk (drochner)
 1.118.2.1  21-Oct-1997  mellon file com.c was added on branch netbsd-1-3 on 1997-10-30 23:22:55 +0000
 1.159.2.4  08-Feb-2000  he Pull up revisions 1.167-1.168 (requested by jonathan):
Properly catch PPS signals on DCD transitions, even if DCD is
otherwise ignored.
 1.159.2.3  20-Jan-2000  he Pull up revisions 1.162-1.163 (requested by jonathan):
Fix TIMEVAL/TIMESPEC botches and update to the -05 draft version
of the PPS-API specification.
 1.159.2.2  05-Jan-2000  he Pull up revision 1.165 (requested by drochner):
Set carrier early enough for a serial console or kgdb to work
with hardware handshake. Fixes PR#6547.
 1.159.2.1  19-Apr-1999  perry branches: 1.159.2.1.2;
pullup 1.159->1.161 -- requested by ross. apparently fixes critical bugs on
a number of ports.
 1.159.2.1.2.1  21-Jun-1999  thorpej Sync w/ -current.
 1.161.2.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.162.4.1  15-Nov-1999  fvdl Sync with -current
 1.162.2.3  18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.162.2.2  22-Nov-2000  bouyer Sync with HEAD.
 1.162.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.183.2.11  11-Nov-2002  nathanw Catch up to -current
 1.183.2.10  17-Sep-2002  nathanw Catch up to -current.
 1.183.2.9  01-Aug-2002  nathanw Catch up to -current.
 1.183.2.8  17-Apr-2002  nathanw Catch up to -current.
 1.183.2.7  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.183.2.6  08-Jan-2002  nathanw Catch up to -current.
 1.183.2.5  14-Nov-2001  nathanw Catch up to -current.
 1.183.2.4  21-Sep-2001  nathanw Catch up to -current.
 1.183.2.3  24-Aug-2001  nathanw Catch up with -current.
 1.183.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.183.2.1  05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.186.2.6  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.186.2.5  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.186.2.4  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.186.2.3  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.186.2.2  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.186.2.1  25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.188.2.5  13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.188.2.4  01-Oct-2001  fvdl Catch up with -current.
 1.188.2.3  26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.188.2.2  18-Sep-2001  fvdl Various changes to make cloning devices possible:

* Add an extra argument (struct vnode **) to VOP_OPEN. If it is
not NULL, specfs will create a cloned (aliased) vnode during
the call, and return it there. The caller should release and
unlock the original vnode if a new vnode was returned. The
new vnode is returned locked.

* Add a flag field to the cdevsw and bdevsw structures.
DF_CLONING indicates that it wants a new vnode for each
open (XXX is there a better way? devprop?)

* If a device is cloning, always call the close entry
point for a VOP_CLOSE.


Also, rewrite cons.c to do the right thing with vnodes. Use VOPs
rather then direct device entry calls. Suggested by mycroft@

Light to moderate testing done an i386 system (arch doesn't matter
though, these are MI changes).
 1.188.2.1  07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.189.2.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.196.4.1  06-Apr-2004  tron Pull up revision 1.225 (requested by enami in ticket #1658):
Fix race condition introduced in rev 1.189; after the change, if there is
THRE interrupt occurs between the LSR read and IIR read, we won't see the
LSR_TXRDY bit when testing it in the variable `lsr' and we don't interrupted
again (as the corresponding bit in the IIR is cleared by reading, except
for some broken device).
Tested by Matthias Scheler and me, reviewed by Allen Briggs.
Closes PR#25010.
 1.196.2.2  29-Aug-2002  gehenna catch up with -current.
 1.196.2.1  16-May-2002  gehenna Add the character device switch.
Replace the access to devsw table with calling devsw API.
 1.216.2.7  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.216.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.216.2.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.216.2.4  18-Sep-2004  skrll Sync with HEAD.
 1.216.2.3  12-Aug-2004  skrll Sync with HEAD.
 1.216.2.2  03-Aug-2004  skrll Sync with HEAD
 1.216.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.224.2.2  05-Jul-2004  he branches: 1.224.2.2.2;
Pull up revisions 1.228-1.230 (requested by mycroft in ticket #603):
Incorporate 4 changes:
o At high speed, set the FIFO trigger to a higher
value to reduce interrupt load. Fixes PR#15448.
o Handle the case of IIR=RXRDY and LSR=!LSR_RCV_MASK
differently, to avoid a hang with some chips. Fixes
PR#21184, and possibly PR#10974 and PR#8248.
o Remove the extra wait at the end of com_common_putc(),
after writing a character out, so that we get another
TXRDY interrupt. This prevents stalls when normal
output and kernel output are mixed. Fixes PR#4263.
o Do not ``preload'' the TX FIFO; wait for a TXRDY
interrupt to come in after enabling it.
 1.224.2.1  06-Apr-2004  jmc Pullup rev 1.225 (requested by enami in ticket #70)

Fix race condition introduced in rev 1.189; after the change, if there is
THRE interrupt occurs between the LSR read and IIR read, we won't see the
LSR_TXRDY bit when testing it in the variable 'lsr' and we don't get
interrupted again (as the corresponding bit in the IIR is cleared by reading,
except for some broken devices). PR#25010
 1.224.2.2.2.1  01-Dec-2007  bouyer Pull up following revision(s) (requested by is in ticket #11394):
sys/dev/ic/com.c: revision 1.233
Revert the part of revision 1.228 that made HW_NO_TXPRELOAD the default:
it appears to break output on the Soekris net4501, which is a rather
popular platform.
This should fix PR kern/29612.
 1.231.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.231.4.1  29-Apr-2005  kent sync with -current
 1.232.2.1  01-Dec-2007  bouyer Pull up following revision(s) (requested by is in ticket #1882):
sys/dev/ic/com.c: revision 1.233
Revert the part of revision 1.228 that made HW_NO_TXPRELOAD the default:
it appears to break output on the Soekris net4501, which is a rather
popular platform.
This should fix PR kern/29612.
 1.234.2.9  17-Mar-2008  yamt sync with head.
 1.234.2.8  04-Feb-2008  yamt sync with head.
 1.234.2.7  21-Jan-2008  yamt sync with head
 1.234.2.6  07-Dec-2007  yamt sync with head
 1.234.2.5  27-Oct-2007  yamt sync with head.
 1.234.2.4  03-Sep-2007  yamt sync with head.
 1.234.2.3  26-Feb-2007  yamt sync with head.
 1.234.2.2  30-Dec-2006  yamt sync with head.
 1.234.2.1  21-Jun-2006  yamt sync with head.
 1.239.2.2  01-Mar-2006  yamt sync with head.
 1.239.2.1  15-Jan-2006  yamt sync with head.
 1.240.4.3  01-Jun-2006  kardel Sync with head.
 1.240.4.2  22-Apr-2006  simonb Sync with head.
 1.240.4.1  04-Feb-2006  simonb Adapt for timecounters and newer PPS API.
 1.240.2.1  09-Sep-2006  rpaulo sync with head
 1.241.6.2  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.241.6.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.241.4.3  19-Apr-2006  elad sync with head.
 1.241.4.2  10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.241.4.1  08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.241.2.4  11-Aug-2006  yamt sync with head
 1.241.2.3  26-Jun-2006  yamt sync with head.
 1.241.2.2  24-May-2006  yamt sync with head.
 1.241.2.1  01-Apr-2006  yamt sync with head.
 1.243.2.1  19-Jun-2006  chap Sync with head.
 1.244.2.6  13-Jul-2006  gdamore Merge from HEAD.
 1.244.2.5  17-Jun-2006  gdamore Yes, I'm restoring COM_INIT_REGS and removing the compatibility #define's
for sc_iot and friends. Those defines break things, like say ast.c, where
comvar.h is included, but a local sc_iot structure member is also used.
 1.244.2.4  17-Jun-2006  gdamore Per tsutsui@, I'm removing COM_INIT_REGS, and adding a flag to make the
map initialization automatic. This breaks this whole tree again, so I pretty
much have to start over going back thru old code to make it all compatible.
 1.244.2.3  16-Jun-2006  gdamore KNF per simonb@ consisting of:
regs.xx -> regs.cr_xxx
wrap COM_INIT_REGS body with do { } while (0);)
Convert INB/OUTB macros to CSR_READ/CSR_WRITE macros per tsutsui@.
 1.244.2.2  15-Jun-2006  gdamore Fix a type where comconsregs was defined twice, and comkgdregs was missing.
Thanks to simonb@ Doh!
 1.244.2.1  15-Jun-2006  gdamore Initial com framework changes. These changes bust *all* com consumers, but
follow-up commits shortly will fix many of them, so that i386, sparc, and
some evbmips ports at least work.
 1.250.2.1  07-Sep-2006  riz Pull up following revision(s) (requested by martin in ticket #118):
sys/dev/ic/com.c: revision 1.251
fix a GCC uninitialised variable warning only seen at -O3.
 1.251.4.2  10-Dec-2006  yamt sync with head.
 1.251.4.1  22-Oct-2006  yamt sync with head
 1.251.2.2  12-Jan-2007  ad Sync with head.
 1.251.2.1  18-Nov-2006  ad Sync with head.
 1.258.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.259.4.1  11-Jul-2007  mjf Sync with head.
 1.259.2.3  23-Oct-2007  ad Sync with head.
 1.259.2.2  01-Jul-2007  ad - Generic soft interrupts are mandatory, remove the kludges.
- Adapt to callout API change.
- Use mutexes.
 1.259.2.1  17-Jun-2007  ad - Increase the number of thread priorities from 128 to 256. How the space
is set up is to be revisited.
- Implement soft interrupts as kernel threads. A generic implementation
is provided, with hooks for fast-path MD code that can run the interrupt
threads over the top of other threads executing in the kernel.
- Split vnode::v_flag into three fields, depending on how the flag is
locked (by the interlock, by the vnode lock, by the file system).
- Miscellaneous locking fixes and improvements.
 1.261.6.4  09-Dec-2007  jmcneill Sync with HEAD.
 1.261.6.3  21-Nov-2007  joerg Sync with HEAD.
 1.261.6.2  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.261.6.1  03-Sep-2007  jmcneill Sync with HEAD.
 1.261.2.1  03-Sep-2007  skrll Sync with HEAD.
 1.262.4.2  18-Oct-2007  yamt sync with head.
 1.262.4.1  14-Oct-2007  yamt sync with head.
 1.262.2.4  23-Mar-2008  matt sync with HEAD
 1.262.2.3  09-Jan-2008  matt sync with HEAD
 1.262.2.2  06-Nov-2007  matt sync with HEAD
 1.262.2.1  29-Oct-2007  matt Add support for OMAP specific com type.
 1.264.2.2  21-Nov-2007  bouyer Sync with HEAD
 1.264.2.1  25-Oct-2007  bouyer Sync with HEAD.
 1.265.2.3  18-Feb-2008  mjf Sync with HEAD.
 1.265.2.2  27-Dec-2007  mjf Sync with HEAD.
 1.265.2.1  08-Dec-2007  mjf Sync with HEAD.
 1.266.2.2  26-Dec-2007  ad Sync with head.
 1.266.2.1  08-Dec-2007  ad Sync with head.
 1.267.4.3  23-Jan-2008  bouyer Sync with HEAD.
 1.267.4.2  08-Jan-2008  bouyer Sync with HEAD
 1.267.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.272.6.4  17-Jan-2009  mjf Sync with HEAD.
 1.272.6.3  28-Sep-2008  mjf Sync with HEAD.
 1.272.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.272.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.272.2.1  24-Mar-2008  keiichi sync with head.
 1.278.2.1  18-May-2008  yamt sync with head.
 1.279.2.5  11-Aug-2010  yamt sync with head.
 1.279.2.4  11-Mar-2010  yamt sync with head
 1.279.2.3  16-May-2009  yamt sync with head
 1.279.2.2  04-May-2009  yamt sync with head.
 1.279.2.1  16-May-2008  yamt sync with head.
 1.281.6.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.281.6.1  19-Oct-2008  haad Sync with HEAD.
 1.281.4.1  18-Jul-2008  simonb Sync with head.
 1.281.2.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.286.14.1  07-Jan-2011  matt Let's cons.c poll and so don't loop until a chacater becomes available.
 1.286.10.2  20-May-2011  matt Fix early boot on AU1x type com ports.
 1.286.10.1  13-Sep-2009  cliff when attaching com, (frequency == -1) means leave the BRG divisor as-is
(inherit values established by firmware)
 1.286.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.287.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.294.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.294.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.295.2.3  31-May-2011  rmind sync with head
 1.295.2.2  05-Mar-2011  rmind sync with head
 1.295.2.1  30-May-2010  rmind sync with head
 1.298.4.1  08-Feb-2011  bouyer Sync with HEAD
 1.298.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.301.4.4  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.301.4.3  23-Jan-2013  yamt sync with head
 1.301.4.2  23-May-2012  yamt sync with head.
 1.301.4.1  17-Apr-2012  yamt sync with head
 1.303.2.3  02-Jun-2012  mrg sync to latest -current.
 1.303.2.2  29-Apr-2012  mrg sync to latest -current.
 1.303.2.1  18-Feb-2012  mrg merge to -current.
 1.304.2.1  22-Apr-2012  riz Pull up following revision(s) (requested by christos in ticket #190):
sys/dev/ic/com.c: revision 1.305
don't include<sys/rnd.h> before we define cn_trap, because it might bring
in<sys/systm.h>
 1.306.2.4  03-Dec-2017  jdolecek update from HEAD
 1.306.2.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.306.2.2  23-Jun-2013  tls resync from head
 1.306.2.1  25-Feb-2013  tls resync with head
 1.310.4.2  18-May-2014  rmind sync with head
 1.310.4.1  28-Aug-2013  rmind sync with head
 1.323.2.2  10-Aug-2014  tls Rebase.
 1.323.2.1  07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.327.2.1  22-Jun-2016  snj Pull up following revision(s) (requested by bouyer in ticket #1178):
sys/arch/arm/allwinner/files.awin: revision 1.36
sys/conf/files: revision 1.1159
sys/dev/ic/com.c: revision 1.339
sys/dev/ic/comreg.h: revision 1.25
sys/dev/ic/comvar.h: revision 1.82
sys/dev/ic/ns16550reg.h: revision 1.11
The UART in the allwiner SoCs is not full-compatible with the 16550, and
it's not a 16750 either. Like the 16750 it has the IIR_BUSY interrupt,
which is triggered when writing to LCR while the chip
can't accept it. But unlike the 16750, it has a specific register,
HALT, to allow writing to the LCR and divisor registers, and then
commit the changes.
Tested on an A20 SoC, changing the baud rate while keeping the
tty device open and incoming data.
 1.329.2.5  28-Aug-2017  skrll Sync with HEAD
 1.329.2.4  29-May-2016  skrll Sync with HEAD
 1.329.2.3  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.329.2.2  06-Jun-2015  skrll Sync with HEAD
 1.329.2.1  06-Apr-2015  skrll Sync with HEAD
 1.339.10.1  06-Nov-2017  snj Pull up following revision(s) (requested by martin in ticket #338):
sys/arch/sparc64/dev/sab.c: revision 1.55
sys/dev/ic/com.c: revision 1.345
sys/dev/ic/z8530tty.c: revision 1.132
sys/dev/sun/sunkbd.c: revision 1.30
sys/dev/sun/sunms.c: revision 1.33
sys/sys/tty.h: revision 1.94
As discussed on tech-kern: define a new tty internal state flag: TS_KERN_ONLY
Implement it in a few tty drivers. If this flag is set, the underlying
hardware is used by another driver and userland has no right to open
it. A few uses will appear soon in sys/dev/sun/sun{kbd,ms}.c.
--
PR port-sparc64/52622: mark the parent device as TS_KERN_ONLY,
so userland will not touch it (and change serial params w/o our
control).
 1.346.2.4  18-Jan-2019  pgoyette Synch with HEAD
 1.346.2.3  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.346.2.2  25-Jun-2018  pgoyette Sync with HEAD
 1.346.2.1  16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.348.2.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.348.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.348.2.1  10-Jun-2019  christos Sync with HEAD
 1.356.2.1  29-Feb-2020  ad Sync with head.
 1.361.4.1  03-Apr-2021  thorpej Sync with HEAD.
 1.361.2.1  03-Apr-2021  thorpej Sync with HEAD.
 1.363.2.1  01-Aug-2021  thorpej Sync with HEAD.

RSS XML Feed