History log of /freebsd-current/sys/dev/puc/puc.c
Revision Date Author Comments
# 9dbf5b0e 13-Mar-2024 John Baldwin <jhb@FreeBSD.org>

new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCE

The public bus_release_resource() API still accepts both forms, but
the internal kobj method no longer passes the arguments.
Implementations which need the rid or type now use rman_get_rid() or
rman_get_type() to fetch the value from the allocated resource.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44131


# fdafd315 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 09e5d910 24-Jul-2023 Mitchell Horne <mhorne@FreeBSD.org>

puc: fix man page reference

The reference to puc(9) is wrong; the page does not exist, and drivers
belong to section 4. Change the reference to puc(4), which does exist.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# bab8274c 25-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Use bool for one-bit wide bit-fields

A signed one-bit wide bit-field can take only the values 0 and -1. Clang
16 introduced a warning that "implicit truncation from 'int' to a
one-bit wide bit-field changes value from 1 to -1". Fix the warnings by
using C99 bool.

Reported by: Clang 16
Reviewed by: emaste, jhb
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D39705


# 55771d1c 06-May-2022 John Baldwin <jhb@FreeBSD.org>

puc: Remove unused devclass argument to DRIVER_MODULE.


# ddfc9c4c 22-Jun-2021 Warner Losh <imp@FreeBSD.org>

newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf

Now that the upper layers all go through a layer to tie into these
information functions that translates an sbuf into char * and len. The
current interface suffers issues of what to do in cases of truncation,
etc. Instead, migrate all these functions to using struct sbuf and these
issues go away. The caller is also in charge of any memory allocation
and/or expansion that's needed during this process.

Create a bus_generic_child_{pnpinfo,location} and make it default. It
just returns success. This is for those busses that have no information
for these items. Migrate the now-empty routines to using this as
appropriate.

Document these new interfaces with man pages, and oversight from before.

Reviewed by: jhb, bcr
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29937


# 7029da5c 26-Feb-2020 Pawel Biernacki <kaktus@FreeBSD.org>

Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)

r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE. All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by: kib (mentor, blanket)
Commented by: kib, gallatin, melifaro
Differential Revision: https://reviews.freebsd.org/D23718


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# d3bf5efc 17-Oct-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix device delete child function.

When detaching device trees parent devices must be detached prior to
detaching its children. This is because parent devices can have
pointers to the child devices in their softcs which are not
invalidated by device_delete_child(). This can cause use after free
issues and panic().

Device drivers implementing trees, must ensure its detach function
detaches or deletes all its children before returning.

While at it remove now redundant device_detach() calls before
device_delete_child() and device_delete_children(), mostly in
the USB controller drivers.

Tested by: Jan Henrik Sylvester <me@janh.de>
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D8070
MFC after: 2 weeks


# 82ed3cb0 01-Mar-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Replace some more default range checks with RMAN_IS_DEFAULT_RANGE().

This is a follow-on to r295832.


# 2dd1bdf1 26-Jan-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Convert rman to use rman_res_t instead of u_long

Summary:
Migrate to using the semi-opaque type rman_res_t to specify rman resources. For
now, this is still compatible with u_long.

This is step one in migrating rman to use uintmax_t for resources instead of
u_long.

Going forward, this could feasibly be used to specify architecture-specific
definitions of resource ranges, rather than baking a specific integer type into
the API.

This change has been broken out to facilitate MFC'ing drivers back to 10 without
breaking ABI.

Reviewed By: jhb
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5075


# 9725900b 13-Mar-2014 Ryan Stone <rstone@FreeBSD.org>

Add MSI support to puc(9)

Add support for MSI interrupts in the puc(9) driver. By default the driver
will prefer MSI interrupts to legacy interrupts. A tunable,
hw.puc.msi_disable, has been added to force the allocation of legacy
interrupts.

Reviewed by: jhb@
MFC after: 2 weeks
Sponsored by: Sandvine Inc.


# 323e149a 15-Jan-2013 John Baldwin <jhb@FreeBSD.org>

Do not require a filter-only interrupt handler for puc ports that are not
serial devices (such as printer ports). This allows ppc devices attached
to puc to correctly setup an interrupt handler and work.

Tested by: Andre Albsmeier Andre.Albsmeier@siemens.com
MFC after: 1 week


# d745c852 06-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.

This means that their use is restricted to a single C file.


# 573e64d4 14-Jun-2011 John Baldwin <jhb@FreeBSD.org>

Add location and pnpinfo strings for puc device ports. The location is
announced during boot and contains the port number. The pnpinfo string
lists the port type (PUC_TYPE_* constants).

Tested by: Boris Samorodov bsam ipt ru
MFC after: 1 week


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# e88e64d3 14-Dec-2009 Marcel Moolenaar <marcel@FreeBSD.org>

MFC rev 200397:
Fix interrupt handling.

PR: kern/140947


# 57467e59 10-Dec-2009 Marcel Moolenaar <marcel@FreeBSD.org>

Fix interrupt handling. It started off broken and grew worse over time.
The rewrite of the interrupt handler includes:
o loop until all pending interrupts are handled. This closes a
race condition.
o count the number of interrupt sources we handled so that we can
properly return FILTER_HANDLED or FILTER_STRAY when we break out
of the loop.
o When matching the interrupt source to the devices that have that
source pending, check only from the set of devices we found to
have a pending interrupt.

PR: kern/140947
MFC after: 3 days


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 8d715a35 06-Jun-2007 Paolo Pisati <piso@FreeBSD.org>

-axe p_ih from struct puc_port cause it was useless
-correctly check for filter only handler

Reviewed by: marcel
Tested by: marcel


# ef544f63 22-Feb-2007 Paolo Pisati <piso@FreeBSD.org>

o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@


# 482aa6a3 29-Jun-2006 David E. O'Brien <obrien@FreeBSD.org>

Fix building with GCC 4.2: ensure types are defined before refering to them.


# 64220a7e 28-Apr-2006 Marcel Moolenaar <marcel@FreeBSD.org>

Rewrite of puc(4). Significant changes are:
o Properly use rman(9) to manage resources. This eliminates the
need to puc-specific hacks to rman. It also allows devinfo(8)
to be used to find out the specific assignment of resources to
serial/parallel ports.
o Compress the PCI device "database" by optimizing for the common
case and to use a procedural interface to handle the exceptions.
The procedural interface also generalizes the need to setup the
hardware (program chipsets, program clock frequencies).
o Eliminate the need for PUC_FASTINTR. Serdev devices are fast by
default and non-serdev devices are handled by the bus.
o Use the serdev I/F to collect interrupt status and to handle
interrupts across ports in priority order.
o Sync the PCI device configuration to include devices found in
NetBSD and not yet merged to FreeBSD.
o Add support for Quatech 2, 4 and 8 port UARTs.
o Add support for a couple dozen Timedia serial cards as found
in Linux.


# 3df4e47b 22-Feb-2006 John Baldwin <jhb@FreeBSD.org>

Use bus_setup_intr() rather than invoking BUS_SETUP_INTR() directly so that
puc still prints out [FAST] on Peter's box.


# 7417e80b 21-Nov-2005 John Baldwin <jhb@FreeBSD.org>

Don't enable PUC_FASTINTR by default in the source. Instead, enable it
via the DEFAULTS kernel configs. This allows folks to turn it that option
off in the kernel configs if desired without having to hack the source.
This is especially useful since PUC_FASTINTR hangs the kernel boot on my
ultra60 which has two uart(4) devices hung off of a puc(4) device.

I did not enable PUC_FASTINTR by default on powerpc since powerpc does not
currently allow sharing of INTR_FAST with non-INTR_FAST like the other
archs.


# 4a1f4e2a 07-Nov-2005 Craig Rodrigues <rodrigc@FreeBSD.org>

Eliminate tinderbox errors.


# 5eb2dd94 06-Nov-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Avoid trouble with PUC_FASTINTR if it is already defined.


# 42afc093 05-Nov-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Now that fast interrupts can be shared we can use them in puc.


# 64fd97df 28-Sep-2005 Poul-Henning Kamp <phk@FreeBSD.org>

puc(4) does strange things to resources in order to fool the
subdrivers to hook up.

It should probably be rewritten to implement a simple bus to which
the sub drivers attach using some kind of hint.

Until then, provide a couple of crutch functions with big warning
signs so it can survive the recent changes to struct resource.


# 11480c10 25-Sep-2005 Poul-Henning Kamp <phk@FreeBSD.org>

__RMAN_RESOURCE_VISIBLE not needed.


# c90ff9ce 04-Mar-2005 Marius Strobl <marius@FreeBSD.org>

- sparc64/fhc/fhc.c:
Change fhc(4) to use IRQ numbers instead of RIDs for allocating the
IRQs of children. This works similar to e.g. sbus(4), i.e. add the
IRQ resources as fully specified to the resource lists of the children,
allocate them like normal. When establishing the interrupt search the
interrupt maps of the children for a matching INO to determine which
map we need to write the fully specified interrupt number to and to
enable the mapping (before the RID was used to indicate which interrupt
map to use).

- dev/puc/puc.c:
Revert rev. 1.38, with the above change fhc(4) no longer needs special
treatment for allocating IRQs.

Thanks to: joerg for providing access to an E3500


# ad11db7c 25-Feb-2005 Marius Strobl <marius@FreeBSD.org>

Add a stopgap allowing puc(4) to allocate IRQs on fhc(4). Given that
both a scc(4) is under way and fhc(4) will be change to use INOs this
shouldn't stay in HEAD for too long but we need a MFC-able solution
for FreeBSD 5.4.

Discussed with: marcel
Tested by: hrs, kris
MFC after: 3 days


# f111c268 25-Feb-2005 Sam Leffler <sam@FreeBSD.org>

fail gracefully rather than using an invalid array index if unable
to allocate a bar; it's unclear whether this can happen in practice

Noticed by: Coverity Prevent analysis tool
Discussed with: marcel


# 774363d3 11-Jan-2005 Warner Losh <imp@FreeBSD.org>

Revert part of last commit that was unintentional


# ac673f9a 10-Jan-2005 Warner Losh <imp@FreeBSD.org>

Use the standard FreeBSD license


# 098ca2bd 05-Jan-2005 Warner Losh <imp@FreeBSD.org>

Start each of the license/copyright comments with /*-, minor shuffle of lines


# a4da0c4b 01-Jul-2004 Warner Losh <imp@FreeBSD.org>

Remove duplicate FreeBSD id


# 87573bee 01-Jul-2004 Warner Losh <imp@FreeBSD.org>

While this file still needs __RMAN_RESOURCE_VISIBLE to get the size of
the struct resource for a malloc, it no longer needs it for the r_
elements of struct resource with this commit.


# b1311799 30-Jun-2004 Warner Losh <imp@FreeBSD.org>

Remove extra RMAN_RESOURCE_VISISBLE


# 23bb544b 30-Jun-2004 Warner Losh <imp@FreeBSD.org>

puc needs to peek into struct resource too.


# 38a674b3 30-Jun-2004 Poul-Henning Kamp <phk@FreeBSD.org>

This needs __RMAN_RESOURCE_VISIBLE


# 5f96beb9 17-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Convert callers to the new bus_alloc_resource_any(9) API.

Submitted by: Mark Santcroos <marks@ripe.net>
Reviewed by: imp, dfr, bde


# 153bbe3e 25-Sep-2003 Marcel Moolenaar <marcel@FreeBSD.org>

Make the port number available to the sub-device with PUC_IVAR_PORT.


# dc7d0dea 06-Sep-2003 Marcel Moolenaar <marcel@FreeBSD.org>

Enhance puc(4) to support uart(4). This includes:
o Introduce PUC_PORT_TYPE_UART so that we can attach to uart(4),
o Introduce port sub-types (eg PUC_PORT_UART_NS8250, PUC_PORT_UART_Z8530)
to handle different hardware and determine resource sizes.
o Introduce two new IVARs: PUC_IVAR_SUBTYPE and PUC_IVAR_REGSHFT. Both
are used by uart(4) to get sufficient information to talk to the HW.
o Introduce PUC_FLAGS_ALTRES to tell puc(4) to try memory mapped I/O
if I/O port space cannot be allocated, or vice versa.
o Have ports of type PUC_PORT_TYPE_COM attach to uart(1) if attaching
to sio(4) fails (due to not having the sio driver).
o Put struct puc_device_description in struct puc_softc instead of
having a pointer to a device description in the softc. This allows
us to create device descriptions on the fly without having to use
malloc() or otherwise have them staticly defined.
o Move puc_find_description() from puc.c to puc_pci.c as it's specific
to PCI.
o Add EBUS and SBUS frontends for use on sparc64. Note that the P in
puc stands for PCI, so we kinda mess things up here. It's too soon
to worry about it though. We'll know what to do about it in time.

NOTE: This commit changes the behaviour of puc(4) to not quieten the
device probe and attach for child devices. The uart(4) driver provides
additional device description that is valuable to have.


# aad970f1 24-Aug-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID().
Also some minor style cleanups.


# a3732274 31-Jul-2003 Doug Ambrisko <ambrisko@FreeBSD.org>

Add printer support to puc(4) driver.
- Move isa/ppc* to sys/dev/ppc (repo-copy)
- Add an attachment method to ppc for puc
- In puc we need to walk the chain of parents.
Still to do, is to make ppc(4) & puc(4) work on other platforms. Testers
wanted.

PR: 38372 (in spirit done differently)
Verified by: Make universe (if I messed up a platform please fix)


# e9442e03 30-Apr-2003 Maxim Sobolev <sobomax@FreeBSD.org>

Add support for IC Book Ironclad Pro/Lite 8-port cards.

Sponsired by: IC Book Labs
MFC After: 2 weeks


# 084254f8 15-Mar-2003 Maxim Sobolev <sobomax@FreeBSD.org>

- Add minimal support for TI16754 4xUART chip into sio(4) driver and remove
now unnecessary hack from the previous commit;
- Add support for Interrupt Latch Register (ILR) into puc(4). So far only
ILRs compatible with specifications from Digi International are supported.
Support for other types of ILRs could be easily added later;
- Correct clock frequency for IC Book Labs Dreadnought x16 Lite board;
- Enable ILR detection/usage for IC Book Labs Dreadnought x16 boards.

Sponsored by: IC Book Labs
MFC after: 2 weeks


# a163d034 18-Feb-2003 Warner Losh <imp@FreeBSD.org>

Back out M_* changes, per decision of the TRB.

Approved by: trb


# 44956c98 21-Jan-2003 Alfred Perlstein <alfred@FreeBSD.org>

Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.


# da5e9a5b 17-Jan-2003 Marcel Moolenaar <marcel@FreeBSD.org>

MFp4: Add support for memory mapped UARTs, but don't add any devices
yet that depend on it because sio(4) needs support for it before it
can be used. There's no reason why zs(4) couldn't attach to puc(4)
in the (near?) future (in principle), so don't make memory mapped I/O
support in sio(4) a precondition for this change.


# d64ada50 30-Dec-2002 Jens Schweikhardt <schweikh@FreeBSD.org>

Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/
Add FreeBSD Id tag where missing.


# 32bc35fd 27-Sep-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Add a field so we can specify flags per port to the underlying device driver.


# 1f02c343 04-Sep-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Don't let children attach fast interrupts if the parent interrupt is normal.

Submitted by: bde


# d3c10e33 04-Sep-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Bring back the PUC_FASTINTR option, and implement it correctly so that
child devices also know if they are fast or normal.

Requested by: bde


# b5518fb0 03-Sep-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Fix interrupt registration:

PUC devices live on pccard or pci so INTR_FAST is never really an option.
Don't try to register the interrupt as fast and don't allow the children
to do so either.


# ed4208e9 03-Sep-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Style: fix a function whitespace stuff-up. Remove a debugging printf.


# c9168019 03-Sep-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Style: move a global variable up to the top of the file.


# 237d2dda 31-Aug-2002 Juli Mallett <jmallett@FreeBSD.org>

Stylistic fixes for the inclusion of the opt_puc.h header, so it comes from the
right places, and so it's sorted consistently with how all the other N-hundreds
of files ding this do it.

Submitted by: Hiten Pandya <hiten@uk.FreeBSD.org>


# 1e89655a 31-Aug-2002 Poul-Henning Kamp <phk@FreeBSD.org>

More cleaning up and unhacking:

Don't expect all RIDs to be PCI rids. The previous code made at
least 1 mistake, even for PCI.

Give the card definitions a chance to specify a init function.
Use this instead of the gross superio hack.
Move the win877 init function to puc_pci.c where it belongs.

RIDs can actually be zero, don't set badmuxed if so.

Set a less incorrect end for the construct SYS_RES_IOPORT entries,
I guess both sio and lpt happen to use 8 IO ports, but that shouldn't
really be hardcoded this way.

Fixup puc_pccard.c to match.

We're getting closer.


# e6ccea0a 31-Aug-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Don't enable PUC_DEBUG by accident


# 32f606d1 31-Aug-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Split the puc driver in pci specific and generic parts.
Add a pccard frontend for it as well.

The PCcard stuff does not work yet because there is still some PCImagic
left in puc.c


# 4e64e277 20-Jul-2002 Warner Losh <imp@FreeBSD.org>

cardbus attachment.


# aaeedfc6 24-Apr-2002 John Hay <jhay@FreeBSD.org>

Ignore the multifunction bit in the PCIR_HEADERTYPE.

PR: 37333
Submitted by: Ari Suutari <ari.suutari@syncrontech.com>
MFC after: 4 days


# e51a25f8 19-Mar-2002 Alfred Perlstein <alfred@FreeBSD.org>

Remove __P.


# db78e578 08-Mar-2002 John Hay <jhay@FreeBSD.org>

Remove the #if __FreeBSD_version glue now that the puc driver is part of
-stable.


# 5aa967d9 19-Feb-2002 Yoshihiro Takahashi <nyan@FreeBSD.org>

Release allocated memory and bus_space_handle on an error.

Reviewed by: jhay


# 9f67ccb7 17-Feb-2002 Yoshihiro Takahashi <nyan@FreeBSD.org>

Move the bus_space_subregion function from the puc driver to the bus_space
sutff.

Reviewed by: jhay


# 9c564b6c 16-Feb-2002 John Hay <jhay@FreeBSD.org>

Add the puc (PCI "Universal" Communications) driver. The idea and some of
the structure definitions come from NetBSD to make it easier to share card
definitions. The driver only acts as a shim between the pci bus and the
sio driver. Later pci parallel ports could also be supported through this
driver. Support for most single and multiport pci serial cards should be
as simple as adding its definition to pucdata.c

Tested with the following pci cards:
Moxa Industio CP-114, 4 port RS-232,RS-422/485
Syba Tech Ltd. PCI-4S2P-550-ECP, 4 port RS-232 + 2 parallel ports
Netmos NM9835 PCI-2S-550, 2 port RS-232