History log of /netbsd-current/sys/dev/ic/com.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 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.


Revision tags: netbsd-10-base
# 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.


Revision tags: bouyer-sunxi-drm-base
# 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: bouyer-sunxi-drm-base
# 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: bouyer-sunxi-drm-base
# 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: bouyer-sunxi-drm-base
# 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: bouyer-sunxi-drm-base
# 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: bouyer-sunxi-drm-base
# 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.363 25-Mar-2021 rin

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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.363 25-Mar-2021 rin

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.


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.361 30-Sep-2020 jmcneill

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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.361 30-Sep-2020 jmcneill

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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.358 01-May-2020 simonb

Get rid of needless __predict_true() and move a comment slightly.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.357 01-Feb-2020 skrll

Use designated initializers


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.356 10-Nov-2019 chs

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.


Revision tags: netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.356 10-Nov-2019 chs

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.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

branches: 1.348.2;
Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 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).


Revision tags: pgoyette-compat-1226
# 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


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.348 27-May-2018 jmcneill

Rename COM_TYPE_SUNXI -> COM_TYPE_DW_APB


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.347 08-Apr-2018 jmcneill

Remove COM_AWIN option


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.346 04-Dec-2017 bouyer

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.


Revision tags: tls-maxphys-base-20171202
# 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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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!


Revision tags: nick-nhusb-base-20170825
# 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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.339 27-May-2016 bouyer

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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.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.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.339 27-May-2016 bouyer

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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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.340 31-Jul-2017 jmcneill

Add COM_TYPE_BCMAUXUART type for BCM2835 AUX UART.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.339 27-May-2016 bouyer

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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.339 27-May-2016 bouyer

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.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 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.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 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>.


Revision tags: nick-nhusb-base-20150406
# 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


Revision tags: nick-nhusb-base
# 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.327 10-Aug-2014 tls

branches: 1.327.2;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 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.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 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


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 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.


Revision tags: agc-symver-base
# 1.308 24-Feb-2013 matt

Initialize t_softc.


Revision tags: yamt-pagecache-base8
# 1.307 10-Jan-2013 macallan

don't try to become console if we get is_console=false as device property


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.306 21-May-2012 skrll

branches: 1.306.2;
Remove empty line.


Revision tags: jmcneill-usbmp-base9
# 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>


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 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


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
# 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@


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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.


Revision tags: uebayasi-xip-base1
# 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.


Revision tags: yamt-nfs-mp-base9
# 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.


Revision tags: uebayasi-xip-base
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 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)


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base mjf-devfs2-base
# 1.287 03-Jan-2009 yamt

branches: 1.287.2;
remove extra semicolons.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base haad-dm-base
# 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.


Revision tags: matt-mips64-base2
# 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.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.282 14-Jul-2008 matt

Remove OMAP gunk in com_activate, it's not needed.

Spotted by Matthias Drochner.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 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


Revision tags: yamt-nfs-mp-base
# 1.279 21-Apr-2008 ad

branches: 1.279.2;
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 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.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase
# 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.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.269 05-Jan-2008 ad

Work around com hangs with pcmcia. PR kern/37462.


Revision tags: vmlocking2-base3
# 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.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 1.265 19-Oct-2007 ad

branches: 1.265.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4
# 1.264 17-Oct-2007 ad

branches: 1.264.2;
Reapply rev 1.262 and add a comment about it.


Revision tags: yamt-x86pmap-base3 vmlocking-base
# 1.263 08-Oct-2007 ad

Merge from vmlocking: use mutexes and the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 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.


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.261 14-Jul-2007 ad

branches: 1.261.2; 1.261.6;
Generic soft interrupts are mandatory.


Revision tags: mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 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.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.258 10-Jan-2007 cube

branches: 1.258.2;
Make COM_HAYESP compile again. It assumes no register mapping is needed.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.256 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 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@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.251 08-Aug-2006 mrg

branches: 1.251.2; 1.251.4;
fix a GCC uninitialised variable warning only seen at -O3.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: yamt-pdpolicy-base6
# 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.


Revision tags: chap-midi-nbase gdamore-uart-base chap-midi-base
# 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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.243 14-May-2006 elad

branches: 1.243.2;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base
# 1.242 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 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)


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.232 27-Feb-2005 perry

branches: 1.232.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 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.


Revision tags: netbsd-2-0-base
# 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_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.201 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge
# 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


Revision tags: kqueue-beforemerge kqueue-base
# 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.


Revision tags: gehenna-devsw-base
# 1.198 29-Jul-2002 simonb

Don't name parameters in a function declaration.


# 1.197 29-Jul-2002 simonb

ANSIfy, KNF.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: eeh-devprop-base
# 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.


Revision tags: newlock-base ifpoll-base
# 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


Revision tags: thorpej-mips-cache-base
# 1.190 05-Nov-2001 fvdl

Initialize the cn_magic goo for kgdb (bah, that should really not
be necessary).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 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.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 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.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 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().


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 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.


Revision tags: chs-ubc2-newbase
# 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).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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


Revision tags: fvdl-softdep-base
# 1.163 04-Nov-1999 jonathan

Update user-level PPS-API to match -05 draft.
Change PPS_<xxx> ioctls to PPS_IOC_<xxx>.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: chs-ubc2-base
# 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().


Revision tags: netbsd-1-4-base
# 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


Revision tags: kenh-if-detach-base
# 1.149 18-Nov-1998 thorpej

Add support for detaching "com" instances.


Revision tags: chs-ubc-base
# 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.


Revision tags: eeh-paddr_t-base
# 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)


Revision tags: netbsd-1-3-base
# 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.


Revision tags: marc-pcmcia-base
# 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