Home | History | Annotate | only in /src/sys/arch/x86/pci
History log of /src/sys/arch/x86/pci
RevisionDateAuthorComments
 1.8 25-Nov-2009  njoly aprintify.
 1.7 09-Jul-2008  joerg branches: 1.7.8;
Fix syntax. *sigh*
 1.6 09-Jul-2008  joerg Finish device/softc split.
 1.5 09-Jul-2008  joerg - device/softc split
 1.4 11-Dec-2005  christos branches: 1.4.74; 1.4.78; 1.4.80; 1.4.82; 1.4.84;
merge ktrace-lwp.
 1.3 13-Jan-2005  fvdl If there are no ioapics, don't bother to put things in ioapic mode.
However, always do this otherwise, regardless of the revision.
Remove incorrect comment.
 1.2 23-Apr-2004  itojun branches: 1.2.2;
pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.1 18-Apr-2004  fvdl Moved here from arch/amd64/pci
 1.2.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.2.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.2 03-Aug-2004  skrll Sync with HEAD
 1.2.2.1 23-Apr-2004  skrll file aapic.c was added on branch ktrace-lwp on 2004-08-03 10:43:04 +0000
 1.4.84.1 19-Oct-2008  haad Sync with HEAD.
 1.4.82.1 18-Jul-2008  simonb Sync with head.
 1.4.80.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.4.78.2 11-Mar-2010  yamt sync with head
 1.4.78.1 04-May-2009  yamt sync with head.
 1.4.74.1 28-Sep-2008  mjf Sync with HEAD.
 1.7.8.1 24-Oct-2010  jym Sync with HEAD
 1.2 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.1 18-Dec-2006  christos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.68;
Moved from i386/pci/agp_machdep.c; from Blair Sadewitz
 1.1.68.1 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.1.6.2 12-Jan-2007  ad Sync with head.
 1.1.6.1 18-Dec-2006  ad file agp_machdep.c was added on branch newlock2 on 2007-01-12 01:01:01 +0000
 1.1.4.2 30-Dec-2006  yamt sync with head.
 1.1.4.1 18-Dec-2006  yamt file agp_machdep.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:22 +0000
 1.1.2.2 21-Dec-2006  yamt sync with head.
 1.1.2.1 18-Dec-2006  yamt file agp_machdep.c was added on branch yamt-splraiseipl on 2006-12-21 15:07:58 +0000
 1.2 11-Dec-2005  christos merge ktrace-lwp.
 1.1 18-Apr-2004  fvdl branches: 1.1.2;
Moved here from arch/amd64/pci
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 18-Apr-2004  skrll file amd8131reg.h was added on branch ktrace-lwp on 2004-08-03 10:43:04 +0000
 1.5 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.4 24-Apr-2021  thorpej branches: 1.4.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.3 12-Dec-2018  is branches: 1.3.14;
Added support for AMD family 16h cpu sensors - (just like 10h-14h).
(Tested on netbsd-8.0 release.)
 1.2 16-Apr-2012  cegger branches: 1.2.2; 1.2.4; 1.2.36; 1.2.42; 1.2.44;
Add rescan support. Re-fixes PR 45268.
 1.1 13-Apr-2012  cegger Replace amdtempbus with amdnb_miscbus.
This allows us to have independent drivers on the same device (northbridge f3)
each coming with a certain functionality/feature.
This way we do not need to mess with amdtemp(4) to utilize other features.
 1.2.44.1 10-Jun-2019  christos Sync with HEAD
 1.2.42.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.2.36.1 15-Dec-2018  martin Pull up following revision(s) (requested by is in ticket #1137):

sys/arch/x86/pci/amdnb_misc.c: revision 1.3
sys/arch/x86/pci/amdtemp.c: revision 1.22

Added support for AMD family 16h cpu sensors - (just like 10h-14h).
(Tested on netbsd-8.0 release.)
 1.2.4.2 29-Apr-2012  mrg sync to latest -current.
 1.2.4.1 16-Apr-2012  mrg file amdnb_misc.c was added on branch jmcneill-usbmp on 2012-04-29 23:04:43 +0000
 1.2.2.3 18-Apr-2012  yamt pull following revisions from trunk so that the kernel at least boot
on my system.
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/x86/pci/pchb.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/pci/pchbvar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/amdnb_misc.c
 1.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 16-Apr-2012  yamt file amdnb_misc.c was added on branch yamt-pagecache on 2012-04-17 00:07:05 +0000
 1.3.14.7 05-Apr-2021  thorpej config_match() -> config_probe() for the straight-forward indirect config
cases. There are still a few odd balls using config_match() which should
be sorted out later.
 1.3.14.6 04-Apr-2021  thorpej CFARG_SUBMATCH -> CFARG_SEARCH for the indirect configuration uses.
 1.3.14.5 03-Apr-2021  thorpej Give config_attach() the tagged variadic argument treatment and
mechanically convert all call sites.
 1.3.14.4 28-Mar-2021  thorpej These devices have only one interface attribute and no locators,
so simplify:

- config_attach_loc() -> config_attach().
- Don't pass CFARG_IATTR, or CFARG_LOCATORS to config_search().
 1.3.14.3 21-Mar-2021  thorpej In "rescan" routines, always pass locators and the interface attribute
straight through to config_search(). Also, for devices that carry only
one interface attribute, no need to do an ifattr_match(), because
rescan_with_cfdata() will have already validated that the parent is
eligible, which includes an interface attribute check.
 1.3.14.2 21-Mar-2021  thorpej CFARG_IATTR usage audit:

If a device carries only one interface attribute, there is no need
to specify it when calling config_search(); that specification is
meant only to disambiguate which interface attribute (which is a
proxy for "what kind of attach args are being used") is having
children attached. cfparent_match() will take care of ensuring that
any potential children can attach to one of the parent's iterface
attributes, and if the parent only carries one, no disambiguation is
necessary.
 1.3.14.1 20-Mar-2021  thorpej The proliferation if config_search_*() and config_found_*() combinations
is a little absurd, so begin to tidy this up:

- Introduce a new cfarg_t enumerated type, that defines the types of
tag-value variadic arguments that can be passed to the various
config_*() functions (CFARG_SUBMATCH, CFARG_IATTR, and CFARG_LOCATORS,
for now, plus a CFARG_EOL sentinel).
- Collapse config_search_*() into config_search() that takes these
variadic arguments.
- Convert all call sites of config_search_*() to the new signature.
Noticed several incorrect usages along the way, which will be
audited in a future commit.
 1.4.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.5 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.4 24-Apr-2021  thorpej branches: 1.4.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.3 20-Jul-2008  martin branches: 1.3.96;
Make struct pcib_softc explicit in our softc.
 1.2 21-Mar-2008  xtraeme branches: 1.2.4; 1.2.6; 1.2.8; 1.2.10;
Split device_t/softc for amdpcib and the hpet attachment, plus other
related cosmetic changes.
 1.1 26-Oct-2007  xtraeme branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10; 1.1.12; 1.1.26;
Share pcib(4) and amdpcib(4) between i386 and amd64; one copy is enough.
 1.1.26.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.26.1 03-Apr-2008  mjf Sync with HEAD.
 1.1.12.2 03-Dec-2007  ad Sync with HEAD.
 1.1.12.1 26-Oct-2007  ad file amdpcib.c was added on branch vmlocking on 2007-12-03 19:04:24 +0000
 1.1.10.2 13-Nov-2007  bouyer Sync with HEAD
 1.1.10.1 26-Oct-2007  bouyer file amdpcib.c was added on branch bouyer-xenamd64 on 2007-11-13 16:00:18 +0000
 1.1.8.3 23-Mar-2008  matt sync with HEAD
 1.1.8.2 06-Nov-2007  matt sync with HEAD
 1.1.8.1 26-Oct-2007  matt file amdpcib.c was added on branch matt-armv6 on 2007-11-06 23:23:40 +0000
 1.1.4.2 28-Oct-2007  joerg Sync with HEAD.
 1.1.4.1 26-Oct-2007  joerg file amdpcib.c was added on branch jmcneill-pm on 2007-10-28 20:10:59 +0000
 1.1.2.3 24-Mar-2008  yamt sync with head.
 1.1.2.2 27-Oct-2007  yamt sync with head.
 1.1.2.1 26-Oct-2007  yamt file amdpcib.c was added on branch yamt-lazymbuf on 2007-10-27 11:28:57 +0000
 1.2.10.1 19-Oct-2008  haad Sync with HEAD.
 1.2.8.1 28-Jul-2008  simonb Sync with head.
 1.2.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.2.4.1 04-May-2009  yamt sync with head.
 1.3.96.4 05-Apr-2021  thorpej config_match() -> config_probe() for the straight-forward indirect config
cases. There are still a few odd balls using config_match() which should
be sorted out later.
 1.3.96.3 04-Apr-2021  thorpej CFARG_SUBMATCH -> CFARG_SEARCH for the indirect configuration uses.
 1.3.96.2 03-Apr-2021  thorpej config_attach_loc() -> config_attach() with CFARG_LOCATORS argument.
 1.3.96.1 20-Mar-2021  thorpej The proliferation if config_search_*() and config_found_*() combinations
is a little absurd, so begin to tidy this up:

- Introduce a new cfarg_t enumerated type, that defines the types of
tag-value variadic arguments that can be passed to the various
config_*() functions (CFARG_SUBMATCH, CFARG_IATTR, and CFARG_LOCATORS,
for now, plus a CFARG_EOL sentinel).
- Collapse config_search_*() into config_search() that takes these
variadic arguments.
- Convert all call sites of config_search_*() to the new signature.
Noticed several incorrect usages along the way, which will be
audited in a future commit.
 1.4.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.8 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.7 15-Jun-2011  jruoho Modularize hpet(4). Works nicely with the multiple bus locations.
 1.6 15-Jun-2011  jruoho Use defined constants.
 1.5 15-Jun-2011  jruoho Add detach function for hpet(4) at amdpcib(4).
 1.4 21-Mar-2008  xtraeme branches: 1.4.18; 1.4.36;
Split device_t/softc for ichlpcib(4) and all hpet consumers, plus
other related cosmetic changes.
 1.3 21-Mar-2008  xtraeme Split device_t/softc for amdpcib and the hpet attachment, plus other
related cosmetic changes.
 1.2 07-Jan-2008  joerg branches: 1.2.6;
x86 always has timecounter support.
 1.1 26-Oct-2007  xtraeme branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.12; 1.1.18;
Share pcib(4) and amdpcib(4) between i386 and amd64; one copy is enough.
 1.1.18.1 08-Jan-2008  bouyer Sync with HEAD
 1.1.12.2 03-Dec-2007  ad Sync with HEAD.
 1.1.12.1 26-Oct-2007  ad file amdpcib_hpet.c was added on branch vmlocking on 2007-12-03 19:04:25 +0000
 1.1.10.2 13-Nov-2007  bouyer Sync with HEAD
 1.1.10.1 26-Oct-2007  bouyer file amdpcib_hpet.c was added on branch bouyer-xenamd64 on 2007-11-13 16:00:19 +0000
 1.1.8.4 23-Mar-2008  matt sync with HEAD
 1.1.8.3 09-Jan-2008  matt sync with HEAD
 1.1.8.2 06-Nov-2007  matt sync with HEAD
 1.1.8.1 26-Oct-2007  matt file amdpcib_hpet.c was added on branch matt-armv6 on 2007-11-06 23:23:41 +0000
 1.1.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.4.2 28-Oct-2007  joerg Sync with HEAD.
 1.1.4.1 26-Oct-2007  joerg file amdpcib_hpet.c was added on branch jmcneill-pm on 2007-10-28 20:10:59 +0000
 1.1.2.4 24-Mar-2008  yamt sync with head.
 1.1.2.3 21-Jan-2008  yamt sync with head
 1.1.2.2 27-Oct-2007  yamt sync with head.
 1.1.2.1 26-Oct-2007  yamt file amdpcib_hpet.c was added on branch yamt-lazymbuf on 2007-10-27 11:28:57 +0000
 1.2.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.4.36.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.18.1 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.18 17-Oct-2024  msaitoh amdsmn(4): Add support AMD family F1Ah model 0xh "Turin".
 1.17 28-Jul-2023  msaitoh branches: 1.17.6;
Add Zen4 Phoenix support.
 1.16 28-Jan-2023  msaitoh amdsmn(4),amdzentemp(4): Add Zen3+ Rembrandt(19h/4xh) & Zen4 Genoa(19h/1xh).
 1.15 18-Dec-2022  reinoud Add amdsmn(4) and amdccp(4) power management stubs.
 1.14 01-Oct-2022  msaitoh branches: 1.14.4;
amdsmn(4),amdzentemp(4): Add support for 17h/6xh and 19h/6xh.
 1.13 27-Apr-2022  msaitoh Rename for AMD F15/6X device. No functional change.
 1.12 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.11 24-Apr-2021  thorpej branches: 1.11.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.10 25-Apr-2020  bouyer branches: 1.10.4;
Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor
 1.9 23-Apr-2020  simonb Apply previous change ("Don't mix sign and unsigned operands. Just use
size_t for the loop.") to another loop variable.
 1.8 20-Apr-2020  joerg Don't mix sign and unsigned operands. Just use size_t for the loop.
 1.7 20-Apr-2020  simonb Update to support Family 15h Model 60 temperature sensors.

Changes based on FreeBSD amdtemp driver changes by Conrad Meyer.

XXX: Some code duplication between this driver and amdtemp as
parts of the 15h refresh code share more in common with
older CPUs while accessing the device more like 17h.
 1.6 06-Aug-2019  msaitoh branches: 1.6.6;
Whitespace fix.
 1.5 18-Jul-2019  msaitoh branches: 1.5.2;
Use unsigned to fix compile error on i386.
 1.4 18-Jul-2019  msaitoh Add support for Ryzen 2xxx and 3xxx.
 1.3 27-Jan-2018  kardel branches: 1.3.2; 1.3.6;
rescan amdsmnbus instead of amdsmn (fixes panic)
 1.2 25-Jan-2018  pgoyette Modularize the amdsmn(4) driver, and update dependency for amdzentemp(4)
 1.1 25-Jan-2018  christos Add amdzentemp from FreeBSD via Ian Clark
 1.3.6.2 21-Apr-2020  martin Sync with HEAD
 1.3.6.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.2.7 22-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1888):

sys/arch/x86/pci/amdzentemp.c: revision 1.20
sys/arch/x86/pci/amdsmn.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.19

Add Zen4 Ryzen "Phoenix" support.
Add Zen2 Mendocino APU support.
Add Zen4 Phoenix support.
 1.3.2.6 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1825):

sys/arch/x86/pci/amdsmn.c: revision 1.16
sys/arch/x86/pci/amdzentemp.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.18

Reduce diff against DragonFly. No functional change.
amdsmn(4),amdzentemp(4): Add Zen3+ Rembrandt(19h/4xh) & Zen4 Genoa(19h/1xh).
 1.3.2.5 11-Oct-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1773):

share/man/man4/man4.x86/amdsmn.4 1.4,1.5
share/man/man4/man4.x86/amdzentemp.4 1.7
sys/arch/x86/pci/amdsmn.c 1.7-1.9,1.13,1.14
sys/arch/x86/pci/amdzentemp.c 1.8-1.10,1.12-1.15

adjust for possible 49K offset

presence of this offset is indicated by a set 19th bit which is shifted away
this brings the temperature to "normal" levels on my ryzen 2700
(I assumed the same 49K offset as the k10temp project)

correct for known temperature bias values.

Update to support Family 15h Model 60 temperature sensors.

Changes based on FreeBSD amdtemp driver changes by Conrad Meyer.

XXX: Some code duplication between this driver and amdtemp as
parts of the 15h refresh code share more in common with
older CPUs while accessing the device more like 17h.

Don't mix sign and unsigned operands. Just use size_t for the loop.

Apply previous change ("Don't mix sign and unsigned operands. Just use
size_t for the loop.") to another loop variable.

amdzentemp(4): Add Zen 3 support.

amdzentemp(4): Add support for per CCD temperature sensor from FreeBSD.

Fix build failure on i386.

Rename for AMD F15/6X device. No functional change.
amdsmn(4),amdzentemp(4): Add support for 17h/6xh and 19h/6xh.

Note that these drivers are present on some newer AMD Family 15h
processors.

amdsmn.4: Now support AMD Family 19h processors.
 1.3.2.4 06-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1328):

sys/arch/x86/pci/amdsmn.c: revision 1.4
sys/arch/x86/pci/amdsmn.c: revision 1.5
sys/arch/x86/pci/amdsmn.c: revision 1.6

Add support for Ryzen 2xxx and 3xxx.

Use unsigned to fix compile error on i386.

Whitespace fix.
 1.3.2.3 06-Feb-2018  martin Additionally pull up rev 1.3 of sys/arch/x86/pci/amdsmn.c, requested by
pgoyette in ticket #524:

rescan amdsmnbus instead of amdsmn (fixes panic)
 1.3.2.2 05-Feb-2018  martin Pull up following revision(s) (requested by pgoyette in ticket #524):

distrib/sets/lists/man/mi 1.1574
distrib/sets/lists/modules/md.amd64 1.73
distrib/sets/lists/modules/md.i386 1.76
share/man/man4/amdtemp.4 1.11
share/man/man4/man4.x86/Makefile 1.17
share/man/man4/man4.x86/amdsmn.4 1.1-1.3
share/man/man4/man4.x86/amdzentemp.4 1.1-1.6
sys/arch/amd64/conf/ALL 1.79,1.80
sys/arch/amd64/conf/GENERIC 1.482,1.484
sys/arch/amd64/conf/XEN3_DOM0 1.146,1.147
sys/arch/x86/pci/amdsmn.c 1.1-1.2
sys/arch/x86/pci/amdsmn.h 1.1
sys/arch/x86/pci/amdzentemp.c 1.1-1.7
sys/arch/x86/pci/files.pci 1.22,1.23
sys/modules/amdzentemp/amdzentemp.ioconf 1.2


Add amdzentemp from FreeBSD via Ian Clark.

man pages for amdsmn and amdzentemp.

Some clean-up on the HISTORY and AUTHORS sections, and addition of a BUGS
section to document the fact that we don't yet handle the required temp
offset, nor do we expose the available thermal-trip value.

Add missing article 'a'

KNF: Put back the blank line following the empty variable declarations
Put back the variable declaration, too, and mark it __diagused
Otherwise a DIAGNOSTIC kernel will complain about the variable being
undeclared.

Correct placement of __diagused attribute.

Modularize the amdsmn(4) driver, and update dependency for amdzentemp(4),
Create amdsmn(4) amd amdzentemp(4) modules for X86.
 1.3.2.1 27-Jan-2018  martin file amdsmn.c was added on branch netbsd-8 on 2018-02-05 13:06:55 +0000
 1.5.2.5 22-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1720):

sys/arch/x86/pci/amdzentemp.c: revision 1.20
sys/arch/x86/pci/amdsmn.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.19

Add Zen4 Ryzen "Phoenix" support.
Add Zen2 Mendocino APU support.
Add Zen4 Phoenix support.
 1.5.2.4 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1644):

sys/arch/x86/pci/amdsmn.c: revision 1.16
sys/arch/x86/pci/amdzentemp.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.18

Reduce diff against DragonFly. No functional change.
amdsmn(4),amdzentemp(4): Add Zen3+ Rembrandt(19h/4xh) & Zen4 Genoa(19h/1xh).
 1.5.2.3 11-Oct-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1539):

share/man/man4/man4.x86/amdsmn.4: revision 1.5
sys/arch/x86/pci/amdsmn.c: revision 1.14
sys/arch/x86/pci/amdzentemp.c: revision 1.12-1.15

amdzentemp(4): Add Zen 3 support.

amdzentemp(4): Add support for per CCD temperature sensor from FreeBSD.

Fix build failure on i386.

amdsmn(4),amdzentemp(4): Add support for 17h/6xh and 19h/6xh.

amdsmn.4: Now support AMD Family 19h processors.
 1.5.2.2 27-Jul-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1482:

sys/dev/pci/pcidevs 1.1422,1.1445-1.1460
via patch
sys/arch/x86/pci/amdsmn.c 1.13

Update pcidevs:
- Add Intel Alder Lake devices and Intel 600 Series PCH devices.
- Add some Intel Xeon Scalable / Skylake-E devices.
- Fix AMD F16_HB from 0x1568 to 0x1538.
- Add some devices for AMD and improve some descriptions to clarify.
- Add VMware AHCI and NVMe.
- Update Intel 700 series Ethernet devices.
- Add some Broadcom devices.
- Add some Broadcom / LSI RAID cards.
- Fix typos and whitespace.
 1.5.2.1 24-Apr-2020  martin Pull up following revision(s) (requested by simonb in ticket #851):

share/man/man4/man4.x86/amdzentemp.4: revision 1.7
share/man/man4/man4.x86/amdsmn.4: revision 1.4
sys/arch/x86/pci/amdsmn.c: revision 1.7
sys/arch/x86/pci/amdsmn.c: revision 1.8
sys/arch/x86/pci/amdsmn.c: revision 1.9
sys/arch/x86/pci/amdzentemp.c: revision 1.10

Update to support Family 15h Model 60 temperature sensors.

Changes based on FreeBSD amdtemp driver changes by Conrad Meyer.
XXX: Some code duplication between this driver and amdtemp as
parts of the 15h refresh code share more in common with
older CPUs while accessing the device more like 17h.
--
Note that these drivers are present on some newer AMD Family 15h
processors.
--
Don't mix sign and unsigned operands. Just use size_t for the loop.
--
Apply previous change ("Don't mix sign and unsigned operands. Just use
size_t for the loop.") to another loop variable.
--
 1.6.6.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.10.4.6 05-Apr-2021  thorpej config_match() -> config_probe() for the straight-forward indirect config
cases. There are still a few odd balls using config_match() which should
be sorted out later.
 1.10.4.5 04-Apr-2021  thorpej CFARG_SUBMATCH -> CFARG_SEARCH for the indirect configuration uses.
 1.10.4.4 03-Apr-2021  thorpej config_attach_loc() -> config_attach() with CFARG_LOCATORS argument.
 1.10.4.3 28-Mar-2021  thorpej These devices have only one interface attribute and no locators,
so simplify:

- config_attach_loc() -> config_attach().
- Don't pass CFARG_IATTR, or CFARG_LOCATORS to config_search().
 1.10.4.2 21-Mar-2021  thorpej In "rescan" routines, always pass locators and the interface attribute
straight through to config_search(). Also, for devices that carry only
one interface attribute, no need to do an ifattr_match(), because
rescan_with_cfdata() will have already validated that the parent is
eligible, which includes an interface attribute check.
 1.10.4.1 20-Mar-2021  thorpej The proliferation if config_search_*() and config_found_*() combinations
is a little absurd, so begin to tidy this up:

- Introduce a new cfarg_t enumerated type, that defines the types of
tag-value variadic arguments that can be passed to the various
config_*() functions (CFARG_SUBMATCH, CFARG_IATTR, and CFARG_LOCATORS,
for now, plus a CFARG_EOL sentinel).
- Collapse config_search_*() into config_search() that takes these
variadic arguments.
- Convert all call sites of config_search_*() to the new signature.
Noticed several incorrect usages along the way, which will be
audited in a future commit.
 1.11.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.14.4.3 22-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #335):

sys/arch/x86/pci/amdzentemp.c: revision 1.20
sys/arch/x86/pci/amdsmn.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.19

Add Zen4 Ryzen "Phoenix" support.
Add Zen2 Mendocino APU support.
Add Zen4 Phoenix support.
 1.14.4.2 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #198):

sys/arch/x86/pci/amdsmn.c: revision 1.16
sys/arch/x86/pci/amdzentemp.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.18

Reduce diff against DragonFly. No functional change.
amdsmn(4),amdzentemp(4): Add Zen3+ Rembrandt(19h/4xh) & Zen4 Genoa(19h/1xh).
 1.14.4.1 19-Dec-2022  martin Pull up following revision(s) (requested by reinoud in ticket #3):

sys/dev/pci/amdccp_pci.c: revision 1.4
sys/arch/x86/pci/amdsmn.c: revision 1.15
sys/dev/acpi/amdccp_acpi.c: revision 1.6
sys/dev/fdt/amdccp_fdt.c: revision 1.7

Add amdsmn(4) and amdccp(4) power management stubs.
 1.17.6.1 02-Aug-2025  perseant Sync with HEAD
 1.1 25-Jan-2018  christos branches: 1.1.2;
Add amdzentemp from FreeBSD via Ian Clark
 1.1.2.2 05-Feb-2018  martin Pull up following revision(s) (requested by pgoyette in ticket #524):

distrib/sets/lists/man/mi 1.1574
distrib/sets/lists/modules/md.amd64 1.73
distrib/sets/lists/modules/md.i386 1.76
share/man/man4/amdtemp.4 1.11
share/man/man4/man4.x86/Makefile 1.17
share/man/man4/man4.x86/amdsmn.4 1.1-1.3
share/man/man4/man4.x86/amdzentemp.4 1.1-1.6
sys/arch/amd64/conf/ALL 1.79,1.80
sys/arch/amd64/conf/GENERIC 1.482,1.484
sys/arch/amd64/conf/XEN3_DOM0 1.146,1.147
sys/arch/x86/pci/amdsmn.c 1.1-1.2
sys/arch/x86/pci/amdsmn.h 1.1
sys/arch/x86/pci/amdzentemp.c 1.1-1.7
sys/arch/x86/pci/files.pci 1.22,1.23
sys/modules/amdzentemp/amdzentemp.ioconf 1.2


Add amdzentemp from FreeBSD via Ian Clark.

man pages for amdsmn and amdzentemp.

Some clean-up on the HISTORY and AUTHORS sections, and addition of a BUGS
section to document the fact that we don't yet handle the required temp
offset, nor do we expose the available thermal-trip value.

Add missing article 'a'

KNF: Put back the blank line following the empty variable declarations
Put back the variable declaration, too, and mark it __diagused
Otherwise a DIAGNOSTIC kernel will complain about the variable being
undeclared.

Correct placement of __diagused attribute.

Modularize the amdsmn(4) driver, and update dependency for amdzentemp(4),
Create amdsmn(4) amd amdzentemp(4) modules for X86.
 1.1.2.1 25-Jan-2018  martin file amdsmn.h was added on branch netbsd-8 on 2018-02-05 13:06:55 +0000
 1.23 30-Dec-2018  is Document bobcat/puma family nicknames.
 1.22 12-Dec-2018  is Added support for AMD family 16h cpu sensors - (just like 10h-14h).
(Tested on netbsd-8.0 release.)
 1.21 27-Sep-2018  maxv Improve a bit, no real functional change.
 1.20 01-Jun-2017  chs branches: 1.20.2; 1.20.8; 1.20.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.19 23-Apr-2015  pgoyette Update module dependencies for all the existing modules that depend on sysmon components.
 1.18 15-Nov-2013  msaitoh branches: 1.18.6;
Modify some macros and add some new macros for CPU family and model
to reduce code duplication and to avoid bug.

CPUID_TO_STEPPING(cpuid) (not changed)

CPUID_TO_FAMILY(cpuid) (new)
CPUID_TO_MODEL(cpuid) (new)

Return the display family and the display model.
The macro names are the same as FreeBSD.

CPUID_TO_BASEFAMILY(cpuid) (The old name was CPUID2FAMILY)
CPUID_TO_BASEMODEL(cpuid) (The old name was CPUID2MODEL)

Only for the base field.

CPUID_TO_EXTFAMILY(cpuid) (The old name was CPUID2EXTFAMILY)
CPUID_TO_EXTMODEL(cpuid) (The old name was CPUID2EXTMODEL)

Only for the extended field.

See http://mail-index.netbsd.org/port-amd64/2013/11/12/msg001978.html
 1.17 12-Nov-2013  msaitoh Calcurate the processor family correctly. The extended family bits
should be added only when the base family is 0xf.
 1.16 16-Jul-2012  pgoyette branches: 1.16.2; 1.16.4;
Enable entropy gathering
 1.15 13-Apr-2012  cegger Replace amdtempbus with amdnb_miscbus.
This allows us to have independent drivers on the same device (northbridge f3)
each coming with a certain functionality/feature.
This way we do not need to mess with amdtemp(4) to utilize other features.
 1.14 13-Apr-2012  cegger - support AMD Family15h
- deregister pmf on detach
 1.13 02-Mar-2012  nonaka Added Family 12h support.
 1.12 31-Jul-2011  jmcneill branches: 1.12.2; 1.12.6; 1.12.8;
add Family14h (AMD Fusion) support
 1.11 15-Jun-2011  jruoho Small cleanup; use KM_SLEEP, wrap long lines, etc. No functional change.
 1.10 15-Jun-2011  jruoho Modularize amdtemp(4).
 1.9 16-Oct-2009  cegger branches: 1.9.10;
Family 10h Errata #319: Attach on Family10h cpu series which have it fixed.
 1.8 16-Jun-2009  cegger - use <sys/bus.h> and <sys/cpu.h>
- add reference to family11h documentation
- add reference to AMD K8 Errata #141
 1.7 12-Mar-2009  cegger - beautify dmesg
- print family id if not supported
spotted by jmcneill@
 1.6 04-Dec-2008  cegger branches: 1.6.4;
Fix the fix: Only AMD K8 Rev-G on AM2 sockets are impacted.
 1.5 04-Dec-2008  cegger On AMD K8 CPUs with Socket AM2, sensor normalization is off by 21C degree.
Adjust temperature calculation. This should fix strange temperatures on AMD K8
CPUs reported by many people.
 1.4 20-May-2008  cegger branches: 1.4.2; 1.4.6; 1.4.8; 1.4.10;
correct comment copied from aiboost(4): envsys(4) wants uK
 1.3 20-May-2008  cegger envsys(4) expects values in mK and not the top of the range of possible temperature values.
Needed some time to figure this out after I saw negative temperature values on Griffin.
 1.2 29-Apr-2008  martin branches: 1.2.2; 1.2.4;
Convert to new 2 clause license
 1.1 22-Apr-2008  cegger branches: 1.1.2;
amdtemp(4): Driver for AMD CPU Temperature Sensors. Adopted from OpenBSD's kate(4).
Changes beyond OpenBSD's driver:
- Improved support for AMD K8
- Added support for AMD Barcelona, AMD Phenom and AMD Griffin
Tested on various single and multi-socket machines.
Review and OK xtreame
 1.1.2.4 11-Mar-2010  yamt sync with head
 1.1.2.3 20-Jun-2009  yamt sync with head
 1.1.2.2 04-May-2009  yamt sync with head.
 1.1.2.1 16-May-2008  yamt sync with head.
 1.2.4.3 04-Jun-2008  yamt sync with head
 1.2.4.2 18-May-2008  yamt sync with head.
 1.2.4.1 29-Apr-2008  yamt file amdtemp.c was added on branch yamt-pf42 on 2008-05-18 12:33:04 +0000
 1.2.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4.10.2 10-Dec-2008  snj Pull up following revision(s) (requested by cegger in ticket #173):
sys/arch/x86/pci/amdtemp.c: revision 1.6
Fix the fix: Only AMD K8 Rev-G on AM2 sockets are impacted.
 1.4.10.1 10-Dec-2008  snj Pull up following revision(s) (requested by cegger in ticket #173):
sys/arch/x86/pci/amdtemp.c: revision 1.5
On AMD K8 CPUs with Socket AM2, sensor normalization is off by 21C degree.
Adjust temperature calculation. This should fix strange temperatures on
AMD K8
CPUs reported by many people.
 1.4.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.4.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.4.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.4.2.3 17-Jan-2009  mjf Sync with HEAD.
 1.4.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.4.2.1 20-May-2008  mjf file amdtemp.c was added on branch mjf-devfs2 on 2008-06-02 13:22:50 +0000
 1.6.4.4 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.6.4.3 01-Nov-2009  jym Sync with HEAD.
 1.6.4.2 23-Jul-2009  jym Sync with HEAD.
 1.6.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.9.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.12.8.2 16-Apr-2012  riz Pull up following revision(s) (requested by cegger in ticket #180):
sys/arch/x86/pci/amdtemp.c: revision 1.14
sys/dev/pci/pcidevs: revision 1.1115
Add AMD Family15h ids
- support AMD Family15h
- deregister pmf on detach
 1.12.8.1 08-Mar-2012  riz Pull up following revision(s) (requested by nonaka):
share/man/man4/amdtemp.4: revision 1.6
share/man/man4/amdtemp.4: revision 1.7
sys/arch/x86/pci/amdtemp.c: revision 1.13
Added Family 12h support.
Mention AMD Fusion.
Bump date for previous.
 1.12.6.4 29-Apr-2012  mrg sync to latest -current.
 1.12.6.3 06-Mar-2012  mrg sync to -current
 1.12.6.2 06-Mar-2012  mrg sync to -current
 1.12.6.1 04-Mar-2012  mrg sync to latest -current.
 1.12.2.3 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.2.2 30-Oct-2012  yamt sync with head
 1.12.2.1 17-Apr-2012  yamt sync with head
 1.16.4.1 18-May-2014  rmind sync with head
 1.16.2.2 03-Dec-2017  jdolecek update from HEAD
 1.16.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.6.2 28-Aug-2017  skrll Sync with HEAD
 1.18.6.1 06-Jun-2015  skrll Sync with HEAD
 1.20.10.1 10-Jun-2019  christos Sync with HEAD
 1.20.8.3 18-Jan-2019  pgoyette Synch with HEAD
 1.20.8.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.20.8.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.20.2.1 15-Dec-2018  martin Pull up following revision(s) (requested by is in ticket #1137):

sys/arch/x86/pci/amdnb_misc.c: revision 1.3
sys/arch/x86/pci/amdtemp.c: revision 1.22

Added support for AMD family 16h cpu sensors - (just like 10h-14h).
(Tested on netbsd-8.0 release.)
 1.23 06-Apr-2025  pgoyette insert a space in attach message
 1.22 17-Oct-2024  msaitoh amdzentemp(4): Add some CPU support.

- Zen4 "Siena" (family 1fh mode 0xa0...0xaf)
- Zen5 "Turin Classic" (family 1ah mode 0x00...0x0f)
- Zen5 "Turin Dense" (family 1ah mode 0x10...0x1f)
- Zen5 "Strix Point" (family 1ah mode 0x20...0x2f)
 1.21 04-Oct-2024  msaitoh amdzentemp(4): Add support for CPU family 0x1a model 0x40...0x4f (Zen 5)
 1.20 28-Jul-2023  msaitoh branches: 1.20.6;
Add Zen2 Mendocino APU support.
 1.19 28-Jul-2023  msaitoh Add Zen4 Ryzen "Phoenix" support.
 1.18 28-Jan-2023  msaitoh amdsmn(4),amdzentemp(4): Add Zen3+ Rembrandt(19h/4xh) & Zen4 Genoa(19h/1xh).
 1.17 28-Jan-2023  msaitoh Reduce diff against DragonFly. No functional change.
 1.16 24-Nov-2022  mrg branches: 1.16.2;
match zen3 "cezanne" (ryzen 5000-series APU.)
 1.15 01-Oct-2022  msaitoh amdsmn(4),amdzentemp(4): Add support for 17h/6xh and 19h/6xh.
 1.14 06-Jun-2021  nonaka Fix build failure on i386.
 1.13 06-Jun-2021  nonaka amdzentemp(4): Add support for per CCD temperature sensor from FreeBSD.
 1.12 05-Jun-2021  nonaka amdzentemp(4): Add Zen 3 support.
 1.11 25-Apr-2020  bouyer branches: 1.11.6; 1.11.10;
Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor
 1.10 20-Apr-2020  simonb Update to support Family 15h Model 60 temperature sensors.

Changes based on FreeBSD amdtemp driver changes by Conrad Meyer.

XXX: Some code duplication between this driver and amdtemp as
parts of the 15h refresh code share more in common with
older CPUs while accessing the device more like 17h.
 1.9 16-Jun-2019  mlelstv branches: 1.9.2; 1.9.8;
correct for known temperature bias values.
 1.8 25-Jul-2018  para adjust for possible 49K offset

presence of this offset is indicated by a set 19th bit which is shifted away
this brings the temperature to "normal" levels on my ryzen 2700
(I assumed the same 49K offset as the k10temp project)
 1.7 26-Jan-2018  pgoyette branches: 1.7.2; 1.7.4; 1.7.6;
sc->sc_sensor cannot be NULL since it was just allocated with KM_SLEEP
(which cannot fail). So remove the NULL-check. CID/1428644
 1.6 25-Jan-2018  pgoyette Modularize the amdsmn(4) driver, and update dependency for amdzentemp(4)
 1.5 25-Jan-2018  pgoyette Correct placement of __diagused attribute
 1.4 25-Jan-2018  pgoyette Put back the variable declaration, too, and mark it __diagused

Otherwise a DIAGNOSTIC kernel will complain about the variable being
undeclared.
 1.3 25-Jan-2018  pgoyette KNF: Put back the blank line following the empty variable declarations
 1.2 25-Jan-2018  prlw1 Unused variable build fix. (now void *aux is unused)
 1.1 25-Jan-2018  christos Add amdzentemp from FreeBSD via Ian Clark
 1.7.6.3 21-Apr-2020  martin Sync with HEAD
 1.7.6.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.6.1 10-Jun-2019  christos Sync with HEAD
 1.7.4.1 28-Jul-2018  pgoyette Sync with HEAD
 1.7.2.6 22-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1888):

sys/arch/x86/pci/amdzentemp.c: revision 1.20
sys/arch/x86/pci/amdsmn.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.19

Add Zen4 Ryzen "Phoenix" support.
Add Zen2 Mendocino APU support.
Add Zen4 Phoenix support.
 1.7.2.5 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1825):

sys/arch/x86/pci/amdsmn.c: revision 1.16
sys/arch/x86/pci/amdzentemp.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.18

Reduce diff against DragonFly. No functional change.
amdsmn(4),amdzentemp(4): Add Zen3+ Rembrandt(19h/4xh) & Zen4 Genoa(19h/1xh).
 1.7.2.4 23-Jan-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1789):

sys/arch/x86/pci/amdzentemp.c: revision 1.16

match zen3 "cezanne" (ryzen 5000-series APU.)
 1.7.2.3 11-Oct-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1773):

share/man/man4/man4.x86/amdsmn.4 1.4,1.5
share/man/man4/man4.x86/amdzentemp.4 1.7
sys/arch/x86/pci/amdsmn.c 1.7-1.9,1.13,1.14
sys/arch/x86/pci/amdzentemp.c 1.8-1.10,1.12-1.15

adjust for possible 49K offset

presence of this offset is indicated by a set 19th bit which is shifted away
this brings the temperature to "normal" levels on my ryzen 2700
(I assumed the same 49K offset as the k10temp project)

correct for known temperature bias values.

Update to support Family 15h Model 60 temperature sensors.

Changes based on FreeBSD amdtemp driver changes by Conrad Meyer.

XXX: Some code duplication between this driver and amdtemp as
parts of the 15h refresh code share more in common with
older CPUs while accessing the device more like 17h.

Don't mix sign and unsigned operands. Just use size_t for the loop.

Apply previous change ("Don't mix sign and unsigned operands. Just use
size_t for the loop.") to another loop variable.

amdzentemp(4): Add Zen 3 support.

amdzentemp(4): Add support for per CCD temperature sensor from FreeBSD.

Fix build failure on i386.

Rename for AMD F15/6X device. No functional change.
amdsmn(4),amdzentemp(4): Add support for 17h/6xh and 19h/6xh.

Note that these drivers are present on some newer AMD Family 15h
processors.

amdsmn.4: Now support AMD Family 19h processors.
 1.7.2.2 05-Feb-2018  martin Pull up following revision(s) (requested by pgoyette in ticket #524):

distrib/sets/lists/man/mi 1.1574
distrib/sets/lists/modules/md.amd64 1.73
distrib/sets/lists/modules/md.i386 1.76
share/man/man4/amdtemp.4 1.11
share/man/man4/man4.x86/Makefile 1.17
share/man/man4/man4.x86/amdsmn.4 1.1-1.3
share/man/man4/man4.x86/amdzentemp.4 1.1-1.6
sys/arch/amd64/conf/ALL 1.79,1.80
sys/arch/amd64/conf/GENERIC 1.482,1.484
sys/arch/amd64/conf/XEN3_DOM0 1.146,1.147
sys/arch/x86/pci/amdsmn.c 1.1-1.2
sys/arch/x86/pci/amdsmn.h 1.1
sys/arch/x86/pci/amdzentemp.c 1.1-1.7
sys/arch/x86/pci/files.pci 1.22,1.23
sys/modules/amdzentemp/amdzentemp.ioconf 1.2


Add amdzentemp from FreeBSD via Ian Clark.

man pages for amdsmn and amdzentemp.

Some clean-up on the HISTORY and AUTHORS sections, and addition of a BUGS
section to document the fact that we don't yet handle the required temp
offset, nor do we expose the available thermal-trip value.

Add missing article 'a'

KNF: Put back the blank line following the empty variable declarations
Put back the variable declaration, too, and mark it __diagused
Otherwise a DIAGNOSTIC kernel will complain about the variable being
undeclared.

Correct placement of __diagused attribute.

Modularize the amdsmn(4) driver, and update dependency for amdzentemp(4),
Create amdsmn(4) amd amdzentemp(4) modules for X86.
 1.7.2.1 26-Jan-2018  martin file amdzentemp.c was added on branch netbsd-8 on 2018-02-05 13:06:55 +0000
 1.9.8.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.9.2.5 22-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1720):

sys/arch/x86/pci/amdzentemp.c: revision 1.20
sys/arch/x86/pci/amdsmn.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.19

Add Zen4 Ryzen "Phoenix" support.
Add Zen2 Mendocino APU support.
Add Zen4 Phoenix support.
 1.9.2.4 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1644):

sys/arch/x86/pci/amdsmn.c: revision 1.16
sys/arch/x86/pci/amdzentemp.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.18

Reduce diff against DragonFly. No functional change.
amdsmn(4),amdzentemp(4): Add Zen3+ Rembrandt(19h/4xh) & Zen4 Genoa(19h/1xh).
 1.9.2.3 23-Jan-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1572):

sys/arch/x86/pci/amdzentemp.c: revision 1.16

match zen3 "cezanne" (ryzen 5000-series APU.)
 1.9.2.2 11-Oct-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1539):

share/man/man4/man4.x86/amdsmn.4: revision 1.5
sys/arch/x86/pci/amdsmn.c: revision 1.14
sys/arch/x86/pci/amdzentemp.c: revision 1.12-1.15

amdzentemp(4): Add Zen 3 support.

amdzentemp(4): Add support for per CCD temperature sensor from FreeBSD.

Fix build failure on i386.

amdsmn(4),amdzentemp(4): Add support for 17h/6xh and 19h/6xh.

amdsmn.4: Now support AMD Family 19h processors.
 1.9.2.1 24-Apr-2020  martin Pull up following revision(s) (requested by simonb in ticket #851):

share/man/man4/man4.x86/amdzentemp.4: revision 1.7
share/man/man4/man4.x86/amdsmn.4: revision 1.4
sys/arch/x86/pci/amdsmn.c: revision 1.7
sys/arch/x86/pci/amdsmn.c: revision 1.8
sys/arch/x86/pci/amdsmn.c: revision 1.9
sys/arch/x86/pci/amdzentemp.c: revision 1.10

Update to support Family 15h Model 60 temperature sensors.

Changes based on FreeBSD amdtemp driver changes by Conrad Meyer.
XXX: Some code duplication between this driver and amdtemp as
parts of the 15h refresh code share more in common with
older CPUs while accessing the device more like 17h.
--
Note that these drivers are present on some newer AMD Family 15h
processors.
--
Don't mix sign and unsigned operands. Just use size_t for the loop.
--
Apply previous change ("Don't mix sign and unsigned operands. Just use
size_t for the loop.") to another loop variable.
--
 1.11.10.1 06-Jun-2021  cjep sync with head
 1.11.6.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.16.2.3 09-Oct-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #940):

sys/arch/x86/pci/amdzentemp.c: revision 1.21

amdzentemp(4): Add support for CPU family 0x1a model 0x40...0x4f (Zen 5)
 1.16.2.2 22-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #335):

sys/arch/x86/pci/amdzentemp.c: revision 1.20
sys/arch/x86/pci/amdsmn.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.19

Add Zen4 Ryzen "Phoenix" support.
Add Zen2 Mendocino APU support.
Add Zen4 Phoenix support.
 1.16.2.1 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #198):

sys/arch/x86/pci/amdsmn.c: revision 1.16
sys/arch/x86/pci/amdzentemp.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.18

Reduce diff against DragonFly. No functional change.
amdsmn(4),amdzentemp(4): Add Zen3+ Rembrandt(19h/4xh) & Zen4 Genoa(19h/1xh).
 1.20.6.1 02-Aug-2025  perseant Sync with HEAD
 1.13 15-Sep-2025  thorpej No longer need to include acpi_i2c.h here.
 1.12 15-Sep-2025  thorpej Do the ACPI-specific get-child-devices dance in iic_attach(). This
obviously isn't ideal, but it funnels the issue into a central location
and provides for easier improvement later.
 1.11 11-Nov-2024  martin Add missing include of "acpica.h", pointed out by Jared.
 1.10 29-Apr-2024  andvar branches: 1.10.2;
Make dwiic_pci compile without ACPI option.
 1.9 19-Oct-2022  riastradh dwiic(4): Don't try to attach children if dwiic_attach failed.

PR kern/57063
 1.8 27-Oct-2021  msaitoh Add more Jasper Lake and Elkhart Lake devices.
 1.7 27-Oct-2021  msaitoh Add many Intel I2C devices.
 1.6 07-Aug-2021  thorpej branches: 1.6.2;
Merge thorpej-cfargs2.
 1.5 29-May-2021  riastradh branches: 1.5.4;
dwiic(4): Attribute output correctly and relegate to debug-level.

Tidy up a little while here.
 1.4 24-Apr-2021  thorpej branches: 1.4.2; 1.4.4;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.3 26-Jan-2021  jmcneill branches: 1.3.2;
Add a device_t parameter to acpi_enter_i2c_devs. If non-NULL, all child
acpi_devnodes will be claimed by that device so we don't later try to
attach a duplicate device to that node at acpinodebus.
 1.2 26-Sep-2018  jakllsch branches: 1.2.4; 1.2.12;
Add dwiic_fdt attachment for "snps,designware-i2c".
 1.1 10-Dec-2017  bouyer branches: 1.1.2; 1.1.4;
Add support for I2C designware controllers (as found in Intel PCH devices),
with a pci front-end.
The pci front-end is tied to ACPI and Intel-specific, so it's in arch/x86/pci
and not dev/pci.
Core driver from OpenBSD, PCI front-end by me.
 1.1.4.1 10-Jun-2019  christos Sync with HEAD
 1.1.2.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.2.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2.4.1 21-Jun-2021  martin Pull up following revision(s) (requested by riastradh in ticket #1303):

sys/arch/x86/pci/dwiic_pci.c: revision 1.5 (patch)

dwiic(4): Attribute output correctly and relegate to debug-level.

Tidy up a little while here.
 1.3.2.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.4.4.1 31-May-2021  cjep sync with head
 1.4.2.3 17-Jun-2021  thorpej Sync w/ HEAD.
 1.4.2.2 25-Apr-2021  thorpej - Don't use acpi_enter_i2c_devs() -- it no longer exists.
- Pass along our devhandle to the i2c bus instance.
 1.4.2.1 25-Apr-2021  thorpej acpi_i2c.h is no more.
 1.5.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6.2.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.10.2.1 02-Aug-2025  perseant Sync with HEAD
 1.27 12-Apr-2023  riastradh ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.

Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.26 24-Apr-2021  thorpej branches: 1.26.16;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.25 14-Oct-2020  ryo branches: 1.25.4;
vmx(4) should be MI. moved to sys/dev/pci from sys/arch/x86/pci
 1.24 01-Mar-2018  mrg move the imc code into x86/pci/files.pci so that pci is defined in time.
 1.23 27-Jan-2018  christos provide an intermediate "bus" for the module and to be the same structure
like amdtemp
 1.22 25-Jan-2018  christos Add amdzentemp from FreeBSD via Ian Clark
 1.21 10-Dec-2017  bouyer Add support for I2C designware controllers (as found in Intel PCH devices),
with a pci front-end.
The pci front-end is tied to ACPI and Intel-specific, so it's in arch/x86/pci
and not dev/pci.
Core driver from OpenBSD, PCI front-end by me.
 1.20 03-May-2015  pgoyette branches: 1.20.10;
Separate the watchdog code from the pcib code, and make the watchdog
a loadable module.
 1.19 11-Nov-2014  christos branches: 1.19.2;
add an agp dependency so that the agp drivers get loaded.
 1.18 18-Oct-2014  uebayasi Install agp_* drivers where pchb(4) is installed except INSTALL_FLOPPY.

XXX
Config around agp(4) is done in quite wrong direction.
"pchb <- (agpbus) <- agp <- agp_*"
should be:
"pchb <- (pcibus) <- agp_* <- (agpbus) <- agp"
 1.17 17-Oct-2014  uebayasi Fix another indirect circular dependency (agp_* -> (agpbus) -> pchb -> abp_*).
Fixes "no agp*" build. Reported & build-tested by Kurt Schreiner.
 1.16 10-Jun-2014  hikaru Add VMware VMXNET3 ethernet driver from OpenBSD, vmx(4).
 1.15 05-Dec-2012  christos branches: 1.15.10;
Intel Atom E600 PCI-LPC bridge, adds a watchdog + HPET support. Tested
on a Soekris net6501. (jmcneill)
 1.14 13-Apr-2012  cegger branches: 1.14.2;
Replace amdtempbus with amdnb_miscbus.
This allows us to have independent drivers on the same device (northbridge f3)
each coming with a certain functionality/feature.
This way we do not need to mess with amdtemp(4) to utilize other features.
 1.13 18-Aug-2011  jakllsch branches: 1.13.2; 1.13.6;
Attach amdtemp(4) at pchb(4) instead of in place of pchb(4).

Should fix PR#45268.
 1.12 15-Jun-2011  jruoho Factor out hpet(4) from ichlpcib(4).
 1.11 04-Apr-2011  bouyer branches: 1.11.2;
Add a driver for RDC's vortex86/PMX-1000 SoC PCI/ISA bridge, with support
for the integrated watchdog timer.
 1.10 23-Jul-2010  jakllsch branches: 1.10.2;
Almost entirely rework Intel Firmware Hub random number generator support.

This introduces fwhrng(4) which attaches via ichlpcib(4), replacing
the rnd(4) support in pchb(4).
 1.9 14-May-2010  phx gcscpcib depends on functions from x86/pci/pcib.c
 1.8 27-Sep-2009  jakllsch branches: 1.8.2; 1.8.4;
gpio(4) support for Intel ICH southbridges.

Tested on Intel SS4200-E (ICH7), and Acorp 6A815EPD (ICH2) motherboards,
on amd64 and i386 ports respectively.

It should be noted that the majority of boards with ICH chips do not
expose the GPIO pins for off-board use. For instance, aside from the
three exposed-on-a-header pins on the 6A815EPD, another pin is also
used to control write protect on the FWH. The SS4200 exposes the GPIO
on a header that connects to the 10 LEDs on the front panel, as well
as a tact switch on the back panel.
 1.7 03-Aug-2008  joerg branches: 1.7.8;
Move some MD declarations from x86/pci/files.pci to x86/conf/files.x86,
so that Xen can use the former.

Drop Xen's pcib.c in favor of the x86 code and thereby unbreak ichlpcib.
 1.6 18-May-2008  jmcneill branches: 1.6.4;
Add support for PCI_BUS_FIXUP and PCI_ADDR_FIXUP on amd64.
 1.5 22-Apr-2008  cegger branches: 1.5.2; 1.5.4;
amdtemp(4): Driver for AMD CPU Temperature Sensors. Adopted from OpenBSD's kate(4).
Changes beyond OpenBSD's driver:
- Improved support for AMD K8
- Added support for AMD Barcelona, AMD Phenom and AMD Griffin
Tested on various single and multi-socket machines.
Review and OK xtreame
 1.4 09-Dec-2007  jmcneill branches: 1.4.10; 1.4.12;
Merge jmcneill-pm branch.
 1.3 26-Oct-2007  xtraeme branches: 1.3.2; 1.3.6; 1.3.8; 1.3.10; 1.3.12;
Share pcib(4) and amdpcib(4) between i386 and amd64; one copy is enough.
 1.2 26-Oct-2007  xtraeme - Share pchb(4) between i386 and amd64; one copy is enough for both.
- Move some of the x86 PCI devices into x86/pci/files.pci.
- Add more x86 stuff into x86/conf/files.x86.

ok joerg.
 1.1 04-Sep-2007  joerg branches: 1.1.2; 1.1.6;
file files.pci was initially added on branch jmcneill-pm.
 1.1.6.1 13-Nov-2007  bouyer Sync with HEAD
 1.1.2.4 28-Oct-2007  joerg Sync with HEAD.
 1.1.2.3 05-Sep-2007  joerg Correctly attach HPET on ichlpcib. Patch and hints how to do this
from cube@
 1.1.2.2 04-Sep-2007  joerg Don't use a global variable to decide whether this is a ICH6+,
use a variable in the softc to determine whether the RCBA is supported.
Add generic HPET support for ICH5 and ICH6+.

This is not (yet) enabled by default, until someone adds the code to
not use the direct attachment if hpet was configured via ACPI.
 1.1.2.1 04-Sep-2007  joerg Move common PCI devices on i386 and amd64 into a arch/x86/pci/fils.pci.
 1.3.12.1 11-Dec-2007  yamt sync with head.
 1.3.10.1 26-Dec-2007  ad Sync with head.
 1.3.8.2 03-Dec-2007  ad Sync with HEAD.
 1.3.8.1 26-Oct-2007  ad file files.pci was added on branch vmlocking on 2007-12-03 19:04:26 +0000
 1.3.6.3 09-Jan-2008  matt sync with HEAD
 1.3.6.2 06-Nov-2007  matt sync with HEAD
 1.3.6.1 26-Oct-2007  matt file files.pci was added on branch matt-armv6 on 2007-11-06 23:23:41 +0000
 1.3.2.3 21-Jan-2008  yamt sync with head
 1.3.2.2 27-Oct-2007  yamt sync with head.
 1.3.2.1 26-Oct-2007  yamt file files.pci was added on branch yamt-lazymbuf on 2007-10-27 11:28:58 +0000
 1.4.12.1 18-May-2008  yamt sync with head.
 1.4.10.2 28-Sep-2008  mjf Sync with HEAD.
 1.4.10.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.4.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.5.4.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5.2.3 11-Aug-2010  yamt sync with head.
 1.5.2.2 11-Mar-2010  yamt sync with head
 1.5.2.1 04-May-2009  yamt sync with head.
 1.6.4.1 19-Oct-2008  haad Sync with HEAD.
 1.7.8.4 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.7.8.3 02-May-2011  jym Sync with head.
 1.7.8.2 24-Oct-2010  jym Sync with HEAD
 1.7.8.1 01-Nov-2009  jym Sync with HEAD.
 1.8.4.3 21-Apr-2011  rmind sync with head
 1.8.4.2 05-Mar-2011  rmind sync with head
 1.8.4.1 30-May-2010  rmind sync with head
 1.8.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.10.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.13.6.1 29-Apr-2012  mrg sync to latest -current.
 1.13.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.13.2.1 17-Apr-2012  yamt sync with head
 1.14.2.3 03-Dec-2017  jdolecek update from HEAD
 1.14.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.2.1 25-Feb-2013  tls resync with head
 1.15.10.1 10-Aug-2014  tls Rebase.
 1.19.2.1 06-Jun-2015  skrll Sync with HEAD
 1.20.10.1 05-Feb-2018  martin Pull up following revision(s) (requested by pgoyette in ticket #524):

distrib/sets/lists/man/mi 1.1574
distrib/sets/lists/modules/md.amd64 1.73
distrib/sets/lists/modules/md.i386 1.76
share/man/man4/amdtemp.4 1.11
share/man/man4/man4.x86/Makefile 1.17
share/man/man4/man4.x86/amdsmn.4 1.1-1.3
share/man/man4/man4.x86/amdzentemp.4 1.1-1.6
sys/arch/amd64/conf/ALL 1.79,1.80
sys/arch/amd64/conf/GENERIC 1.482,1.484
sys/arch/amd64/conf/XEN3_DOM0 1.146,1.147
sys/arch/x86/pci/amdsmn.c 1.1-1.2
sys/arch/x86/pci/amdsmn.h 1.1
sys/arch/x86/pci/amdzentemp.c 1.1-1.7
sys/arch/x86/pci/files.pci 1.22,1.23
sys/modules/amdzentemp/amdzentemp.ioconf 1.2


Add amdzentemp from FreeBSD via Ian Clark.

man pages for amdsmn and amdzentemp.

Some clean-up on the HISTORY and AUTHORS sections, and addition of a BUGS
section to document the fact that we don't yet handle the required temp
offset, nor do we expose the available thermal-trip value.

Add missing article 'a'

KNF: Put back the blank line following the empty variable declarations
Put back the variable declaration, too, and mark it __diagused
Otherwise a DIAGNOSTIC kernel will complain about the variable being
undeclared.

Correct placement of __diagused attribute.

Modularize the amdsmn(4) driver, and update dependency for amdzentemp(4),
Create amdsmn(4) amd amdzentemp(4) modules for X86.
 1.25.4.2 28-Mar-2021  thorpej Minor rearrangement of the deck chairs to group things together.
 1.25.4.1 23-Mar-2021  thorpej Remove unneceesary "imcsmb" attribute from "imc".
 1.26.16.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #282):

sys/dev/pci/ichsmb.c: revision 1.82
sys/arch/amd64/conf/GENERIC: revision 1.602
sys/arch/x86/pci/tco.c: revision 1.10
sys/arch/x86/pci/tco.h: revision 1.5
sys/arch/x86/pci/ichlpcib.c: revision 1.59
sys/dev/ic/i82801lpcreg.h: revision 1.17
sys/arch/x86/pci/files.pci: revision 1.27
sys/dev/pci/files.pci: revision 1.446

ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.
Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.9 13-Apr-2015  riastradh Convert arch/x86 to use <sys/rnd*.h>. Omit needless includes.
 1.8 16-Nov-2014  ozaki-r branches: 1.8.2;
Replace callout_stop with callout_halt

In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.

Discussed with martin@ and riastradh@.
 1.7 10-Aug-2014  tls branches: 1.7.2;
Merge tls-earlyentropy branch into HEAD.
 1.6 17-Oct-2013  christos branches: 1.6.2;
remove set but unused variables
 1.5 02-Feb-2012  tls branches: 1.5.2; 1.5.6; 1.5.10;
Entropy-pool implementation move and cleanup.

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

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

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

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

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

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.4 19-Nov-2011  tls branches: 1.4.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.3 01-Jul-2011  dyoung branches: 1.3.2;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.2 23-Aug-2010  jakllsch branches: 1.2.2; 1.2.8;
Move FWH chip detection area entirely within the mapping for
the smaller i82802AB. This is needed as not all BIOSes set a
larger-than-necessary decode range.
 1.1 23-Jul-2010  jakllsch branches: 1.1.2; 1.1.4;
Almost entirely rework Intel Firmware Hub random number generator support.

This introduces fwhrng(4) which attaches via ichlpcib(4), replacing
the rnd(4) support in pchb(4).
 1.1.4.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.4.1 23-Jul-2010  uebayasi file fwhrng.c was added on branch uebayasi-xip on 2010-08-17 06:45:32 +0000
 1.1.2.3 09-Oct-2010  yamt sync with head
 1.1.2.2 11-Aug-2010  yamt sync with head.
 1.1.2.1 23-Jul-2010  yamt file fwhrng.c was added on branch yamt-nfs-mp on 2010-08-11 22:52:56 +0000
 1.2.8.2 05-Mar-2011  rmind sync with head
 1.2.8.1 23-Aug-2010  rmind file fwhrng.c was added on branch rmind-uvmplock on 2011-03-05 20:52:28 +0000
 1.2.2.3 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.2.2.2 24-Oct-2010  jym Sync with HEAD
 1.2.2.1 23-Aug-2010  jym file fwhrng.c was added on branch jym-xensuspend on 2010-10-24 22:48:17 +0000
 1.3.2.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.2.1 17-Apr-2012  yamt sync with head
 1.4.2.1 18-Feb-2012  mrg merge to -current.
 1.5.10.1 18-May-2014  rmind sync with head
 1.5.6.2 03-Dec-2017  jdolecek update from HEAD
 1.5.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.2.1 07-Dec-2014  martin Pull up following revision(s) (requested by ozaki-r in ticket #1201):
sys/kern/kern_ktrace.c: revision 1.166
sys/dev/isa/aps.c: revision 1.16
sys/dev/sysmon/sysmonvar.h: revision 1.45
sys/dev/ir/irframe_tty.c: revision 1.60
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.111-1.112 (patch)
sys/dev/pci/pccbb.c: revision 1.207
sys/dev/wscons/wskbd.c: revision 1.135
sys/dev/usb/ohci.c: revision 1.254
sys/net/if_ecosubr.c: revision 1.41
sys/dev/pcmcia/btbc.c: revision 1.17
sys/arch/x86/x86/via_padlock.c: revision 1.23
sys/dev/sdmmc/sdmmc.c: revision 1.23 (patch)
sys/dev/bluetooth/btkbd.c: revision 1.17
sys/dev/bluetooth/bcsp.c: revision 1.25
sys/arch/x86/pci/fwhrng.c: revision 1.8
sys/dev/ic/nslm7x.c: revision 1.61
share/man/man9/callout.9: revision 1.28 (patch)

Replace callout_stop with callout_halt and ensure the callout
is not running before destroying it.
 1.6.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

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

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

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.7.2.1 01-Dec-2014  martin Pull up following revision(s) (requested by ozaki-r in ticket #279):
sys/kern/kern_ktrace.c: revision 1.166
sys/dev/isa/aps.c: revision 1.16
sys/dev/sysmon/sysmonvar.h: revision 1.45
sys/dev/ir/irframe_tty.c: revision 1.60
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.111
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.112
sys/dev/pci/pccbb.c: revision 1.207
sys/dev/wscons/wskbd.c: revision 1.135
sys/dev/usb/ohci.c: revision 1.254
sys/net/if_ecosubr.c: revision 1.41
sys/dev/pcmcia/btbc.c: revision 1.17
sys/arch/x86/x86/via_padlock.c: revision 1.23
sys/dev/sdmmc/sdmmc.c: revision 1.23
sys/dev/bluetooth/btkbd.c: revision 1.17
sys/dev/bluetooth/bcsp.c: revision 1.25
sys/arch/x86/pci/fwhrng.c: revision 1.8
sys/dev/ic/nslm7x.c: revision 1.61
share/man/man9/callout.9: revision 1.28
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
Discussed with martin@ and riastradh@.
Make it clear that we should use not callout_stop but callout_halt
before callout_destroy
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
In this case, we need to pass an interlock to callout_halt to wait for
the callout complete.
Reviewed by riastradh@.
Kill sme_callout_mtx and use sme_mtx instead
We can use sme_mtx for the callout as well. Actually we should do so
because sme_events_list and some other data that are touched in the
callout should be protected by sme_mtx, not sme_callout_mtx.
Discussed with riastradh@ in
http://mail-index.netbsd.org/tech-kern/2014/11/11/msg017956.html
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
In this case, we need to pass an interlock to callout_halt to wait for
the callout complete. And also we make sure that SME_CALLOUT_INITIALIZED
is unset before calling callout_halt to prevent the callout from calling
callout_schedule. This is the same as what we did in sys/netinet6/mld6.c@1.61.
Reviewed by riastradh@.
 1.8.2.1 06-Jun-2015  skrll Sync with HEAD
 1.4 23-Aug-2010  jakllsch Move FWH chip detection area entirely within the mapping for
the smaller i82802AB. This is needed as not all BIOSes set a
larger-than-necessary decode range.
 1.3 23-Jul-2010  jakllsch Almost entirely rework Intel Firmware Hub random number generator support.

This introduces fwhrng(4) which attaches via ichlpcib(4), replacing
the rnd(4) support in pchb(4).
 1.2 03-Nov-2009  snj branches: 1.2.2; 1.2.4;
Drop 3rd and 4th clauses, as the copyright holder (Michael Shalayeff) did
in OpenBSD revision 1.2.
 1.1 12-Feb-2006  tron branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22; 1.1.80; 1.1.94;
Share Intel hardware random number generator support between amd64 and
i386 port. This will benefit EM64T systems using Intel i9xx chipsets.
 1.1.94.1 24-Oct-2010  jym Sync with HEAD
 1.1.80.3 09-Oct-2010  yamt sync with head
 1.1.80.2 11-Aug-2010  yamt sync with head.
 1.1.80.1 11-Mar-2010  yamt sync with head
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 12-Feb-2006  rpaulo file i82802reg.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:44:49 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 12-Feb-2006  yamt file i82802reg.h was added on branch yamt-lazymbuf on 2006-06-21 14:57:56 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 12-Feb-2006  simonb file i82802reg.h was added on branch simonb-timecounters on 2006-04-22 11:38:09 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 12-Feb-2006  yamt file i82802reg.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:54 +0000
 1.2.4.1 05-Mar-2011  rmind sync with head
 1.2.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.2.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.62 18-Dec-2024  hans Add support for the Braswell PCU LPC to ichlpcib.
 1.61 09-May-2023  riastradh branches: 1.61.6;
ichlpcib(4): Use config_detach_children.

Delete a lot of unnecessary code with broken error branches involving
config_detach which have probably seldom if ever been exercised.

No substantive functional change intended. Low risk because
ichlpcib(4) is not a removable device, so you have to go out of your
way to exercise detach.
 1.60 09-May-2023  riastradh ichlpcib(4): KNF. No functional change intended.
 1.59 12-Apr-2023  riastradh ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.

Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.58 22-Sep-2022  riastradh branches: 1.58.4;
ichlpcib(4), tco(4): Rename iot -> pmt, ioh -> pmh.

Makes it clearer that this is specifically about the power management
controller (PMC) registers relative to PMBASE.
 1.57 22-Sep-2022  riastradh ichlpcib(4), tco(4): Take `lpcib_' off various names.

For PMC-specific ones, change `lpcib_' to `pmc_'. These are in a
separate PCI device in newer chipsets.

For TCO-specific ones, which may live in different places, whether at
their own base address or as an offset from PMBASE, just leave it as
`tco_' or `tcotimer'.

No functional change intended.
 1.56 22-Sep-2022  riastradh tco(4): Rename lpcib_tco_attach_args -> tco_attach_args.

No longer hangs off LPC bus, newer devices hang it off SMBus.
 1.55 22-Sep-2022  riastradh tco(4): Change has_rcba bit into version number.

Will be useful for newer Intel platform controller hubs.

No functional change intended. Module ABI is unchanged, although older
modules will do something nonseneical when confronted with versions
above 1 -- that will require a revbump (but with any luck, it will make
life easier for versions above 2 easier once we do that).
 1.54 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.53 24-Apr-2021  thorpej branches: 1.53.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.52 03-Jun-2018  maxv branches: 1.52.16;
Constify lpcib_devices[] so that it lands in .rodata (1584 bytes).
 1.51 06-Aug-2016  jakllsch branches: 1.51.14;
Disable gpio(4) attachment to ichlpcib(4) by default.

The GPIO lines on an ICH are usually connected to opaque platform-
defined functionality, and may be manipulated by the ACPI DSDT or other
mechanisms behind our backs. In one instance, it was found this
in combiation with gpio_resume() sabotaged repeated suspend/resume cycles.

GPIO functionality can be enabled by setting ichlpcib_gpio_disable to 0,
for instance with `gdb -write`.
 1.50 17-May-2015  msaitoh Add Core 5G (mobile) LPC support.
 1.49 03-May-2015  pgoyette Separate the watchdog code from the pcib code, and make the watchdog
a loadable module.
 1.48 20-Mar-2015  msaitoh Add Intel C61x and X99 devices.
 1.47 18-Mar-2015  msaitoh Add 9 Series support.
 1.46 13-Jan-2015  msaitoh As I wrote in the last commit, The PMBASE and GPIOBASE registers are not
compltible with the PCI spec and the map sizes are fixed to 128bytes. The
pci_mapreg_submap() function has a code to check the range of the BAR. The
PCI_MAPREG_IO_SIZE() macro returns lower than 128bytes on some machines.
It makes impossible to use pci_mapreg_submap(). Use pci_conf_read() and
bus_space_map() directly. Observed and tested with my Thinkpad X61.
 1.45 26-Dec-2014  msaitoh Fix a bug that ichlpcib(4) maps I/O area incorrectly and then fails to attach
gpio. It might also fix ACPI related problem described in PR#48960:
- The LPCIB_PCI_PMBASE and LPCIB_PCI_GPIO register are alike PCI BAR but not
completely compatible with it. It's ok because the registers' addresses are
out of BAR0-BAR5(0x10-0x24) and are located in the device-dependent header.
The PMBASE and GPIO registers define the base address and the type but not
describe the size. The size is fixed to 128bytes. So use
pci_mapreg_submap().
- Make pci_mapreg_submap() extern again.
- Fix the calculation of the map size in pci_mapreg_submap().
 1.44 15-Dec-2014  msaitoh Add DH89xxC[CL] LPC devices.
 1.43 04-Jan-2014  msaitoh branches: 1.43.4; 1.43.6;
Add Z68 LPC.
 1.42 04-Jan-2014  msaitoh Temporary disable C2000 PCU because the behavior of the wdog is little strange.
 1.41 03-Jan-2014  msaitoh Add C2000 Platform Controller Unit(PCU).
 1.40 17-Sep-2013  jakllsch Use '\n' at the end of all aprint_error_dev() format strings.
 1.39 04-Jun-2013  msaitoh branches: 1.39.2;
Add Intel 8 Series / C220 Series LPC devices.
 1.38 12-Jan-2013  riastradh Match the C600's ichlpcib.
 1.37 19-Dec-2012  msaitoh Add Intel 7 series' LPC devices.
 1.36 06-Dec-2012  msaitoh Add support 3400 series, 5 series, C216, 82801GH, 82801E and 6300ESB.
 1.35 06-Dec-2012  msaitoh No functional change:
- Remove trailing white space.
- Sort entries.
- Remove duplicated entries.
 1.34 17-Nov-2011  riz branches: 1.34.6; 1.34.10;
Also match ICH8, ICH9 and ICH10 devices. Tested on ICH10.
 1.33 14-Aug-2011  msaitoh branches: 1.33.2;
Add some LPC entries for Intel 6 series and C20x.
 1.32 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.31 15-Jun-2011  jruoho Factor out hpet(4) from ichlpcib(4).
 1.30 06-Jun-2011  msaitoh Rename to use PCI_PRODUCT_INTEL_82801DBM_LPC
 1.29 04-Apr-2011  dyoung branches: 1.29.2;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.28 06-Sep-2010  christos branches: 1.28.2;
make it compile.
 1.27 17-Aug-2010  jakllsch Match ichlpcib(4) on ICH0 (82801AB_LPC).
 1.26 23-Jul-2010  jakllsch Finish cleaning up pchb from recent change.
Use fewer magic numbers in ichlpcib.
Slightly improve style conformance.
Update paths in cpp re-inclusion guards.
 1.25 23-Jul-2010  jakllsch Almost entirely rework Intel Firmware Hub random number generator support.

This introduces fwhrng(4) which attaches via ichlpcib(4), replacing
the rnd(4) support in pchb(4).
 1.24 24-Feb-2010  dyoung branches: 1.24.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.23 08-Jan-2010  dyoung branches: 1.23.2;
Expand PMF_FN_* macros.
 1.22 08-Jan-2010  dyoung Move all copies of ifattr_match() to sys/kern/subr_autoconf.c.
 1.21 27-Sep-2009  jakllsch Make this build without gpio(4).
 1.20 27-Sep-2009  jakllsch gpio(4) support for Intel ICH southbridges.

Tested on Intel SS4200-E (ICH7), and Acorp 6A815EPD (ICH2) motherboards,
on amd64 and i386 ports respectively.

It should be noted that the majority of boards with ICH chips do not
expose the GPIO pins for off-board use. For instance, aside from the
three exposed-on-a-header pins on the 6A815EPD, another pin is also
used to control write protect on the FWH. The SS4200 exposes the GPIO
on a header that connects to the 10 LEDs on the front panel, as well
as a tact switch on the back panel.
 1.19 18-Aug-2009  dyoung Let us detach ichlpcib(4) and its children.

XXX More testing is needed. I've tested this on a Dell Dimension 3000,
XXX but that system does not attach every possible device that I try to
XXX detach with this code:

ichlpcib0 at pci0 dev 31 function 0
ichlpcib0: vendor 0x8086 product 0x24d0 (rev. 0x02)
timecounter: Timecounter "ichlpcib0" frequency 3579545 Hz quality 1000
ichlpcib0: 24-bit timer
ichlpcib0: TCO (watchdog) timer configured.
isa0 at ichlpcib0
 1.18 11-Aug-2009  bouyer Fix watchdog code:
- the timer bound constants are in tick, so convert period to tick before
checking it against the bounds
- for ICH5 or older, fix code that would have always written a 0 period
to the register.
 1.17 29-Apr-2009  njoly Attach 82801IEM LPC Interface Bridge too.
 1.16 04-Apr-2009  joerg Restore SpeedStep settings on shutdown. Some BIOSes don't like it, if
SpeedStep is enabled and powerdown fails otherwise. Fixes PR kern/40487.
 1.15 03-Mar-2009  mrg don't enable speedstep on systems with intel 82855GM host bridges.
 1.14 13-Oct-2008  joerg branches: 1.14.2; 1.14.4; 1.14.8;
Intel Tempest can use ichlpcib as well.
 1.13 14-Aug-2008  yamt revert some parts of the following commit.
(given that it reverted other developers' changes saying
"misc/cosmetic changes", i assume that it was unintentional.)
this makes a watchdog on my box (8086:24d0) work again.
----------------------------
revision 1.1
date: 2007/08/26 16:49:47; author: xtraeme; state: Exp;
branches: 1.1.2;
Some changes for the ichlpcib driver:

- Moved to x86/pci, so that EM64T systems running NetBSD/amd64 can use it.
- Added support for the TCO on ICH6 or newer chipsets, adapted from
FreeBSD.
- Added timecounter support for the power management timer, adapted from
OpenBSD.
- Plus some misc/cosmetic changes.

Thanks to yukonbob on irc@freenode for testing the TCO part on ICH4-M.
Tested by me with ICH7 too.
 1.12 20-Jul-2008  martin Make struct pcib_softc explicit in our softc.
 1.11 28-Apr-2008  martin branches: 1.11.2; 1.11.4; 1.11.6;
Remove clause 3 and 4 from TNF licenses
 1.10 16-Apr-2008  cegger branches: 1.10.2; 1.10.4;
- use aprint_*_dev and device_xname
- use POSIX integer types
 1.9 21-Mar-2008  xtraeme Split device_t/softc for ichlpcib(4) and all hpet consumers, plus
other related cosmetic changes.
 1.8 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.7 15-Jan-2008  drochner branches: 1.7.2; 1.7.6;
fix some unaligned PCI config space accesses in suspend/resume functions
 1.6 09-Dec-2007  jmcneill branches: 1.6.2;
Merge jmcneill-pm branch.
 1.5 23-Nov-2007  xtraeme branches: 1.5.2; 1.5.4;
tcotimer_setmode: convert seconds to ticks after the value has been
checked with the limits. We can use now the max timeout value on ICH6
or newer (i.e 613 seconds and not the half of it as previously).
 1.4 03-Sep-2007  xtraeme branches: 1.4.2; 1.4.4; 1.4.6; 1.4.10; 1.4.14;
Improve some comments.
 1.3 01-Sep-2007  ober Attach to ICH8M LPC.
Tested watchdog and it works.
ok xtraeme@
 1.2 29-Aug-2007  xtraeme Attach to the ICH9 LPC Interface Bridges. The datasheet doesn't mention
any difference in the TCO part (compared to ICH[678]).
 1.1 26-Aug-2007  xtraeme branches: 1.1.2;
Some changes for the ichlpcib driver:

- Moved to x86/pci, so that EM64T systems running NetBSD/amd64 can use it.
- Added support for the TCO on ICH6 or newer chipsets, adapted from
FreeBSD.
- Added timecounter support for the power management timer, adapted from
OpenBSD.
- Plus some misc/cosmetic changes.

Thanks to yukonbob on irc@freenode for testing the TCO part on ICH4-M.
Tested by me with ICH7 too.
 1.1.2.3 23-Mar-2008  matt sync with HEAD
 1.1.2.2 09-Jan-2008  matt sync with HEAD
 1.1.2.1 06-Nov-2007  matt sync with HEAD
 1.4.14.3 18-Feb-2008  mjf Sync with HEAD.
 1.4.14.2 27-Dec-2007  mjf Sync with HEAD.
 1.4.14.1 08-Dec-2007  mjf Sync with HEAD.
 1.4.10.3 03-Dec-2007  ad Sync with HEAD.
 1.4.10.2 09-Oct-2007  ad Sync with head.
 1.4.10.1 03-Sep-2007  ad file ichlpcib.c was added on branch vmlocking on 2007-10-09 13:38:43 +0000
 1.4.6.17 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.4.6.16 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.4.6.15 12-Nov-2007  joerg GC unused softc field.
 1.4.6.14 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.4.6.13 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.4.6.12 05-Sep-2007  cube Finish previous commit.
 1.4.6.11 05-Sep-2007  cube Avoid any future confusion by renaming the (unused) first argument of
lpci_hpet_match from "self" to "parent". Sprinkle a few device_t while
there.
 1.4.6.10 05-Sep-2007  joerg Try to map the HPET window in the match function to deal with the
possible ACPI attachmened HPET earlier and cleaner.
 1.4.6.9 05-Sep-2007  joerg Move variables into the branches where they are used. Make status
32bit wide to match the actual register operations.
 1.4.6.8 05-Sep-2007  joerg Correctly attach HPET on ichlpcib. Patch and hints how to do this
from cube@
 1.4.6.7 05-Sep-2007  jmcneill XXX because of pcibattach, we need to keep our softcs in sync with pcib(4)
 1.4.6.6 05-Sep-2007  joerg Push the mapping of the HPET register window into the attach function.
This should prevent DIAGNOSTIC from complaining when hpet is attached
via ACPI.
 1.4.6.5 04-Sep-2007  joerg Don't use a global variable to decide whether this is a ICH6+,
use a variable in the softc to determine whether the RCBA is supported.
Add generic HPET support for ICH5 and ICH6+.

This is not (yet) enabled by default, until someone adds the code to
not use the direct attachment if hpet was configured via ACPI.
 1.4.6.4 04-Sep-2007  joerg Merge back power management changes from arch/i386/pci/ichlpcib.c.
 1.4.6.3 04-Sep-2007  joerg Explicitly remember pci_attach_args and drop the corresponding argument
processing.
 1.4.6.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.4.6.1 03-Sep-2007  jmcneill file ichlpcib.c was added on branch jmcneill-pm on 2007-09-03 16:47:46 +0000
 1.4.4.6 24-Mar-2008  yamt sync with head.
 1.4.4.5 17-Mar-2008  yamt sync with head.
 1.4.4.4 21-Jan-2008  yamt sync with head
 1.4.4.3 07-Dec-2007  yamt sync with head
 1.4.4.2 03-Sep-2007  yamt sync with head.
 1.4.4.1 03-Sep-2007  yamt file ichlpcib.c was added on branch yamt-lazymbuf on 2007-09-03 14:31:22 +0000
 1.4.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.4.2.1 03-Sep-2007  skrll file ichlpcib.c was added on branch nick-csl-alignment on 2007-09-03 10:19:51 +0000
 1.5.4.1 11-Dec-2007  yamt sync with head.
 1.5.2.1 26-Dec-2007  ad Sync with head.
 1.6.2.1 19-Jan-2008  bouyer Sync with HEAD
 1.7.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.7.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.7.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.7.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.7.2.1 24-Mar-2008  keiichi sync with head.
 1.10.4.6 09-Oct-2010  yamt sync with head
 1.10.4.5 11-Aug-2010  yamt sync with head.
 1.10.4.4 11-Mar-2010  yamt sync with head
 1.10.4.3 19-Aug-2009  yamt sync with head.
 1.10.4.2 04-May-2009  yamt sync with head.
 1.10.4.1 16-May-2008  yamt sync with head.
 1.10.2.1 18-May-2008  yamt sync with head.
 1.11.6.1 19-Oct-2008  haad Sync with HEAD.
 1.11.4.1 28-Jul-2008  simonb Sync with head.
 1.11.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.14.8.5 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.14.8.4 02-May-2011  jym Sync with head.
 1.14.8.3 24-Oct-2010  jym Sync with HEAD
 1.14.8.2 01-Nov-2009  jym Sync with HEAD.
 1.14.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.14.4.4 26-Jan-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #1944):
sys/arch/x86/pci/ichlpcib.c: revision 1.46

The PMBASE and GPIOBASE registers are not compltible with the PCI spec
and the map sizes are fixed to 128bytes. The pci_mapreg_submap()
function has a code to check the range of the BAR. The
PCI_MAPREG_IO_SIZE() macro returns lower than 128bytes on some
machines. It makes impossible to use pci_mapreg_submap(). Use
pci_conf_read() and bus_space_map() directly.
 1.14.4.3 23-Jan-2015  martin Pull up the following changes, requested by msaitoh in ticket #1942:

sys/arch/x86/pci/ichlpcib.c 1.40, 1.45 via patch
sys/dev/ic/i82801lpcreg.h 1.12
sys/dev/pci/pci_map.c 1.32 via patch

- Fix a bug that ichlpcib(4) maps I/O area incorrectly. It might also
fixes ACPI related problem described in PR#48960:
- The LPCIB_PCI_PMBASE and LPCIB_PCI_GPIO register are alike PCI BAR
but not completely compatible with it. It's ok because the
registers' addresses are out of BAR0-BAR5(0x10-0x24) and are
located in the device-dependent header. The PMBASE and GPIO
registers define the base address and the type but not describe
the size. The size is fixed to 128bytes. So use
pci_mapreg_submap().
- Fix the calculation of the map size in pci_mapreg_submap().
- Use '\n' at the end of aprint_error_dev() format strings.
 1.14.4.2 16-Aug-2009  snj Pull up following revision(s) (requested by bouyer in ticket #912):
sys/arch/x86/pci/ichlpcib.c: revision 1.18
Fix watchdog code:
- the timer bound constants are in tick, so convert period to tick before
checking it against the bounds
- for ICH5 or older, fix code that would have always written a 0 period
to the register.
 1.14.4.1 07-Apr-2009  snj branches: 1.14.4.1.2; 1.14.4.1.4;
Pull up following revision(s) (requested by joerg in ticket #669):
sys/arch/x86/pci/ichlpcib.c: revision 1.16
Restore SpeedStep settings on shutdown. Some BIOSes don't like it, if
SpeedStep is enabled and powerdown fails otherwise. Fixes PR kern/40487.
 1.14.4.1.4.1 21-Apr-2010  matt sync to netbsd-5
 1.14.4.1.2.1 16-Aug-2009  snj Pull up following revision(s) (requested by bouyer in ticket #912):
sys/arch/x86/pci/ichlpcib.c: revision 1.18
Fix watchdog code:
- the timer bound constants are in tick, so convert period to tick before
checking it against the bounds
- for ICH5 or older, fix code that would have always written a 0 period
to the register.
 1.14.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.14.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.23.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.23.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.23.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.24.2.3 12-Jun-2011  rmind sync with head
 1.24.2.2 21-Apr-2011  rmind sync with head
 1.24.2.1 05-Mar-2011  rmind sync with head
 1.28.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.33.2.4 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.33.2.3 23-Jan-2013  yamt sync with head
 1.33.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.33.2.1 17-Apr-2012  yamt sync with head
 1.34.10.4 03-Dec-2017  jdolecek update from HEAD
 1.34.10.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.10.2 23-Jun-2013  tls resync from head
 1.34.10.1 25-Feb-2013  tls resync with head
 1.34.6.2 26-Jan-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #1239):
sys/arch/x86/pci/ichlpcib.c: revision 1.46
The PMBASE and GPIOBASE registers are not
compatible with the PCI spec and the map sizes are fixed to 128bytes. The
pci_mapreg_submap() function has a code to check the range of the BAR. The
PCI_MAPREG_IO_SIZE() macro returns lower than 128bytes on some machines.
This makes it impossible to use pci_mapreg_submap(). Use pci_conf_read() and
bus_space_map() directly.
 1.34.6.1 16-Jan-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1229):
sys/arch/x86/pci/ichlpcib.c: revision 1.40, 1.45
sys/dev/pci/pcivar.h: revision 1.101
sys/dev/pci/pci_map.c: revision 1.32
sys/dev/ic/i82801lpcreg.h: revision 1.12
Use '\n' at the end of all aprint_error_dev() format strings.
--
Fix a bug that ichlpcib(4) maps I/O area incorrectly and then fails to attach
gpio. It might also fixes ACPI related problem described in PR#48960:
- The LPCIB_PCI_PMBASE and LPCIB_PCI_GPIO register are alike PCI BAR but not
completely compatible with it. It's ok because the registers' addresses are
out of BAR0-BAR5(0x10-0x24) and are located in the device-dependent header.
The PMBASE and GPIO registers define the base address and the type but not
describe the size. The size is fixed to 128bytes. So use
pci_mapreg_submap().
- Make pci_mapreg_submap() extern again.
- Fix the calculation of the map size in pci_mapreg_submap().
 1.39.2.1 18-May-2014  rmind sync with head
 1.43.6.3 05-Oct-2016  skrll Sync with HEAD
 1.43.6.2 06-Jun-2015  skrll Sync with HEAD
 1.43.6.1 06-Apr-2015  skrll Sync with HEAD
 1.43.4.6 09-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1295):
sys/arch/x86/pci/ichlpcib.c: revision 1.50
Add Core 5G (mobile) LPC support.
 1.43.4.5 28-Aug-2016  snj branches: 1.43.4.5.2;
Pull up following revision(s) (requested by maya in ticket #1213):
sys/arch/x86/pci/ichlpcib.c: revision 1.51
Disable gpio(4) attachment to ichlpcib(4) by default.
The GPIO lines on an ICH are usually connected to opaque platform-
defined functionality, and may be manipulated by the ACPI DSDT or other
mechanisms behind our backs. In one instance, it was found this
in combiation with gpio_resume() sabotaged repeated suspend/resume cycles.
GPIO functionality can be enabled by setting ichlpcib_gpio_disable to 0,
for instance with `gdb -write`.
 1.43.4.4 30-Apr-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #725):
sys/arch/x86/pci/ichlpcib.c: revisions 1.47, 1.48
sys/dev/pci/ichsmb.c: revisions 1.39, 1.40, 1.41
sys/dev/pci/pucdata.c: revision 1.94
Add 9 Series support.
--
Add Intel C61x and X99 devices.
--
attach Mobile 5th Gen. Core SMBus
 1.43.4.3 17-Feb-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #528):
sys/dev/pci/ichsmb.c: revision 1.38
sys/dev/pci/pcidevs: revision 1.1206
sys/dev/pci/pcidevs: revision 1.1207
sys/arch/x86/pci/ichlpcib.c: revision 1.44
Change Intel 0x0434 entry:
- Rename DH89XX_QA to DH89XXCC_IQIA
- Modify the description to DH89xxCC PCIe Endpoint and QuickAssist
(include typo fix)
- Rename DH89xxCC's names from DH89XX_ to DH89XXCC_.
- Add some DH89xxCC's devices.
- Add DH89XXCL's devices.
- Rename PCI_PRODUCT_INTEL_DH89XX_SMB to PCI_PRODUCT_INTEL_DH89XXCC_SMB
- Add PCI_PRODUCT_INTEL_DH89XXCL_SMB
Add DH89xxC[CL] LPC devices.
 1.43.4.2 26-Jan-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #455):
sys/arch/x86/pci/ichlpcib.c: revision 1.46

The PMBASE and GPIOBASE registers are not compatible with the PCI spec
and the map sizes are fixed to 128bytes. The pci_mapreg_submap()
function has a code to check the range of the BAR. The
PCI_MAPREG_IO_SIZE() macro returns lower than 128bytes on some
machines. This makes it impossible to use pci_mapreg_submap(). Use
pci_conf_read() and bus_space_map() directly.
 1.43.4.1 08-Jan-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #394):
sys/dev/pci/pcivar.h: revision 1.101
sys/dev/pci/pci_map.c: revision 1.32
sys/dev/ic/i82801lpcreg.h: revision 1.12
sys/arch/x86/pci/ichlpcib.c: revision 1.45
Fix a bug that ichlpcib(4) maps I/O area incorrectly and then fails to attach
gpio. It might also fix ACPI related problem described in PR#48960:
- The LPCIB_PCI_PMBASE and LPCIB_PCI_GPIO register are alike PCI BAR but not
completely compatible with it. It's ok because the registers' addresses are
out of BAR0-BAR5(0x10-0x24) and are located in the device-dependent header.
The PMBASE and GPIO registers define the base address and the type but not
describe the size. The size is fixed to 128bytes. So use
pci_mapreg_submap().
- Make pci_mapreg_submap() extern again.
- Fix the calculation of the map size in pci_mapreg_submap().
 1.43.4.5.2.1 18-Jan-2017  skrll Sync with netbsd-5
 1.51.14.1 25-Jun-2018  pgoyette Sync with HEAD
 1.52.16.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.53.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.58.4.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #282):

sys/dev/pci/ichsmb.c: revision 1.82
sys/arch/amd64/conf/GENERIC: revision 1.602
sys/arch/x86/pci/tco.c: revision 1.10
sys/arch/x86/pci/tco.h: revision 1.5
sys/arch/x86/pci/ichlpcib.c: revision 1.59
sys/dev/ic/i82801lpcreg.h: revision 1.17
sys/arch/x86/pci/files.pci: revision 1.27
sys/dev/pci/files.pci: revision 1.446

ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.
Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.61.6.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Jul-2011  dyoung branches: 1.3.2;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.2 15-Jun-2011  jruoho branches: 1.2.2;
Modularize hpet(4). Works nicely with the multiple bus locations.
 1.1 15-Jun-2011  jruoho Factor out hpet(4) from ichlpcib(4).
 1.2.2.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.2.1 15-Jun-2011  cherry file ichlpcib_hpet.c was added on branch cherry-xenmp on 2011-06-23 14:19:48 +0000
 1.3.2.2 27-Aug-2011  jym Add/remove files, like in HEAD.
 1.3.2.1 01-Jul-2011  jym file ichlpcib_hpet.c was added on branch jym-xensuspend on 2011-08-27 15:59:49 +0000
 1.61 14-Oct-2020  ryo vmx(4) should be MI. moved to sys/dev/pci from sys/arch/x86/pci
 1.60 27-Apr-2020  yamaguchi Fix the wrong logic about making the number of vmx(4) TX/RX queue
be power of two

reviewed by nonaka@n.o.
 1.59 24-Mar-2020  knakahara fix vmx(4) cannot link up at boot time. reviewed by msaitoh@n.o, thanks.

vmx(4) could call if_link_state_change(ifp, LINK_STATE_UP) from vmxnet3_init()
before ifp->if_link_cansched was set, because dp->dom_if_up() (in6_if_up() for
INET6) could call ifp->if_init(). And then, workqueue_enqueue() was not called
at that time.
As the result, the last LQ_ITEM was stuck LINK_STATE_UP, so
if_link_state_change_work_schedule() was never called until
if_link_state_change(ifp, LINK_STATE_DOWN) was called.

To fix this issue, vmx(4) avoid calling if_link_state_change() before
ifp->if_link_cansched is set.
 1.58 15-Mar-2020  thorpej Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
access to media-related structures / hardware regsiters. Converted
drivers use the new ifmedia_init_with_lock() function for this. The
new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
a compatibility lock to be used instead. Several media-related entry
points must be aware of this compatibility lock, and are able to acquire
it recursively a limited number of times, if needed. This is a SPIN
mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex. The mcx driver still needs to be fully converted to
NET_MPSAFE.
 1.57 02-Feb-2020  thorpej - Adopt <net/if_stats.h>.
- Use ifmedia_fini().
 1.56 29-Jan-2020  knakahara Fix missing callout_destroy(). Pointed out by yamaguchi@n.o.
 1.55 29-Jan-2020  knakahara Fix typo in evcnt description. Pointed out by yamaguchi@n.o.
 1.54 06-Jan-2020  msaitoh branches: 1.54.2;
Protect ec_multicnt.
 1.53 24-Dec-2019  knakahara Fix missing splnet() for ether_ioctl() caused by if_vmx.c:r1.32.

pointed out by nonaka@n.o, thanks.
 1.52 27-Nov-2019  maxv localify
 1.51 10-Oct-2019  knakahara Fix kassert failure in vmxnet3_transmit(). Pointed out by ryo@n.o, thanks.
 1.50 30-Sep-2019  knakahara Fix typo in vmxnet3_legacy_intr().

That causes sysctl hw.vmx*.{rx,tx} effect inversely when vmx(4) uses
INTx or MSI.
 1.49 30-Aug-2019  knakahara vmxnet3_softc.vmx_stats should not count globally. pointed out by hikaru@n.o

divide vmxnet3_softc.vmx_stats to each vmxnet3_txqueue and vmxnet3_rxqueue,
furthermore make them evcnt.
 1.48 19-Aug-2019  knakahara add vmx(4) basic statistics counters.

Sorry, I have forgotten this TODO in r1.40 commit message.
 1.47 19-Aug-2019  knakahara fix panic when vmx(4) is detached.
 1.46 01-Aug-2019  knakahara vmx(4) uses interrupt distribution for each queue like ixg(4).
 1.45 30-Jul-2019  knakahara branches: 1.45.2;
vmx(4) can select workqueue for packet processing like ixg(4).
 1.44 29-Jul-2019  knakahara make vmx(4)'s *_process_limit tunable.
 1.43 29-Jul-2019  knakahara vmx(4) uses deferred interrupt handlering like ixg(4).
 1.42 29-Jul-2019  knakahara Fix missing NULL check after softint_establish().
 1.41 29-Jul-2019  knakahara Join Tx interrupt handler and Rx interrupt handler of vmx(4).

That can reduce interrupt resources.
 1.40 24-Jul-2019  knakahara vmx(4) support if_transmit and Tx multiqueue (2/2).

Fix Tx interrupt handler. I tested on ESXi 5.5.

TODO: add statistics counters
 1.39 24-Jul-2019  knakahara refactor: unify vmxnet3_start_locked and vmxnet_transmit_locked
 1.38 24-Jul-2019  knakahara vmx(4) support if_transmit and Tx multiqueue (1/2)

Implemented Tx processing only. Fix Tx interrupt handler later.
 1.37 23-Jul-2019  knakahara vmx(4) can be detached now.
 1.36 22-Jul-2019  knakahara remove unnecessary NULL check after kmem_zalloc(KM_SLEEP)
 1.35 19-Jul-2019  knakahara vmx(4) can be set IFEF_MPSAFE now.

I tested bidirectional forwarding with some ioctls.
 1.34 19-Jul-2019  knakahara Store IFF_ALLMULTI in ec->ec_flags instead of ifp->if_flags.

See such as if_wm.c:1.636.
 1.33 19-Jul-2019  knakahara vmx(4) enable jumbo frame.

I tested 1600 mtu to/from Linux vmxnet3.
 1.32 16-Jul-2019  knakahara Fix vmx(4) MTU setting.

Advised by hikaru@n.o and msaitoh@n.o, thanks.
 1.31 16-Jul-2019  knakahara Eliminate IFF_RUNNING checking code from vmxnet3_init_locked().

Advised by hikaru@n.o, thanks.
 1.30 09-Jul-2019  msaitoh Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.29 29-May-2019  msaitoh Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.28 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.27 20-Mar-2019  nonaka PR/54058: vmx(4): Fix device enable command failure when the number of vCPUs
is not a power of two.

Make the size of the vmx(4) TX/RX queue a power of two not exceeding
the number of vCPUs.
 1.26 26-Jun-2018  msaitoh branches: 1.26.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.25 01-Jun-2018  maxv Rename

M_CSUM_DATA_IPv6_HL -> M_CSUM_DATA_IPv6_IPHL
M_CSUM_DATA_IPv6_HL_SET -> M_CSUM_DATA_IPv6_SET

Reduces the diff against IPv4. Also, clarify the definitions.
 1.24 16-Apr-2018  nonaka vmx(4): compute if_ibytes using rxq->vxrxq_stats.vmrxs_ibytes.
 1.23 16-Apr-2018  nonaka vmx(4): handled SIOCZIFDATA.
 1.22 16-Apr-2018  nonaka vmx(4): Fix calculation of interface statistics counter.
 1.21 12-Feb-2018  maxv branches: 1.21.2;
m_free -> m_freem, otherwise leak
 1.20 26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.19 20-Feb-2017  knakahara branches: 1.19.6;
Apply deferred if_start to vmx(4).
 1.18 11-Jan-2017  maya branches: 1.18.2;
we cannot guarantee that m_pulldown doesn't fail, as it may fail even
if temporarily out of memory, and it will free the mbuf in this scenario.

test for failure and return error if it happens.

CID 1396651

ok riastradh
 1.17 11-Jan-2017  maya on error, free the mbuf in vmxnet3_txq_offload_ctx, not in callers.

ok riastradh
 1.16 11-Jan-2017  maya GC unused macros.

Even if they were used (and actually asserted), asserting on !mutex_owned
is generally a bad idea, as it may be true in unexpected contexts.

suggested by riastradh, thanks.
 1.15 28-Dec-2016  ozaki-r Protect ec_multi* with mutex

The data can be accessed from sysctl, ioctl, interface watchdog
(if_slowtimo) and interrupt handlers. We need to protect the data against
parallel accesses from them.

Currently the mutex is applied to some drivers, we need to apply it to all
drivers in the future.

Note that the mutex is adaptive one for ease of implementation but some
drivers access the data in interrupt context so we cannot apply the mutex
to every drivers as is. We have two options: one is to replace the mutex
with a spin one, which requires some additional works (see
ether_multicast_sysctl), and the other is to modify the drivers to access
the data not in interrupt context somehow.
 1.14 27-Dec-2016  hikaru Use the correct number of multicast addrs
 1.13 15-Dec-2016  ozaki-r Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.12 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.11 29-Nov-2016  dholland PR 51672 David Binderman: M_CSUM_TCPv6, not 2x M_CSUM_TCPv4.
(from context it's quite clear that's what's supposed to be here)
 1.10 28-Nov-2016  martin Mark a variable __diagused as it is only ever used in a KASSERT
 1.9 25-Nov-2016  hikaru Add missing bpf_mtap.
 1.8 25-Nov-2016  hikaru Sync code with FreeBSD to support RSS

- Use MSI/MSI-X if it is available.
- Support TSO.

co-authored by k-nakahara
 1.7 10-Jun-2016  ozaki-r branches: 1.7.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.6 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.5 14-Aug-2014  hikaru branches: 1.5.2; 1.5.4;
Set ifflags callback so that the device can enter promiscuous mode.
 1.4 19-Jul-2014  hikaru branches: 1.4.2; 1.4.4;
Correct return value handling.
m_defrag(9) is different from OpenBSD one,
it returns new mbuf pointer on success, not zero.
 1.3 19-Jun-2014  hikaru Use 64-bit DMA, if it is available.
This fixes null packet handling on guest which have memory over than 3GB.
 1.2 19-Jun-2014  hikaru Make it be able to down I/F. This fixes panic when removing IFF_UP flag.
 1.1 10-Jun-2014  hikaru Add VMware VMXNET3 ethernet driver from OpenBSD, vmx(4).
 1.4.4.1 14-Aug-2014  martin Pull up following revision(s) (requested by hikaru in ticket #15):
sys/arch/x86/pci/if_vmx.c: revision 1.5
Set ifflags callback so that the device can enter promiscuous mode.
 1.4.2.2 10-Aug-2014  tls Rebase.
 1.4.2.1 19-Jul-2014  tls file if_vmx.c was added on branch tls-earlyentropy on 2014-08-10 06:54:11 +0000
 1.5.4.5 28-Aug-2017  skrll Sync with HEAD
 1.5.4.4 05-Feb-2017  skrll Sync with HEAD
 1.5.4.3 05-Dec-2016  skrll Sync with HEAD
 1.5.4.2 09-Jul-2016  skrll Sync with HEAD
 1.5.4.1 19-Mar-2016  skrll Sync with HEAD
 1.5.2.3 03-Dec-2017  jdolecek update from HEAD
 1.5.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.2.1 14-Aug-2014  tls file if_vmx.c was added on branch tls-maxphys on 2014-08-20 00:03:29 +0000
 1.7.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.7.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.18.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.19.6.8 13-May-2020  martin Pull up following revision(s) (requested by yamaguchi in ticket #1547):

sys/arch/x86/pci/if_vmx.c: revision 1.60

Fix the wrong logic about making the number of vmx(4) TX/RX queue
be power of two

reviewed by nonaka@n.o.
 1.19.6.7 26-Dec-2019  martin Pull up following revision(s) (requested by knakahara in ticket #1477):

sys/arch/x86/pci/if_vmx.c: revision 1.53

Fix missing splnet() for ether_ioctl() caused by if_vmx.c:r1.32.
pointed out by nonaka@n.o, thanks.
 1.19.6.6 22-Jul-2019  martin Pull up following revision(s) (requested by knakahara in ticket #1300):

sys/arch/x86/pci/if_vmx.c: revision 1.31
sys/arch/x86/pci/if_vmx.c: revision 1.32 (via patch)

Eliminate IFF_RUNNING checking code from vmxnet3_init_locked().

Advised by hikaru@n.o, thanks.

-

Fix vmx(4) MTU setting.

Advised by hikaru@n.o and msaitoh@n.o, thanks.
 1.19.6.5 21-Mar-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1219):

sys/arch/x86/pci/if_vmx.c: revision 1.27
PR/54058: vmx(4): Fix device enable command failure when the number of vCPUs
is not a power of two.

Make the size of the vmx(4) TX/RX queue a power of two not exceeding
the number of vCPUs.
 1.19.6.4 16-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #767):

sys/arch/x86/pci/if_vmx.c: revision 1.23,1.24

vmx(4): handled SIOCZIFDATA.

vmx(4): compute if_ibytes using rxq->vxrxq_stats.vmrxs_ibytes.
 1.19.6.3 16-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #762):

sys/arch/x86/pci/if_vmx.c: revision 1.22

vmx(4): Fix calculation of interface statistics counter.
 1.19.6.2 26-Feb-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #577):
sys/arch/x86/pci/if_vmx.c: 1.21
m_free -> m_freem, otherwise leak
 1.19.6.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.21.2.3 28-Jul-2018  pgoyette Sync with HEAD
 1.21.2.2 25-Jun-2018  pgoyette Sync with HEAD
 1.21.2.1 22-Apr-2018  pgoyette Sync with HEAD
 1.26.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.26.2.1 10-Jun-2019  christos Sync with HEAD
 1.45.2.7 13-May-2020  martin Pull up following revision(s) (requested by yamaguchi in ticket #902):

sys/arch/x86/pci/if_vmx.c: revision 1.60

Fix the wrong logic about making the number of vmx(4) TX/RX queue
be power of two

reviewed by nonaka@n.o.
 1.45.2.6 28-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #662):

sys/dev/pcmcia/if_xi.c: revision 1.93
sys/arch/x86/pci/if_vmx.c: revision 1.54
sys/dev/pci/if_de.c: revision 1.165
sys/arch/arm/ti/if_cpsw.c: revision 1.10
sys/arch/arm/omap/if_cpsw.c: revision 1.26
sys/dev/isa/if_iy.c: revision 1.112
sys/dev/pcmcia/if_ray.c: revision 1.96

Add ETHER_LOCK() and ETHER_UNLOCK() to protect ec_multiaddrs.

XXX These drivers don't check whether enm_addrlo and enm_addrhi are the same
or not, so it won't work correctly if an multicast address entry has a range.

Protect ec_multicnt.
 1.45.2.5 26-Dec-2019  martin Pull up following revision(s) (requested by knakahara in ticket #583):

sys/arch/x86/pci/if_vmx.c: revision 1.53

Fix missing splnet() for ether_ioctl() caused by if_vmx.c:r1.32.
pointed out by nonaka@n.o, thanks.
 1.45.2.4 10-Oct-2019  martin Pull up following revision(s) (requested by knakahara in ticket #298):

sys/arch/x86/pci/if_vmx.c: revision 1.51

Fix kassert failure in vmxnet3_transmit(). Pointed out by ryo@n.o, thanks.
 1.45.2.3 30-Sep-2019  martin Pull up following revision(s) (requested by knakahara in ticket #268):

sys/arch/x86/pci/if_vmx.c: revision 1.50

Fix typo in vmxnet3_legacy_intr().

That causes sysctl hw.vmx*.{rx,tx} effect inversely when vmx(4) uses
INTx or MSI.
 1.45.2.2 01-Sep-2019  martin Pull up following revision(s) (requested by knakahara in ticket #143):

sys/arch/x86/pci/if_vmx.c: revision 1.49

vmxnet3_softc.vmx_stats should not count globally. pointed out by hikaru@n.o

divide vmxnet3_softc.vmx_stats to each vmxnet3_txqueue and vmxnet3_rxqueue,
furthermore make them evcnt.
 1.45.2.1 20-Aug-2019  martin Pull up following revision(s) (requested by knakahara in ticket #99):

sys/arch/x86/pci/if_vmx.c: revision 1.46
sys/arch/x86/pci/if_vmx.c: revision 1.47
sys/arch/x86/pci/if_vmx.c: revision 1.48

vmx(4) uses interrupt distribution for each queue like ixg(4).

fix panic when vmx(4) is detached.

add vmx(4) basic statistics counters.
Sorry, I have forgotten this TODO in r1.40 commit message.
 1.54.2.1 29-Feb-2020  ad Sync with head.
 1.4 14-Oct-2020  ryo vmx(4) should be MI. moved to sys/dev/pci from sys/arch/x86/pci
 1.3 05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.2 25-Nov-2016  hikaru branches: 1.2.16;
Sync code with FreeBSD to support RSS

- Use MSI/MSI-X if it is available.
- Support TSO.

co-authored by k-nakahara
 1.1 10-Jun-2014  hikaru branches: 1.1.2; 1.1.6; 1.1.8; 1.1.12;
Add VMware VMXNET3 ethernet driver from OpenBSD, vmx(4).
 1.1.12.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.8.1 05-Dec-2016  skrll Sync with HEAD
 1.1.6.3 03-Dec-2017  jdolecek update from HEAD
 1.1.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.1 10-Jun-2014  tls file if_vmxreg.h was added on branch tls-maxphys on 2014-08-20 00:03:29 +0000
 1.1.2.2 10-Aug-2014  tls Rebase.
 1.1.2.1 10-Jun-2014  tls file if_vmxreg.h was added on branch tls-earlyentropy on 2014-08-10 06:54:11 +0000
 1.2.16.1 10-Jun-2019  christos Sync with HEAD
 1.1 10-Dec-2017  bouyer Add support for I2C designware controllers (as found in Intel PCH devices),
with a pci front-end.
The pci front-end is tied to ACPI and Intel-specific, so it's in arch/x86/pci
and not dev/pci.
Core driver from OpenBSD, PCI front-end by me.
 1.27 24-May-2022  bouyer - msipic_construct_msix_pic(): set mp_table_base to memaddr (without
table_offset), this is what Xen wants
while there use pci_conf_write16() in msi_set_msictl_enablebit() too,
for consistency (it seems that Xen accepts the 32bit write at this point,
but this may change).

- xen_map_msix_pirq(): don't forget to set map_irq.table_base in the
MSI-X case, otherwise Xen maps it as MSI
- call pic_hwunmask() after pirq_establish() in msi/msix case, to make sure
the msi-x vector is unmasked.

Now MSI-X works with Xen so stop disabling it in pci_attach_hook().
 1.26 23-May-2022  bouyer Work in progress on MSI/MSI-X on Xen (MSI works on my hardware, more work
needed for MSI-X):
- Xen silently rejects 32 bits writes to MSI configuration registers
(especially when setting PCI_MSI_CTL_MSI_ENABLE/PCI_MSIX_CTL_ENABLE),
it expects 16 bits writes. So introduce a pci_conf_write16(),
only available on XENPV (and working only for mode 1 without
PCI_OVERRIDE_CONF_WRITE) and use it to enable MSI or MSI-X on XENPV.
- for multi-MSI vectors, Xen allocates all of them in a single hypercall,
so it's not convenient to do it at intr_establish() time.
So do it at alloc() time and register the pirqs in the msipic structure.
xen_pic_to_gsi() now just returns the values cached in the msipic.
As a bonus, if the PHYSDEVOP_map_pirq hypercall fails we can fail
the alloc() and we don't need the xen_pci_msi*_probe() hacks.

options NO_PCI_MSI_MSIX still on by default for XEN3_DOM0.
 1.25 11-Dec-2020  knakahara Fix build failure when XNEPV is defined.
 1.24 11-Dec-2020  knakahara Not pic->pic_addroute but pic->pic_hwunmask should enable interrupts for MSI-X.

pic->pic_addroute should not enable interrupt, because callers expect
interrupts have been disabled until they call pic->pic_hwunmask.

By the way, the old implement writes zero to Vector Control for MSI-X Table
Entries, howerver it must be read and updated. Because, there are not only
Mask Bit but also ST lower and ST upper.
 1.23 04-May-2020  jdolecek branches: 1.23.2;
add support for using MSI for XenPV Dom0

use PHYSDEVOP_map_pirq to get the pirq/gsi for MSI/MSI-X, switch also INTx
to use it instead of PHYSDEVOP_alloc_irq_vector

MSI confirmed working with single-vector MSI for wm(4), ahcisata(4), bge(4)

XXX added some provision for MSI-X, but it doesn't actually work (no interrupts
delivered), needs some further investigation; disable MSI-X for XENPV
via flag in x86/pci/pci_machdep.c
 1.22 04-May-2020  jdolecek constify the pic templates
 1.21 25-Apr-2020  bouyer Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor
 1.20 02-Dec-2019  msaitoh branches: 1.20.6;
Use PCI_MSIX_"TBL"BIR_MASK instead of PCI_MSIX_"PBA"BIR_MASK for MSI-X table.
This is not a real bug because both macros have the same value.
 1.19 13-Nov-2019  hikaru Disable MSI-X before writing the MSI-X table.

That fixes MSI-X interrupt lost on VMware ESXi 6.7 PCI passthrough devices.

ok knakahara@
 1.18 03-Oct-2019  tnn change bus_space_map to _x86_memio_map

Resolves bus space reservation conflict between MI and MD code.
Discussion:
http://mail-index.netbsd.org/port-amd64/2019/09/28/msg003014.html
 1.17 26-Jun-2019  knakahara branches: 1.17.2;
Fix updating "Multiple Message Enable" field for MSI multiple vectors. Pointed out by jmcneill@n.o, thanks.

I tested ahcisata for MSI single vector regression.
 1.16 18-Jun-2019  msaitoh Add note about the case of PCI_MSI_MDATA[64] is 16bit.
 1.15 17-Jun-2019  msaitoh KNF. No functional change.
 1.14 17-Jun-2019  msaitoh Fix comma with semicolon. No functional change.
 1.13 14-Jun-2019  msaitoh No functional change:
- Rename macros:
- ICR, LVT and MSIDATA can share the bit definitions. Remove redundant
definitions and use the common macros.
- Consistently use LAPIC_LVT_ for all local vector table's macro names.
- Use __BITS().
- Add definition for TSC-deadline (LAPIC_LVT_TMM_TSCDLT).
 1.12 01-Apr-2019  msaitoh Fix typo in comment (s/numer/number/).
 1.11 28-Jul-2017  maxv branches: 1.11.2; 1.11.6;
Don't include malloc.h.
 1.10 01-Jun-2017  chs branches: 1.10.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.9 23-May-2017  nonaka x86: Add preliminary x2APIC support.

x2APIC is used only when x2APIC is enabled in BIOS/UEFI.
LAPIC ID is not supported above 256.
 1.8 17-Nov-2015  msaitoh No functional change:
- Add comments.
- Remove obsolete comment.
- Move definitions to better location.
- Rename bit definition.
- KNF.
- Indent.
 1.7 13-Aug-2015  msaitoh Add workaround for PCI prefetchable bit in msipic_construct_msix_pic().
Some chips (e.g. Intel 82599) report SERR and MSI-X interrupt doesn't work.
This problem might not be the driver's bug but our PCI common part or VMs'
bug. See fxp(4), bge(4) and ixgbe(4). All of them has the same workaround
related to prefetchable bit. For the MSI-X table area, it should not have side
effect by prefetching. Until we find a real reason, we ignore the prefetchable
bit.
 1.6 13-Aug-2015  msaitoh - Don't take pci_attach_args as an argument in pci_msi[x]_count().
- Move prototypes of pci_msi[x]_count() from x86/x86/pci_machdep_common to
sys/dev/pci/pcivar.h.
- Move pci_msi[x]_count() from x86/pci/pci_msi_machdep.c to sys/dev/pci/pci.c
 1.5 11-Aug-2015  msaitoh Add missing opt_intrdebug.h.
 1.4 08-May-2015  knakahara branches: 1.4.2;
add a const qualifier to struct pci_attach_args *pa argument
 1.3 28-Apr-2015  martin Make this compilable in non-DIAGNOSTIC kernels.
 1.2 28-Apr-2015  knakahara fix debug message.
 1.1 27-Apr-2015  knakahara add x86 MD MSI/MSI-X support code.
 1.4.2.5 28-Aug-2017  skrll Sync with HEAD
 1.4.2.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.4.2.3 22-Sep-2015  skrll Sync with HEAD
 1.4.2.2 06-Jun-2015  skrll Sync with HEAD
 1.4.2.1 08-May-2015  skrll file msipic.c was added on branch nick-nhusb on 2015-06-06 14:40:04 +0000
 1.10.2.1 20-Nov-2019  martin Pull up following revision(s) (requested by hikaru in ticket #1453):

sys/arch/x86/pci/msipic.c: revision 1.19

Disable MSI-X before writing the MSI-X table.

That fixes MSI-X interrupt lost on VMware ESXi 6.7 PCI passthrough devices.

ok knakahara@
 1.11.6.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.11.6.1 10-Jun-2019  christos Sync with HEAD
 1.11.2.2 03-Dec-2017  jdolecek update from HEAD
 1.11.2.1 28-Jul-2017  jdolecek file msipic.c was added on branch tls-maxphys on 2017-12-03 11:36:50 +0000
 1.17.2.2 16-Nov-2019  martin Pull up following revision(s) (requested by hikaru in ticket #429):

sys/arch/x86/pci/msipic.c: revision 1.19

Disable MSI-X before writing the MSI-X table.

That fixes MSI-X interrupt lost on VMware ESXi 6.7 PCI passthrough devices.

ok knakahara@
 1.17.2.1 15-Oct-2019  martin Pull up following revision(s) (requested by tnn in ticket #305):

sys/arch/x86/pci/msipic.c: revision 1.18

change bus_space_map to _x86_memio_map

Resolves bus space reservation conflict between MI and MD code.

Discussion:
http://mail-index.netbsd.org/port-amd64/2019/09/28/msg003014.html
 1.20.6.1 19-Apr-2020  bouyer Add per-PIC callbacks for interrupt_get_devname(), interrupt_get_assigned()
and interrupt_get_count(). Implement Xen-specific callbacks for
PIC_XEN and use the x86 one for others.
In event_set_handler(), call intr_allocate_io_intrsource() so that
events appears in interrupt list (intrctl list).
 1.23.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.4 23-May-2022  bouyer Work in progress on MSI/MSI-X on Xen (MSI works on my hardware, more work
needed for MSI-X):
- Xen silently rejects 32 bits writes to MSI configuration registers
(especially when setting PCI_MSI_CTL_MSI_ENABLE/PCI_MSIX_CTL_ENABLE),
it expects 16 bits writes. So introduce a pci_conf_write16(),
only available on XENPV (and working only for mode 1 without
PCI_OVERRIDE_CONF_WRITE) and use it to enable MSI or MSI-X on XENPV.
- for multi-MSI vectors, Xen allocates all of them in a single hypercall,
so it's not convenient to do it at intr_establish() time.
So do it at alloc() time and register the pirqs in the msipic structure.
xen_pic_to_gsi() now just returns the values cached in the msipic.
As a bonus, if the PHYSDEVOP_map_pirq hypercall fails we can fail
the alloc() and we don't need the xen_pci_msi*_probe() hacks.

options NO_PCI_MSI_MSIX still on by default for XEN3_DOM0.
 1.3 04-May-2020  jdolecek add support for using MSI for XenPV Dom0

use PHYSDEVOP_map_pirq to get the pirq/gsi for MSI/MSI-X, switch also INTx
to use it instead of PHYSDEVOP_alloc_irq_vector

MSI confirmed working with single-vector MSI for wm(4), ahcisata(4), bge(4)

XXX added some provision for MSI-X, but it doesn't actually work (no interrupts
delivered), needs some further investigation; disable MSI-X for XENPV
via flag in x86/pci/pci_machdep.c
 1.2 08-May-2015  knakahara branches: 1.2.2; 1.2.18;
add a const qualifier to struct pci_attach_args *pa argument
 1.1 27-Apr-2015  knakahara add x86 MD MSI/MSI-X support code.
 1.2.18.2 03-Dec-2017  jdolecek update from HEAD
 1.2.18.1 08-May-2015  jdolecek file msipic.h was added on branch tls-maxphys on 2017-12-03 11:36:50 +0000
 1.2.2.2 06-Jun-2015  skrll Sync with HEAD
 1.2.2.1 08-May-2015  skrll file msipic.h was added on branch nick-nhusb on 2015-06-06 14:40:04 +0000
 1.37 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.36 24-Apr-2021  thorpej branches: 1.36.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.35 01-Oct-2016  mrg branches: 1.35.30;
use 4-byte style accesses, should hopefully fix PR#37787.
 1.34 16-Apr-2012  pgoyette branches: 1.34.2; 1.34.16; 1.34.20;
Now that we have amdnb_misc for attaching amdtemp, revert pchb.c revisions
1.27 and 1.32. This will unbreak the build.

XXX The amdtemp device currently does not seem to provide correct sensor
values.

XXX The amdnb_misc device does not currently have a rescan capability, so
the amdtemp module will not instantiate any devices (PR kern/45268
reappears).

XXX The agp attachment at the same pci device and function (which was
the motivation for attaching amdtemp at pchb) probably ought to also
be moved to attach at amdnb_miscbus.
 1.33 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.32 20-Aug-2011  jakllsch branches: 1.32.2; 1.32.6;
Add rescan support for 'amdtempbus' to x86 pchb(4).
Maybe finally fixes PR#45268.
 1.31 20-Aug-2011  jakllsch pchb_get_bus_number() is actually public
 1.30 20-Aug-2011  jakllsch staticification
 1.29 20-Aug-2011  jakllsch We no longer need to #include "rnd.h".
 1.28 20-Aug-2011  jakllsch We need to initialize the PCI chipset and device tags in the softc for
the suspend and resume handlers.
 1.27 18-Aug-2011  jakllsch Attach amdtemp(4) at pchb(4) instead of in place of pchb(4).

Should fix PR#45268.
 1.26 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.25 17-May-2011  dyoung PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.24 24-Feb-2011  matt Add Intel Pineview support
 1.23 23-Jul-2010  jakllsch branches: 1.23.2; 1.23.4;
Almost entirely rework Intel Firmware Hub random number generator support.

This introduces fwhrng(4) which attaches via ichlpcib(4), replacing
the rnd(4) support in pchb(4).
 1.22 16-Jun-2010  riz Add AGP support for a number of Intel onboard devices, including
82G41, 82B43, E7221, 82965GME, and "Iron Lake". Device
types (i915, i965, G33, and G4X variants) from the Linux Intel AGP
driver, and (for 82G41) from Henry Bent in PR#42906.

There are a few more varieties that should be relatively low-hanging
fruit ("Pineview" and "Sandy Bridge"), but will require a little bit
of rejiggering of the "chiptype".

OK mrg@
 1.21 24-Feb-2010  dyoung branches: 1.21.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.20 08-Jan-2010  dyoung branches: 1.20.2;
Expand PMF_FN_* macros.
 1.19 23-Aug-2009  jmcneill Save a line of dmesg by printing the vendor/product info on the same line
as the locators.
 1.18 07-Apr-2009  dyoung Detach pchb(4) instances at shutdown.
 1.17 27-Jan-2009  markd branches: 1.17.2;
Add some more Intel G4X class chipsets
 1.16 29-Nov-2008  christos Add support for the Intel G45 AGP. From Arnaud Lacombe
 1.15 08-Nov-2008  christos Support for Intel G35 as found on Asus P5E-VM HDMI motherboard from
Milos Negovanovic
 1.14 22-Aug-2008  tnn branches: 1.14.2; 1.14.4; 1.14.8;
AGP support for Intel 945GME chipset, found on Acer Aspire One.
 1.13 19-Aug-2008  matthias Add agp support for Intel 946GZ.
 1.12 30-May-2008  joerg branches: 1.12.4;
Add a function to extract the primary bus number of PCI host bridges,
as far as specific code for this already existed.
 1.11 28-Apr-2008  martin branches: 1.11.2;
Remove clause 3 and 4 from TNF licenses
 1.10 16-Apr-2008  cegger branches: 1.10.2; 1.10.4;
- use aprint_*_dev and device_xname
- use POSIX integer types
 1.9 04-Mar-2008  cube Split device_t/softc and other related cosmetic changes.
 1.8 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.7 28-Feb-2008  drochner fix an unaligned PCI config space access for the P2 "BX" chipset
 1.6 03-Jan-2008  dyoung branches: 1.6.2; 1.6.6;
Support detachment of pchb(4) and sysbeep(4).
 1.5 09-Dec-2007  jmcneill branches: 1.5.2;
Merge jmcneill-pm branch.
 1.4 24-Nov-2007  markd branches: 1.4.2; 1.4.4; 1.4.6;
Add Intel Q35/G33/Q33 bridges.
 1.3 12-Nov-2007  joerg branches: 1.3.2;
Add Intel 82965PM bridge from jmcneill-pm.
 1.2 30-Oct-2007  jnemeth branches: 1.2.2; 1.2.4;
PR/37201 - Yasushi Oshima -- Intel 82965G chipset support
 1.1 26-Oct-2007  xtraeme branches: 1.1.2; 1.1.4;
- Share pchb(4) between i386 and amd64; one copy is enough for both.
- Move some of the x86 PCI devices into x86/pci/files.pci.
- Add more x86 stuff into x86/conf/files.x86.

ok joerg.
 1.1.4.7 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.1.4.6 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.1.4.5 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.1.4.4 04-Nov-2007  jmcneill Re-add 965 support lost in an earlier merge.
 1.1.4.3 31-Oct-2007  joerg Sync with HEAD.
 1.1.4.2 28-Oct-2007  joerg Sync with HEAD.
 1.1.4.1 26-Oct-2007  joerg file pchb.c was added on branch jmcneill-pm on 2007-10-28 20:10:59 +0000
 1.1.2.6 17-Mar-2008  yamt sync with head.
 1.1.2.5 21-Jan-2008  yamt sync with head
 1.1.2.4 07-Dec-2007  yamt sync with head
 1.1.2.3 15-Nov-2007  yamt sync with head.
 1.1.2.2 27-Oct-2007  yamt sync with head.
 1.1.2.1 26-Oct-2007  yamt file pchb.c was added on branch yamt-lazymbuf on 2007-10-27 11:28:58 +0000
 1.2.4.4 23-Mar-2008  matt sync with HEAD
 1.2.4.3 09-Jan-2008  matt sync with HEAD
 1.2.4.2 06-Nov-2007  matt sync with HEAD
 1.2.4.1 30-Oct-2007  matt file pchb.c was added on branch matt-armv6 on 2007-11-06 23:23:42 +0000
 1.2.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.2.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.2.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.2.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.3.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.3.2.1 12-Nov-2007  bouyer file pchb.c was added on branch bouyer-xenamd64 on 2007-11-13 16:00:19 +0000
 1.4.6.1 11-Dec-2007  yamt sync with head.
 1.4.4.1 26-Dec-2007  ad Sync with head.
 1.4.2.2 03-Dec-2007  ad Sync with HEAD.
 1.4.2.1 24-Nov-2007  ad file pchb.c was added on branch vmlocking on 2007-12-03 19:04:28 +0000
 1.5.2.1 08-Jan-2008  bouyer Sync with HEAD
 1.6.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.6.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.6.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.6.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.6.2.1 24-Mar-2008  keiichi sync with head.
 1.10.4.5 11-Aug-2010  yamt sync with head.
 1.10.4.4 11-Mar-2010  yamt sync with head
 1.10.4.3 16-Sep-2009  yamt sync with head
 1.10.4.2 04-May-2009  yamt sync with head.
 1.10.4.1 16-May-2008  yamt sync with head.
 1.10.2.2 04-Jun-2008  yamt sync with head
 1.10.2.1 18-May-2008  yamt sync with head.
 1.11.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.11.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.12.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.12.4.1 19-Oct-2008  haad Sync with HEAD.
 1.14.8.1 21-Apr-2010  matt sync to netbsd-5
 1.14.4.1 05-May-2009  bouyer Pull up following revision(s) (requested by snj in ticket #737):
sys/arch/x86/pci/pchb.c: revisions 1.15 - 1.17
sys/dev/pci/agp.c: revisions 1.63 - 1.65
sys/dev/pci/agp_i810.c: revisions 1.57 - 1.64
sys/dev/pci/pcidevs: revisions 1.965, 1.967 via patch
sys/dev/pci/agpreg.h: revision 1.20
Add AGP support for Intel G35, G45, and Q45.
 1.14.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.14.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.14.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.17.2.5 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.17.2.4 28-Mar-2011  jym Sync with HEAD. TODO before merge:
- shortcut for suspend code in sysmon, when powerd(8) is not running.
Borrow ``xs_watch'' thread context?
- bug hunting in xbd + xennet resume. Rings are currently thrashed upon
resume, so current implementation force flush them on suspend. It's not
really needed.
 1.17.2.3 24-Oct-2010  jym Sync with HEAD
 1.17.2.2 01-Nov-2009  jym Sync with HEAD.
 1.17.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.20.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.20.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.21.2.3 31-May-2011  rmind sync with head
 1.21.2.2 05-Mar-2011  rmind sync with head
 1.21.2.1 03-Jul-2010  rmind sync with head
 1.23.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.23.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.32.6.2 29-Apr-2012  mrg sync to latest -current.
 1.32.6.1 18-Feb-2012  mrg merge to -current.
 1.32.2.2 18-Apr-2012  yamt pull following revisions from trunk so that the kernel at least boot
on my system.
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/x86/pci/pchb.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/pci/pchbvar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/amdnb_misc.c
 1.32.2.1 17-Apr-2012  yamt sync with head
 1.34.20.1 04-Nov-2016  pgoyette Sync with HEAD
 1.34.16.1 05-Oct-2016  skrll Sync with HEAD
 1.34.2.1 03-Dec-2017  jdolecek update from HEAD
 1.35.30.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.36.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.10 23-Jul-2010  jakllsch Almost entirely rework Intel Firmware Hub random number generator support.

This introduces fwhrng(4) which attaches via ichlpcib(4), replacing
the rnd(4) support in pchb(4).
 1.9 03-Nov-2009  snj branches: 1.9.2; 1.9.4;
Drop 3rd and 4th clauses, as the copyright holder (Michael Shalayeff) did
in OpenBSD revision 1.39.
 1.8 04-Mar-2008  cube branches: 1.8.4; 1.8.18;
Split device_t/softc and other related cosmetic changes.
 1.7 03-Jan-2008  dyoung branches: 1.7.2; 1.7.6;
Support detachment of pchb(4) and sysbeep(4).
 1.6 17-Oct-2007  garbled branches: 1.6.2; 1.6.8;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.5 16-Oct-2007  joerg Make the check for a working RNG a bit more aggressive. Try to read
10 samples and bail out if there was a timeout to get either of those
within 10ms or if they are all 0xff. Both are good indicators of a
missing RNG.
 1.4 16-Oct-2007  joerg Exploit that only Intel devices are matched and all devices do the same.
This saves two levels of indentation for the main body, making it more
readable. Don't hide the error for disabling the RNG under DIAGNOSTIC,
verbose is enough. Use aprint_*_dev.
 1.3 09-Jul-2007  ad branches: 1.3.8; 1.3.10; 1.3.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.2 19-Feb-2006  tron branches: 1.2.8; 1.2.14; 1.2.20; 1.2.30; 1.2.32; 1.2.38;
Improve code probing for the Intel hardware RNG to avoid false detections.
See http://home.comcast.net/~andrex/hardware-RNG/doihave.html for details.
Problem pointed on by Thor Lancelot Simon on port-amd64 mailing list.
 1.1 12-Feb-2006  tron branches: 1.1.2;
Share Intel hardware random number generator support between amd64 and
i386 port. This will benefit EM64T systems using Intel i9xx chipsets.
 1.1.2.3 01-Mar-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 12-Feb-2006  yamt file pchb_rnd.c was added on branch yamt-uio_vmspace on 2006-02-18 15:38:54 +0000
 1.2.38.2 17-Oct-2007  garbled Sync with HEAD
 1.2.38.1 03-Oct-2007  garbled Sync with HEAD
 1.2.32.1 11-Jul-2007  mjf Sync with head.
 1.2.30.2 23-Oct-2007  ad Sync with head.
 1.2.30.1 01-Jul-2007  ad Adapt to callout API change.
 1.2.20.2 09-Sep-2006  rpaulo sync with head
 1.2.20.1 19-Feb-2006  rpaulo file pchb_rnd.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:44:49 +0000
 1.2.14.6 17-Mar-2008  yamt sync with head.
 1.2.14.5 21-Jan-2008  yamt sync with head
 1.2.14.4 27-Oct-2007  yamt sync with head.
 1.2.14.3 03-Sep-2007  yamt sync with head.
 1.2.14.2 21-Jun-2006  yamt sync with head.
 1.2.14.1 19-Feb-2006  yamt file pchb_rnd.c was added on branch yamt-lazymbuf on 2006-06-21 14:57:56 +0000
 1.2.8.2 22-Apr-2006  simonb Sync with head.
 1.2.8.1 19-Feb-2006  simonb file pchb_rnd.c was added on branch simonb-timecounters on 2006-04-22 11:38:09 +0000
 1.3.12.1 18-Oct-2007  yamt sync with head.
 1.3.10.3 23-Mar-2008  matt sync with HEAD
 1.3.10.2 09-Jan-2008  matt sync with HEAD
 1.3.10.1 06-Nov-2007  matt sync with HEAD
 1.3.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.6.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.6.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.7.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.7.2.1 24-Mar-2008  keiichi sync with head.
 1.8.18.1 24-Oct-2010  jym Sync with HEAD
 1.8.4.2 11-Aug-2010  yamt sync with head.
 1.8.4.1 11-Mar-2010  yamt sync with head
 1.9.4.1 05-Mar-2011  rmind sync with head
 1.9.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.9.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.9 16-Apr-2012  pgoyette Now that we have amdnb_misc for attaching amdtemp, revert pchb.c revisions
1.27 and 1.32. This will unbreak the build.

XXX The amdtemp device currently does not seem to provide correct sensor
values.

XXX The amdnb_misc device does not currently have a rescan capability, so
the amdtemp module will not instantiate any devices (PR kern/45268
reappears).

XXX The agp attachment at the same pci device and function (which was
the motivation for attaching amdtemp at pchb) probably ought to also
be moved to attach at amdnb_miscbus.
 1.8 20-Aug-2011  jakllsch branches: 1.8.2; 1.8.6;
Add rescan support for 'amdtempbus' to x86 pchb(4).
Maybe finally fixes PR#45268.
 1.7 23-Jul-2010  jakllsch Finish cleaning up pchb from recent change.
Use fewer magic numbers in ichlpcib.
Slightly improve style conformance.
Update paths in cpp re-inclusion guards.
 1.6 23-Jul-2010  jakllsch Almost entirely rework Intel Firmware Hub random number generator support.

This introduces fwhrng(4) which attaches via ichlpcib(4), replacing
the rnd(4) support in pchb(4).
 1.5 28-Apr-2008  martin branches: 1.5.14; 1.5.20; 1.5.22;
Remove clause 3 and 4 from TNF licenses
 1.4 04-Mar-2008  cube branches: 1.4.2; 1.4.4;
Split device_t/softc and other related cosmetic changes.
 1.3 03-Jan-2008  dyoung branches: 1.3.2; 1.3.6;
Support detachment of pchb(4) and sysbeep(4).
 1.2 09-Dec-2007  jmcneill branches: 1.2.2;
Merge jmcneill-pm branch.
 1.1 12-Feb-2006  tron branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22; 1.1.50; 1.1.52; 1.1.58; 1.1.62; 1.1.64;
Share Intel hardware random number generator support between amd64 and
i386 port. This will benefit EM64T systems using Intel i9xx chipsets.
 1.1.64.1 11-Dec-2007  yamt sync with head.
 1.1.62.1 26-Dec-2007  ad Sync with head.
 1.1.58.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.52.2 23-Mar-2008  matt sync with HEAD
 1.1.52.1 09-Jan-2008  matt sync with HEAD
 1.1.50.2 12-Nov-2007  joerg CG unused softc fields.
 1.1.50.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 12-Feb-2006  rpaulo file pchbvar.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:44:49 +0000
 1.1.16.4 17-Mar-2008  yamt sync with head.
 1.1.16.3 21-Jan-2008  yamt sync with head
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 12-Feb-2006  yamt file pchbvar.h was added on branch yamt-lazymbuf on 2006-06-21 14:57:56 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 12-Feb-2006  simonb file pchbvar.h was added on branch simonb-timecounters on 2006-04-22 11:38:09 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 12-Feb-2006  yamt file pchbvar.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:54 +0000
 1.2.2.1 08-Jan-2008  bouyer Sync with HEAD
 1.3.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.3.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.3.2.1 24-Mar-2008  keiichi sync with head.
 1.4.4.2 11-Aug-2010  yamt sync with head.
 1.4.4.1 16-May-2008  yamt sync with head.
 1.4.2.1 18-May-2008  yamt sync with head.
 1.5.22.1 05-Mar-2011  rmind sync with head
 1.5.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.5.14.2 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.5.14.1 24-Oct-2010  jym Sync with HEAD
 1.8.6.1 29-Apr-2012  mrg sync to latest -current.
 1.8.2.1 18-Apr-2012  yamt pull following revisions from trunk so that the kernel at least boot
on my system.
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/x86/pci/pchb.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/pci/pchbvar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/amdnb_misc.c
 1.10 28-Jul-2017  maxv Don't include malloc.h.
 1.9 27-Jan-2012  para branches: 1.9.6; 1.9.24;
converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.8 28-Aug-2011  dyoung branches: 1.8.2; 1.8.6;
Normalize whitespace.
 1.7 28-Aug-2011  dyoung Replace some anonymous constants with PCI_ constants.

Print debugging information using aprint_debug(9) not aprint_verbose(9)
and be consistent about that. Get rid of the pciaddrverbose switch for
debugging printfs.

Make 'static' several functions that are private to this module.

Don't test truth of arbitrary integers but compare with 0. Change
'return (x)' to 'return x'.
 1.6 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.5 26-Jul-2010  jym Add PAE to ALL kernel, so that most paddr_t format string errors get caught
during compilation.

While here, fix the compilation for ALL.
 1.4 17-Feb-2009  jmcneill branches: 1.4.2; 1.4.4; 1.4.6;
Use aprint_*
 1.3 19-Dec-2008  cegger branches: 1.3.2;
backout previous. makes i386 ALL kernel build again
 1.2 18-Dec-2008  cegger remove unused malloc.h
 1.1 18-May-2008  jmcneill branches: 1.1.2; 1.1.4; 1.1.8; 1.1.12;
Add support for PCI_BUS_FIXUP and PCI_ADDR_FIXUP on amd64.
 1.1.12.2 03-Mar-2009  skrll Sync with HEAD.
 1.1.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.1.8.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.8.1 18-May-2008  wrstuden file pci_addr_fixup.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:12 +0000
 1.1.4.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.4.1 18-May-2008  mjf file pci_addr_fixup.c was added on branch mjf-devfs2 on 2008-06-02 13:22:50 +0000
 1.1.2.2 18-May-2008  yamt sync with head.
 1.1.2.1 18-May-2008  yamt file pci_addr_fixup.c was added on branch yamt-pf42 on 2008-05-18 12:33:04 +0000
 1.3.2.4 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.3.2.3 24-Oct-2010  jym Sync with HEAD
 1.3.2.2 01-Nov-2009  jym Sync with HEAD.
 1.3.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.4.6.1 05-Mar-2011  rmind sync with head
 1.4.4.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.4.2.3 11-Aug-2010  yamt sync with head.
 1.4.2.2 04-May-2009  yamt sync with head.
 1.4.2.1 17-Feb-2009  yamt file pci_addr_fixup.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:10 +0000
 1.8.6.1 18-Feb-2012  mrg merge to -current.
 1.8.2.1 17-Apr-2012  yamt sync with head
 1.9.24.1 28-Aug-2017  skrll Sync with HEAD
 1.9.6.1 03-Dec-2017  jdolecek update from HEAD
 1.1 18-May-2008  jmcneill branches: 1.1.2; 1.1.4; 1.1.8; 1.1.22;
Add support for PCI_BUS_FIXUP and PCI_ADDR_FIXUP on amd64.
 1.1.22.2 04-May-2009  yamt sync with head.
 1.1.22.1 18-May-2008  yamt file pci_addr_fixup.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:10 +0000
 1.1.8.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.8.1 18-May-2008  wrstuden file pci_addr_fixup.h was added on branch wrstuden-revivesa on 2008-06-23 05:02:12 +0000
 1.1.4.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.4.1 18-May-2008  mjf file pci_addr_fixup.h was added on branch mjf-devfs2 on 2008-06-02 13:22:50 +0000
 1.1.2.2 18-May-2008  yamt sync with head.
 1.1.2.1 18-May-2008  yamt file pci_addr_fixup.h was added on branch yamt-pf42 on 2008-05-18 12:33:04 +0000
 1.3 01-Mar-2019  msaitoh - Almost all ppbreg.h's definitions are also in pcireg.h. Remove duplicated
definitions from ppbreg.h and move some definitions from ppbreg.h to
pcireg.h.
- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard Timer Status
and Discard Timer SERR# Enable bit in pci_subr.c.
- PCI_BRIDGE_PREFETCHBASE32_REG and PCI_BRIDGE_PREFETCHLIMIT32_REG are
"upper" 32bit registers, rename to *UP32_REG to avoid confusion.
- Use macro.
 1.2 01-Jul-2011  dyoung branches: 1.2.54;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.1 18-May-2008  jmcneill branches: 1.1.2; 1.1.4; 1.1.8; 1.1.18; 1.1.22;
Add support for PCI_BUS_FIXUP and PCI_ADDR_FIXUP on amd64.
 1.1.22.2 04-May-2009  yamt sync with head.
 1.1.22.1 18-May-2008  yamt file pci_bus_fixup.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:10 +0000
 1.1.18.1 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.1.8.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.8.1 18-May-2008  wrstuden file pci_bus_fixup.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:12 +0000
 1.1.4.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.4.1 18-May-2008  mjf file pci_bus_fixup.c was added on branch mjf-devfs2 on 2008-06-02 13:22:50 +0000
 1.1.2.2 18-May-2008  yamt sync with head.
 1.1.2.1 18-May-2008  yamt file pci_bus_fixup.c was added on branch yamt-pf42 on 2008-05-18 12:33:04 +0000
 1.2.54.1 10-Jun-2019  christos Sync with HEAD
 1.1 18-May-2008  jmcneill branches: 1.1.2; 1.1.4; 1.1.8; 1.1.22;
Add support for PCI_BUS_FIXUP and PCI_ADDR_FIXUP on amd64.
 1.1.22.2 04-May-2009  yamt sync with head.
 1.1.22.1 18-May-2008  yamt file pci_bus_fixup.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:10 +0000
 1.1.8.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.8.1 18-May-2008  wrstuden file pci_bus_fixup.h was added on branch wrstuden-revivesa on 2008-06-23 05:02:12 +0000
 1.1.4.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.4.1 18-May-2008  mjf file pci_bus_fixup.h was added on branch mjf-devfs2 on 2008-06-02 13:22:50 +0000
 1.1.2.2 18-May-2008  yamt sync with head.
 1.1.2.1 18-May-2008  yamt file pci_bus_fixup.h was added on branch yamt-pf42 on 2008-05-18 12:33:04 +0000
 1.51 01-Aug-2020  jdolecek reorder includes to pull __HAVE_PCI_MSI_MSIX properly via
<x86/pci_machdep_common.h>
 1.50 17-Jun-2019  msaitoh KNF. No functional change.
 1.49 11-Feb-2019  cherry We reorganise definitions for XEN source support as follows:

XEN - common sources required for baseline XEN support.
XENPV - sources required for support of XEN in PV mode.
XENPVHVM - sources required for support for XEN in HVM mode.
XENPVH - sources required for support for XEN in PVH mode.
 1.48 02-Dec-2018  cherry make

options NO_PCI_MSI_MSIX

work again for arch/x86/
 1.47 27-Nov-2018  jdolecek actually allow pci_intr_alloc() with NULL count with MSI-X
 1.46 27-Nov-2018  jdolecek make pci_intr_alloc() try also MSI-X by default (with NULL count);
there are boards/emulators which only have MSI-X and no MSI, and
so far there is no evidence there are devices which support both
and don't work in MSI-X mode

this change is supposed to reduce amount of needed cut&paste code in drivers

discussed briefly with jmcneill@
 1.45 23-Sep-2018  cherry Revert:
http://mail-index.netbsd.org/source-changes/2018/09/10/msg098995.html

It is incorrect to infer semantics from usage.

the problem for which the original commit was intended should be fixed
within the callee intr_establish_xname() and not the caller:
pci_intr_find_intx_irq()

This was accomplished via:
http://mail-index.netbsd.org/source-changes/2018/09/20/msg099286.html
 1.44 10-Sep-2018  cherry In the NIOAPIC case, we do not need to support "legacy" irqs,
ie; We don't need to simultaneously pass back the irq in the
range 0 < irq < 16 (which are sometimes described as "legacy"
in src

This was non-obvious, until the semantics of "legacy" were
used in inconsistent ways in Xen (to also mean interrupts in
the 0 < irq < 256 range) which causes problems with attempting
to unify the sys/arch/x86/isa/isa_machdep.c:isa_intr_establish_xname()
function between XEN and !XEN

This commit should not affect current functionality on any
either native or Xen. It is needed for future code reorg, and
published now as a preview.
 1.43 24-Jun-2018  jdolecek branches: 1.43.2;
provide pci_intr_establish_xname() on x86 independantly from MSI,
so it's available on XEN too; change also the stub to use weak
symbol instead #ifdef
 1.42 04-Jan-2018  knakahara branches: 1.42.2;
fix "intrctl list" panic when ACPI is disabled.

reviewed by cherry@n.o and tested by msaitoh@n.o, thanks.
 1.41 28-Jul-2017  maxv Don't include malloc.h.
 1.40 01-Jun-2017  chs branches: 1.40.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.39 28-Nov-2016  knakahara fix build of amd64/i386 with NO_PCI_MSI_MSIX option.
 1.38 11-Jul-2016  knakahara branches: 1.38.2;
pci_intr_type() is required pci_chipset_tag_t argument by other than x86.

pointed out by nonaka@n.o.
 1.37 17-Aug-2015  knakahara Add kernel code to support intrctl(8).
 1.36 13-Aug-2015  msaitoh - Don't take pci_attach_args as an argument in pci_msi[x]_count().
- Move prototypes of pci_msi[x]_count() from x86/x86/pci_machdep_common to
sys/dev/pci/pcivar.h.
- Move pci_msi[x]_count() from x86/pci/pci_msi_machdep.c to sys/dev/pci/pci.c
 1.35 24-Jul-2015  knakahara fix pci_intr_alloc(..., NULL, 0). reported nonaka@n.o
 1.34 21-Jul-2015  knakahara add pci_intr_alloc() API
 1.33 15-May-2015  knakahara pci_msi_string() must be used by MD code only.
 1.32 15-May-2015  knakahara refactor: change function names and move them.
 1.31 15-May-2015  knakahara unify INTx, MSI and MSI-X APIs without alloc. (alloc API is under discussion)
 1.30 27-Apr-2015  knakahara add x86 MD MSI/MSI-X support code.
 1.29 27-Apr-2015  knakahara add intr_handle_t and let pci_intr_handle_t use it.
 1.28 27-Apr-2015  knakahara add pci_intr_distribute(9) for x86.
 1.27 29-Mar-2014  christos branches: 1.27.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.26 26-Jan-2013  dyoung branches: 1.26.2;
Several registers and bitfields named IOAPIC_* actually belong to the
LAPIC, so rename them LAPIC_* and move to a more appropriate header
file.
 1.25 15-Jun-2012  yamt branches: 1.25.2;
comment
 1.24 15-Jun-2012  yamt assertions. use a macro. no functional changes.
 1.23 29-Aug-2011  dyoung branches: 1.23.2;
Use a loop instead of tail-recursion for the pci_intr(9) overrides.
This is the same change that I just made to the pci(9) overrides. While
I am here, fix a bug: use PCI_OVERRIDE_INTR_DISESTABLISH instead of
PCI_OVERRIDE_INTR_ESTABLISH for the pci_intr_disestablish(9) override.
 1.22 17-Aug-2011  dyoung In pci_msi_establish(), replace several anonymous constants with IOAPIC_
symbols. No change in the generated assembly.
 1.21 17-Aug-2011  dyoung Redefine PCI_MSI_* and PCI_PCIE_* constants in terms of bits(3).

Use named constants and more conventional variable names in
pci_msi_establish() and pci_msi_disestablish(). Fix a couple of bugs:
pci_msi_establish() returned a pointer to the struct intrhand instead of
to the struct msi_hdl as it was intended to, and pci_msi_disestablish()
did not free(9) the msi_hdl.
 1.20 01-Aug-2011  drochner add an experimental implementation of PCI MSIs (Message Signaled
Interrupts). Successfully tested with hdaudio and "wpi" wireless
ethernet.
notes:
-There seem to be buggy chips around which announce MSI support
but don't correctly implement it. Thus the final word whether MSIs
can be used should be by the driver.
-Only a single vector is supported. For multiple vectors, the IDT
allocation code would have to be changed. (And we would possibly
run into problems due to the limited number of vectors supported
by the current code.)
-The code is "#if NIOAPIC > 0" because it uses the ioapic_edge
interrupt stubs. These actually don't touch any ioapic, so this
is somewhat a misnomer.
-MSIs can't be identified by a "pin" but only by a cpu/vector
pair. Common intr code soesn't deal well with this yet.
-Drivers need to take care of saving/restoring MSI data in the device's
config space on suspend/resume.
 1.19 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.18 20-Dec-2010  matt branches: 1.18.2;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.17 28-Apr-2010  dyoung Provide an x86 implementation of pci_chipset_tag_create(9) and
pci_chipset_tag_destroy(9).
 1.16 14-Mar-2010  dyoung branches: 1.16.2;
Add a new member, pc_super, to x86's pci_chipset_tag: pc.pc_super points
to the tag that pc inherits its behavior from. Add code to deal with
pc.pc_super.

Pull identical declarations out of xen/include/pci_machdep.h and
x86/include/pci_machdep.h into x86/include/pci_machdep_common.h.
 1.15 25-Feb-2010  dyoung In the x86 pci(9) implementation, test for and call a
pci_chipset_tag_t's override functions.
 1.14 18-Aug-2009  jmcneill branches: 1.14.2;
Switch to ACPICA 20090730, and update for API changes.
 1.13 21-Mar-2009  ad Fix 'boot -z' bogons.
 1.12 03-Jul-2008  drochner branches: 1.12.4; 1.12.10;
Remove "struct device" from "struct pic", where it was only real
for ioapics and faked up for others. Add it to "struct ioapic_softc"
for now, until device/softc get split.
This required all typecasts between "struct pic" and "struct ioapic_softc"
to be replaced, I hope I got them all.
functionally tested on i386, compile-tested on xen, untested on amd64
 1.11 30-May-2008  ad branches: 1.11.2;
pci_intr_setattr(), allows PCI interrupts to be marked MPSAFE on x86, and
other platforms if the code is added.

pci_intr_map(...)
pci_intr_setattr(pc, ih, PCI_INTR_MPSAFE, 1);
pci_intr_establish(...)
 1.10 30-May-2008  ad Add a 'known_mpsafe' argument to intr_establish().
 1.9 03-May-2008  cegger branches: 1.9.2;
ansify
 1.8 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.7 04-Jan-2008  ad branches: 1.7.6; 1.7.8; 1.7.10;
sys/lock.h isn't needed here.
 1.6 16-Nov-2006  christos branches: 1.6.28; 1.6.34; 1.6.42;
__unused removal on arguments; approved by core.
 1.5 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.4 04-Jul-2006  christos branches: 1.4.4; 1.4.6; 1.4.8;
spell NACPI correctly.
 1.3 04-Jul-2006  christos PR/33912: tron: Building GENERIC kernel fails
Fallout from ACPI changes.
 1.2 04-Jul-2006  christos Apply fvdl's acpi pci interrupt configuration code.
- MPACPI is no more.
- MPACPI_SCANPCI -> ACPI_SCANPCI
 1.1 03-Feb-2006  bouyer branches: 1.1.4; 1.1.6; 1.1.14; 1.1.16;
Split move interrupt-related PCI functions from pci_machdep.c to
pci_intr_machdep.c. In Xen-3 registers access is done the normal way but
interrupts need custom setup. Proposed on port-amd64, port-i386 and
port-xen a week ago.
 1.1.16.4 21-Jan-2008  yamt sync with head
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 03-Feb-2006  yamt file pci_intr_machdep.c was added on branch yamt-lazymbuf on 2006-06-21 14:57:56 +0000
 1.1.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.1.6.1 11-Aug-2006  yamt sync with head
 1.1.4.2 18-Feb-2006  yamt sync with head.
 1.1.4.1 03-Feb-2006  yamt file pci_intr_machdep.c was added on branch yamt-uio_vmspace on 2006-02-18 15:38:54 +0000
 1.4.8.2 10-Dec-2006  yamt sync with head.
 1.4.8.1 22-Oct-2006  yamt sync with head
 1.4.6.2 09-Sep-2006  rpaulo sync with head
 1.4.6.1 04-Jul-2006  rpaulo file pci_intr_machdep.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:44:49 +0000
 1.4.4.1 18-Nov-2006  ad Sync with head.
 1.6.42.1 08-Jan-2008  bouyer Sync with HEAD
 1.6.34.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.28.1 09-Jan-2008  matt sync with HEAD
 1.7.10.5 11-Aug-2010  yamt sync with head.
 1.7.10.4 11-Mar-2010  yamt sync with head
 1.7.10.3 19-Aug-2009  yamt sync with head.
 1.7.10.2 04-May-2009  yamt sync with head.
 1.7.10.1 16-May-2008  yamt sync with head.
 1.7.8.2 04-Jun-2008  yamt sync with head
 1.7.8.1 18-May-2008  yamt sync with head.
 1.7.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.7.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.9.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.11.2.1 03-Jul-2008  simonb Sync with head.
 1.12.10.6 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.12.10.5 02-May-2011  jym Sync with head.
 1.12.10.4 10-Jan-2011  jym Sync with HEAD
 1.12.10.3 24-Oct-2010  jym Sync with HEAD
 1.12.10.2 01-Nov-2009  jym Sync with HEAD.
 1.12.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.14.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.2.3 21-Apr-2011  rmind sync with head
 1.16.2.2 05-Mar-2011  rmind sync with head
 1.16.2.1 30-May-2010  rmind sync with head
 1.18.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.23.2.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.2.1 30-Oct-2012  yamt sync with head
 1.25.2.3 03-Dec-2017  jdolecek update from HEAD
 1.25.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.2.1 25-Feb-2013  tls resync with head
 1.26.2.1 18-May-2014  rmind sync with head
 1.27.6.5 28-Aug-2017  skrll Sync with HEAD
 1.27.6.4 05-Dec-2016  skrll Sync with HEAD
 1.27.6.3 05-Oct-2016  skrll Sync with HEAD
 1.27.6.2 22-Sep-2015  skrll Sync with HEAD
 1.27.6.1 06-Jun-2015  skrll Sync with HEAD
 1.38.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.40.2.1 13-Jan-2018  snj Pull up following revision(s) (requested by knakahara in ticket #493):
sys/arch/x86/include/intr.h: revision 1.53
sys/arch/x86/pci/pci_intr_machdep.c: revision 1.42
sys/arch/x86/x86/intr.c: revision 1.114 via patch
fix "intrctl list" panic when ACPI is disabled.
reviewed by cherry@n.o and tested by msaitoh@n.o, thanks.
 1.42.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.42.2.2 30-Sep-2018  pgoyette Ssync with HEAD
 1.42.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.43.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.43.2.1 10-Jun-2019  christos Sync with HEAD
 1.101 26-Sep-2025  tnn x86: correct bootinfo detection for vioif(4) adapters

When we pxeboot a virtio-net adapter in QEMU, firmware reports the
parent virtio(4) pci BDF triplet as the device we can match on, but
device_pci_register must return the child vioif(4) as actual boot device.

PR kern/57023 from Martin Kjellstrand.
 1.100 08-May-2025  riastradh x86/pci_machdep.c: Nix trailing whitespace.

No functional change intended.
 1.99 06-May-2025  manu Search host bridge on all devices from PCI bus 0

We look for host bridge MSI capability to enable MSI on PCI devices,
which require locating the host bridge itself. Previously we assumed
it was on bus 0, device 0, but that assmption misses some setups.
For instance, Dell Poweredge r760xd2 has its host bridge on bus 0,
device 20, function 4.

This change iterates on all devices on bus 0 to find the host bridge.
 1.98 21-Nov-2023  gutteridge branches: 1.98.2;
pci_machdep.c & pci_msi_machdep.c: comment fixes

Correct spelling and grammar in some comments.
 1.97 17-Oct-2023  bouyer Support non-VGA framebuffers for Xen dom0. This is mandatory for graphic
console on EFI-only hardware.
Add a xen_genfb_getbtinfo() function which will return a btinfo_framebuffer
structure, filled in with parameters provided by Xen
when runing as a Xen dom0, call xen_genfb_getbtinfo() instead of
lookup_bootinfo(BTINFO_FRAMEBUFFER) when adding properties to the
PCI graphic device (when genfb is attached) and in x86_genfb_init()
when genfb is used as console.
x86/x86/consinit.c: If running as a Xen dom0, use xen_genfb_getbtinfo()
to check if we have a genfb console
xen/x86/consinit.c: support genfb as possible console
xen/x86/consinit.c: use the hypervior IO as console until a better one
is found. If the hypervisor is using a serial port for boot messages,
we'll get NetBSD's boot message on the serial port too until
the real console takes over.
xen/x86/autoconf.c: rework device_register() to be closer to the x86 version.
Especially make sure that device_pci_register() is called.
 1.96 16-Oct-2023  bouyer Declare
int acpi_md_vesa_modenum;
int acpi_md_vbios_reset;
struct vcons_screen x86_genfb_console_screen;

in genfb_machdep.h instead of locally as extern in various .c files.
 1.95 25-Aug-2023  riastradh xen: Provide definitions or ifdefs to make drm build in XEN3_DOM0.

No idea if it works, but it builds now.

PR port-xen/49330
 1.94 07-Aug-2023  msaitoh Fix detection of availability of MSI/MSI-X on some systems.

Try to find all functions on bus 0, device 0 to find a PCI host bridge.
Some CPU's host bridge is at 0:0.4. Tested by Intel Snow Ridge.
 1.93 06-Sep-2022  msaitoh branches: 1.93.4;
Fix compile error. Compile test only.
 1.92 05-Sep-2022  riastradh x86: Fix interaction between consinit, device_pci_register, and drm.

Leave an essay on what's going on here in both places with
cross-references.

PR kern/56996
 1.91 24-May-2022  bouyer - msipic_construct_msix_pic(): set mp_table_base to memaddr (without
table_offset), this is what Xen wants
while there use pci_conf_write16() in msi_set_msictl_enablebit() too,
for consistency (it seems that Xen accepts the 32bit write at this point,
but this may change).

- xen_map_msix_pirq(): don't forget to set map_irq.table_base in the
MSI-X case, otherwise Xen maps it as MSI
- call pic_hwunmask() after pirq_establish() in msi/msix case, to make sure
the msi-x vector is unmasked.

Now MSI-X works with Xen so stop disabling it in pci_attach_hook().
 1.90 23-May-2022  bouyer Work in progress on MSI/MSI-X on Xen (MSI works on my hardware, more work
needed for MSI-X):
- Xen silently rejects 32 bits writes to MSI configuration registers
(especially when setting PCI_MSI_CTL_MSI_ENABLE/PCI_MSIX_CTL_ENABLE),
it expects 16 bits writes. So introduce a pci_conf_write16(),
only available on XENPV (and working only for mode 1 without
PCI_OVERRIDE_CONF_WRITE) and use it to enable MSI or MSI-X on XENPV.
- for multi-MSI vectors, Xen allocates all of them in a single hypercall,
so it's not convenient to do it at intr_establish() time.
So do it at alloc() time and register the pirqs in the msipic structure.
xen_pic_to_gsi() now just returns the values cached in the msipic.
As a bonus, if the PHYSDEVOP_map_pirq hypercall fails we can fail
the alloc() and we don't need the xen_pci_msi*_probe() hacks.

options NO_PCI_MSI_MSIX still on by default for XEN3_DOM0.
 1.89 15-Oct-2021  jmcneill Disable MSI and MSI-X support if IAPC_BOOT_ARCH reports that MSI is not
supported.
 1.88 28-Jan-2021  jmcneill Remove x86_genfb_mtrr_init. PATs have been available since the Pentium III
and this code has been #if notyet'd shortly after being introduced.
 1.87 04-May-2020  jdolecek branches: 1.87.2;
add support for using MSI for XenPV Dom0

use PHYSDEVOP_map_pirq to get the pirq/gsi for MSI/MSI-X, switch also INTx
to use it instead of PHYSDEVOP_alloc_irq_vector

MSI confirmed working with single-vector MSI for wm(4), ahcisata(4), bge(4)

XXX added some provision for MSI-X, but it doesn't actually work (no interrupts
delivered), needs some further investigation; disable MSI-X for XENPV
via flag in x86/pci/pci_machdep.c
 1.86 24-May-2019  nonaka branches: 1.86.2;
Added drivers for Hyper-V Synthetic Keyboard and Video device.
 1.85 17-May-2019  christos Factor out the fbinfo setting code, to make it more readable, and use
memcpy to properly align the structure (although it does not matter on x86).
 1.84 11-Feb-2019  cherry We reorganise definitions for XEN source support as follows:

XEN - common sources required for baseline XEN support.
XENPV - sources required for support of XEN in PV mode.
XENPVHVM - sources required for support for XEN in HVM mode.
XENPVH - sources required for support for XEN in PVH mode.
 1.83 10-Jul-2018  maxv Fix bug, SPINOUT() is not supposed to take the value given to BACKOFF().
Here the exponential backoff is wrecked.
 1.82 23-Jun-2018  jakllsch branches: 1.82.2;
Disable all contemporary mode 1 quirks.
 1.81 23-Jun-2018  jakllsch If mode 1 enable check fails, give mode 1 a second chance by trying to
use it to locate a PCI Host Bridge or device from vendor that produced
a chipset lacking a Host Bridge class device.

Should allow us to remove most all the mode 1 quirks added in the last
two decades.
 1.80 11-Apr-2018  nonaka efiboot reports parent ppb bus/device/function of booted network inteface.
 1.79 01-Jun-2017  chs branches: 1.79.2; 1.79.8;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.78 25-Feb-2017  nonaka EFI console is drawing faster by shadowfb.
 1.77 09-Feb-2017  msaitoh Supress verbose message "This pci host supports neither MSI nor MSI-X."
on VMware and KVM. OK'd by k-nakahara.
 1.76 25-Aug-2016  nonaka branches: 1.76.2;
more fix line break position in verbose message.
 1.75 25-Aug-2016  knakahara fix line break position in verbose message.

pointed out by nonaka@n.o, thanks.
 1.74 10-Jun-2016  jakllsch branches: 1.74.2;
Avoid trying to create a tag for locating AMD HyperTransport bridge that will
panic a machine that uses Configuration Mechanism 2.
 1.73 26-Nov-2015  jakllsch Move acpimcfg_map_bus() before no-MSI bailout in pci_attach_hook().
 1.72 02-Nov-2015  knakahara Add verbose messages when the kernel disables MSI/MSI-X.
 1.71 02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.70 27-Apr-2015  knakahara add x86 MD MSI/MSI-X support code.
 1.69 07-Nov-2014  christos branches: 1.69.2;
print the bad values in panic messages
 1.68 05-Nov-2014  christos we don't need to keep track of curmode if not vga_post.
 1.67 06-May-2014  christos branches: 1.67.2;
tidy up.
 1.66 06-May-2014  sborrill Force pci_mode 1 when running as Xen HVM domU to allow cd* to be detected
correctly. Fixes kern/48770. Thanks to cube@
 1.65 27-Jan-2014  jakllsch branches: 1.65.2;
Stopgap to prevent genfb from stealing console. Revisit later.
 1.64 26-Jan-2014  msaitoh PUCCN improvements:
- Fix a bug that the puc cn mechanism doesn't use the UART's frequency
in pucdata.c's table.

- Add a new option PUC_CNAUTO. If this option is set, consinit() in
x86/x86/consinit.c checks puc com device to use it as console.
Without this option, the behavior is the same as before.

- Add a new config parameter PUC_CNBUS. The old code scans bus #0 only.
If PUC_CNBUS is set, the specified number's bus will be scanned.

- Rename comcnprobe() to puc_cnprobe() to make it clear.

- Rename comcninit() to puc_cninit() to make it clear.

- Add code for a device that a device's com register is MMIO (#if0 ed).
 1.63 25-Dec-2013  jakllsch Give cpu_comcnprobe a chance of working on Mode 2 PCI config space.
 1.62 17-Oct-2013  christos remove set but unused variables
 1.61 05-Oct-2013  gson Force PCI mode 1 when running under QEMU, to work around QEMU bug 897771.
This should also make it possible to boot NetBSD under versions of KVM
that have inherited said QEMU bug. Fixes PR kern/45671.
 1.60 31-Jul-2013  macallan hand genfb the virtual address of the actual framebuffer, not the upper
left corner of the text area
now centering works and we don't scribble past the mapped VRAM when trying
to clear the screen in 32bit colour
 1.59 31-Jul-2013  soren Blocking memory space accesses on the SIS 85C496 chipset turned out to be
a bit too heavy-handed and similar cases are unlikely to crop up again,
so simplify by eliminating pci_bus_flags().

Closes PR port-i386/20410.
 1.58 22-Jul-2013  soren Allow console on com_puc without a compile-time option so that PC servers
can become headless after the first reboot (sadly, e.g. Intel AMT presents
as a com_puc, but doesn't appear in the BIOS serial port table, so you need
a keyboard and monitor to install and set the installboot parameters first).

Fix com_puc console on devices with offset BAR's.
 1.57 03-May-2013  jakllsch branches: 1.57.4; 1.57.6;
use IO_VGA as symbolic constant for 0x3c0 in x86_genfb_set_mapreg()
 1.56 01-Mar-2012  jakllsch branches: 1.56.2;
slightly rework pcim1_quirk_tbl[]-related bits:
- put patchable entry first so finding it with gdb/ddb is more trivial
- use pcitag_t instead of uint32_t for tag
- make this table const
- drop old #undef
- use NULL instead of 0 where appropriate.
 1.55 28-Feb-2012  jakllsch cosmetic, spelling, and grammar adjustments
 1.54 15-Feb-2012  tsutsui branches: 1.54.2; 1.54.6; 1.54.8;
Add VIA VX900 host bridge to a buggy PCI mode 1 quirk table. PR/46018
Ok releng@
 1.53 18-Nov-2011  jmcneill branches: 1.53.4;
remove Xbox support
 1.52 18-Oct-2011  dyoung branches: 1.52.2;
Factor device_isa_register() and device_pci_register() out of
device_register() and stick the new routines into isa_machdep.c and
pci_machdep.c, respectively.
 1.51 13-Sep-2011  dyoung Bracket a debugging printf() with #ifdef DEBUG.
 1.50 01-Sep-2011  christos Add bus_dma overrides. From dyoung
 1.49 29-Aug-2011  dyoung Move the code for grovelling in PCI configuration space for assigned
memory & I/O regions into its own module, pci_ranges.c, so that we can
leave it out on systems that won't need it.
 1.48 28-Aug-2011  dyoung Add some code for grovelling in the PCI configuration space for all
of the memory & I/O space reserved by the PCI BIOS for PCI devices
(including bridges) and recording that information for later use.

The code takes between 13k and 50k (depends on the architecture and,
bizarrely, the kernel configuration) so I am going to move it from
pci_machdep.c into its own module on Monday.
 1.47 28-Aug-2011  dyoung Make the override implementation more concise. Saves about three lines
of code per routine, makes it more explicit what's going on, and avoids
recursion, though the compiler probably optimized the tail recursion in
the old code.
 1.46 27-Aug-2011  christos use c99 struct initializers
 1.45 17-May-2011  dyoung PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.44 30-Apr-2010  dyoung branches: 1.44.2;
Add an exponential back-off to the loop that tries to lock the
PCI configuration-access registers, to avoid excessive cacheline
ping-ponging. Thanks to rmind@ for the tip.
 1.43 28-Apr-2010  dyoung Provide an x86 implementation of pci_chipset_tag_create(9) and
pci_chipset_tag_destroy(9).
 1.42 27-Apr-2010  dyoung Make pci_conf_read(9) and pci_conf_write(9) re-entrant so that the
kernel can use them in an NMI trap handler. Only one CPU can be
in _read() or _write() at once. However, on any single CPU, more
than one thread of execution (LWP, interrupt handler, trap handler)
may be in _read() or _write() at once, because each thread saves
and restores the PCI configuration-access state.
 1.41 14-Mar-2010  dyoung branches: 1.41.2;
Add a new member, pc_super, to x86's pci_chipset_tag: pc.pc_super points
to the tag that pc inherits its behavior from. Add code to deal with
pc.pc_super.

Pull identical declarations out of xen/include/pci_machdep.h and
x86/include/pci_machdep.h into x86/include/pci_machdep_common.h.
 1.40 25-Feb-2010  dyoung In the x86 pci(9) implementation, test for and call a
pci_chipset_tag_t's override functions.
 1.39 16-Feb-2010  dyoung PCI Configuration Mechanisms #1 and #2 are controlled by two to
three registers. Let us think of the kernel operating the registers
in two steps:

1) Select: enable configuration cycles and select a range of
configuration-space addresses.

2) Access: read or write a word in PCI configuration space.

To make the steps more explicit, extract some helper subroutines
from pci_conf_read(9) and pci_conf_write(9):

pci_conf_selector(tag, reg): from a pcitag_t and a register offset,
create a word that enables configuration cycles and selects a
configuration address range.

pci_conf_select(w): for `w' a word created by pci_conf_selector(),
enable configuration cycles and select the address range indicated
by `w'.

pci_conf_select(0): disable configuration cycles.

pci_conf_port(tag, reg): map a pcitag_t and a register offset to an I/O
port where the configuration access should occur.

While I'm in here, change the panic(9) calls to panic("%s: ...",
__func__) instead of hard-coding a subroutine name.
 1.38 16-Feb-2010  dyoung Get rid of all PCI_CONF_MODE #ifdef'age except for the little bit
that initializes pci_mode, which I have moved to the top.

Make pci_mode private to pci_machdep.c.

Provide pci_mode_set() for pcibios.c to configure the PCI Configuration
Mechanism. KASSERT() in pci_mode_set() that the mechanism is not
changing from anything but the "don't know" value, -1.
 1.37 18-Aug-2009  jmcneill branches: 1.37.2;
Switch to ACPICA 20090730, and update for API changes.
 1.36 03-Jul-2009  drochner add SIS 740 to the list of chipsets known to implement PCI configuration
mode 1 incorrectly, from Jason White
(see thread "ACPI issue with old Shuttle system" on port-i386)
 1.35 15-Mar-2009  cegger ansify function definitions
 1.34 28-Apr-2008  martin branches: 1.34.8; 1.34.10; 1.34.14;
Remove clause 3 and 4 from TNF licenses
 1.33 16-Apr-2008  cegger branches: 1.33.2; 1.33.4;
- use aprint_*_dev and device_xname
- use POSIX integer types
 1.32 21-Mar-2008  dyoung Use device_t.
 1.31 14-Jan-2008  dyoung branches: 1.31.2; 1.31.6;
KASSERT() that reads/writes from/to PCI configuration space are
aligned on 32-bit boundaries.
 1.30 04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.29 04-Jan-2008  ad sys/lock.h isn't needed here.
 1.28 17-Oct-2007  garbled branches: 1.28.2; 1.28.8;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.27 29-Aug-2007  dyoung Use __arraycount().
 1.26 22-Jul-2007  mjf branches: 1.26.4; 1.26.6;
Remove newline from format string of aprint_normal.

Thanks to pooka@ for pointing it out.
 1.25 19-Jul-2007  mjf s/aprintf_normal/aprint_normal
 1.24 19-Jul-2007  mjf Change printf to aprintf_normal and add a newline as requested by Christoph Egger on port-xen.
 1.23 09-Jul-2007  ad branches: 1.23.2; 1.23.4;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.22 22-Feb-2007  matt branches: 1.22.4; 1.22.6; 1.22.12;
Add missing initializer for _tag_needs_count
 1.21 21-Feb-2007  mrg add a pair of new bus_dma(9) functions:
int _bus_dmatag_subregion(bus_dma_tag_t tag,
bus_addr_t min_addr,
bus_addr_t max_addr,
bus_dma_tag_t *newtag,
int flags)
void _bus_dmatag_destroy(bus_dma_tag_t tag)

that allow a (normally broken/limited) device to restrict the bus address
range it can talk to. this is used by bce(4) to limit DMA addresses to
1GB range, the maximum the chip can address.

all this is from Yorick Hardy <yhardy@uj.ac.za> with input from several
people on tech-kern.

XXX: bus_dma(9) needs an update still.
 1.20 06-Feb-2007  jmcneill branches: 1.20.2;
On Xbox, disallow pci_conf_read/pci_conf_write calls for bus 0 device 0
functions 1 and 2.
 1.19 05-Jan-2007  jmcneill On the Xbox, prevent scanning past the first device on bus 1.
 1.18 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.17 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.16 04-Jul-2006  christos branches: 1.16.4; 1.16.6;
Apply fvdl's acpi pci interrupt configuration code.
- MPACPI is no more.
- MPACPI_SCANPCI -> ACPI_SCANPCI
 1.15 25-Jun-2006  soren Add quirk for the not quite standard PCI bus in Parallels Desktop for Mac.
 1.14 07-Feb-2006  bouyer branches: 1.14.2; 1.14.10;
Add back proper MPBIOS/MPACPI handling.
 1.13 03-Feb-2006  bouyer branches: 1.13.2;
Split move interrupt-related PCI functions from pci_machdep.c to
pci_intr_machdep.c. In Xen-3 registers access is done the normal way but
interrupts need custom setup. Proposed on port-amd64, port-i386 and
port-xen a week ago.
 1.12 16-Nov-2005  christos branches: 1.12.2; 1.12.4;
PR/31885: Stephane Witzmann: Force pci mode 1 on SIS 741.
 1.11 20-Jun-2005  sekiya branches: 1.11.2; 1.11.8;
pci_device_foreach(), pci_device_foreach_min(), pci_bridge_foreach(), and
pci_bridge_hook don't actually have any dependancies on PCIBIOS-specific code,
and they can be used to fixup PCI bus numbering in the absence of the BIOS.

To that end, decouple them from PCIBIOS.
 1.10 16-Apr-2005  yamt tweak x86 bus_dma code so that it can be used by xen port.

- distinguish paddr_t and bus_addr_t.
for xen, use bus_addr_t in the sense of machine address.
- move _X86_BUS_DMA_PRIVATE part of bus.h into bus_private.h.
- remove special handling of xen_shm. we can always grab
machine address from pte.
 1.9 30-Oct-2003  fvdl branches: 1.9.8; 1.9.14;
* keep track of PCI buses that aren't known by firmware, but are found
by NetBSD
* use this info in in intr_find_mpmapping
* get rid of the last argument to intr_find_mpmapping, it was redundant
 1.8 16-Oct-2003  fvdl Add hooks and structures to allow the MP table intr mapping code a
better shot at finding a mapping. For PCI interrupts, if a bus
has no mappings, try its parent, with the swizzled pin, and the
bridge's device number.
 1.7 06-Sep-2003  fvdl Move the bulk of pci_intr_string into a seperate intr_string function. Use
that new function to print the pciide compat interrupt in pciide_machdep.c.
Share pciide_machdep.c between amd64 and i386.
 1.6 06-Sep-2003  fvdl If possible, put the device name of the APIC used into the interrupt string,
not "apic N". This makes it easier to match vmstat output with dmesg output.
 1.5 15-Jun-2003  fvdl branches: 1.5.2;
Handle 64bit DMA addresses on PCI for platforms that can (currently only
enabled on amd64). Add a dmat64 field to various PCI attach structures,
and pass it down where needed. Implement a simple new function called
pci_dma64_available(pa) to test if 64bit DMA addresses may be used.
This returns 1 iff _PCI_HAVE_DMA64 is defined in <machine/pci_machdep.h>,
and there is more than 4G of memory.
 1.4 29-May-2003  fvdl Add the options MPBIOS_SCANPCI and MPACPI_SCANPCI to configure PCI roots
with the MPBIOS/ACPI bus information, by walking through the buses, and
descending down every bus that hasn't been marked configured yet.
 1.3 07-May-2003  fvdl Generalize bounce buffers, and use them for 32 bit PCI if needed.
Make ALLOCNOW the default iff bouncing might be needed (this has
no effect on i386 because ISA DMA devices already had to use
ALLOCNOW, and PCI isn't bounced (yet), since we don't do > 4G
at this point for i386.
 1.2 28-Apr-2003  fvdl Include "eisa.h" in order to get the NEISA value; without it EISA-only
MP intr routing tables wouldn't be searched.
 1.1 27-Feb-2003  fvdl Moved here from i386/pci.
 1.5.2.5 11-Dec-2005  christos Sync with head.
 1.5.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.14.2 21-Nov-2005  tron Pull up following revision(s) (requested by christos in ticket #966):
sys/arch/x86/pci/pci_machdep.c: revision 1.12
PR/31885: Stephane Witzmann: Force pci mode 1 on SIS 741.
 1.9.14.1 21-Apr-2005  tron Pull up revision 1.10 (requested by yamt in ticket #175):
tweak x86 bus_dma code so that it can be used by xen port.
- distinguish paddr_t and bus_addr_t.
for xen, use bus_addr_t in the sense of machine address.
- move _X86_BUS_DMA_PRIVATE part of bus.h into bus_private.h.
- remove special handling of xen_shm. we can always grab
machine address from pte.
 1.9.8.1 29-Apr-2005  kent sync with -current
 1.11.8.1 22-Nov-2005  yamt sync with head.
 1.11.2.6 24-Mar-2008  yamt sync with head.
 1.11.2.5 21-Jan-2008  yamt sync with head
 1.11.2.4 03-Sep-2007  yamt sync with head.
 1.11.2.3 26-Feb-2007  yamt sync with head.
 1.11.2.2 30-Dec-2006  yamt sync with head.
 1.11.2.1 21-Jun-2006  yamt sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.12.2.1 18-Feb-2006  yamt sync with head.
 1.13.2.1 22-Apr-2006  simonb Sync with head.
 1.14.10.1 13-Jul-2006  gdamore Merge from HEAD.
 1.14.2.2 11-Aug-2006  yamt sync with head
 1.14.2.1 26-Jun-2006  yamt sync with head.
 1.16.6.2 10-Dec-2006  yamt sync with head.
 1.16.6.1 22-Oct-2006  yamt sync with head
 1.16.4.3 09-Feb-2007  ad Sync with HEAD.
 1.16.4.2 12-Jan-2007  ad Sync with head.
 1.16.4.1 18-Nov-2006  ad Sync with head.
 1.20.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.22.12.1 03-Oct-2007  garbled Sync with HEAD
 1.22.6.1 11-Jul-2007  mjf Sync with head.
 1.22.4.3 09-Oct-2007  ad Sync with head.
 1.22.4.2 20-Aug-2007  ad Sync with HEAD.
 1.22.4.1 10-Apr-2007  ad Replace some more locks.
 1.23.4.2 03-Sep-2007  skrll Sync with HEAD.
 1.23.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.23.2.1 07-Aug-2007  matt Sync with HEAD.
 1.26.6.3 23-Mar-2008  matt sync with HEAD
 1.26.6.2 09-Jan-2008  matt sync with HEAD
 1.26.6.1 06-Nov-2007  matt sync with HEAD
 1.26.4.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.28.8.2 19-Jan-2008  bouyer Sync with HEAD
 1.28.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.28.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.31.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.31.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.31.2.1 24-Mar-2008  keiichi sync with head.
 1.33.4.6 11-Aug-2010  yamt sync with head.
 1.33.4.5 11-Mar-2010  yamt sync with head
 1.33.4.4 19-Aug-2009  yamt sync with head.
 1.33.4.3 18-Jul-2009  yamt sync with head.
 1.33.4.2 04-May-2009  yamt sync with head.
 1.33.4.1 16-May-2008  yamt sync with head.
 1.33.2.1 18-May-2008  yamt sync with head.
 1.34.14.5 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.34.14.4 24-Oct-2010  jym Sync with HEAD
 1.34.14.3 01-Nov-2009  jym Sync with HEAD.
 1.34.14.2 23-Jul-2009  jym Sync with HEAD.
 1.34.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.34.10.2 21-May-2014  bouyer Pull up following revision(s) (requested by sborrill in ticket #1903):
sys/arch/x86/pci/pci_machdep.c: revision 1.61 via patch
sys/arch/x86/pci/pci_machdep.c: revision 1.66 via patch
Force pci_mode 1 when running as Xen HVM domU to allow cd* to be
detected correctly. Fixes kern/48770. Thanks to cube@
Force PCI mode 1 when running under QEMU, to work around QEMU bug 897771.
This should also make it possible to boot NetBSD under versions of KVM
that have inherited said QEMU bug. Fixes PR kern/45671.
 1.34.10.1 19-May-2012  riz Pull up following revision(s) (requested by gendalia in ticket #1755):
sys/arch/x86/pci/pci_machdep.c: revision 1.36
add SIS 740 to the list of chipsets known to implement PCI configuration
mode 1 incorrectly, from Jason White
(see thread "ACPI issue with old Shuttle system" on port-i386)
 1.34.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.37.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.37.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.41.2.2 31-May-2011  rmind sync with head
 1.41.2.1 30-May-2010  rmind sync with head
 1.44.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.52.2.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.52.2.1 17-Apr-2012  yamt sync with head
 1.53.4.4 06-Mar-2012  mrg sync to -current
 1.53.4.3 06-Mar-2012  mrg sync to -current
 1.53.4.2 04-Mar-2012  mrg sync to latest -current.
 1.53.4.1 18-Feb-2012  mrg merge to -current.
 1.54.8.1 20-Oct-2013  bouyer Apply patchm requested by gson in ticket #963:
sys/arch/x86/pci/pci_machdep.c 1.61 via patch

Force PCI mode 1 when running under QEMU, to work around
QEMU bug 897771.
This should also make it possible to boot NetBSD under versions of KVM
that have inherited said QEMU bug. Fixes PR kern/45671.
 1.54.6.1 20-Oct-2013  bouyer Apply patch, requested by gson in ticket #963:
sys/arch/x86/pci/pci_machdep.c 1.61 via patch

Force PCI mode 1 when running under QEMU, to work around
QEMU bug 897771.
This should also make it possible to boot NetBSD under versions of KVM
that have inherited said QEMU bug. Fixes PR kern/45671.
 1.54.2.2 21-May-2014  bouyer Pull up following revision(s) (requested by sborrill in ticket #1060):
sys/arch/x86/pci/pci_machdep.c: revision 1.66
Force pci_mode 1 when running as Xen HVM domU to allow cd* to be
detected correctly. Fixes kern/48770. Thanks to cube@
 1.54.2.1 20-Oct-2013  bouyer Apply patch, requested by riastradh in ticket #962:
sys/arch/x86/pci/pci_machdep.c 1.61 via patch

Force PCI mode 1 when running under QEMU, to work around
QEMU bug 897771.
This should also make it possible to boot NetBSD under versions of KVM
that have inherited said QEMU bug. Fixes PR kern/45671.
 1.56.2.3 03-Dec-2017  jdolecek update from HEAD
 1.56.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.56.2.1 23-Jun-2013  tls resync from head
 1.57.6.1 23-Jul-2013  riastradh sync with HEAD
 1.57.4.2 18-May-2014  rmind sync with head
 1.57.4.1 28-Aug-2013  rmind sync with head
 1.65.2.1 10-Aug-2014  tls Rebase.
 1.67.2.1 25-Jan-2015  martin Pull up following revision(s) (requested by nonaka in ticket #451):
sys/arch/x86/pci/pci_machdep.c: revision 1.68
we don't need to keep track of curmode if not vga_post.
 1.69.2.5 28-Aug-2017  skrll Sync with HEAD
 1.69.2.4 05-Oct-2016  skrll Sync with HEAD
 1.69.2.3 09-Jul-2016  skrll Sync with HEAD
 1.69.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.69.2.1 06-Jun-2015  skrll Sync with HEAD
 1.74.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.76.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.79.8.3 28-Jul-2018  pgoyette Sync with HEAD
 1.79.8.2 25-Jun-2018  pgoyette Sync with HEAD
 1.79.8.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.79.2.3 23-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1890):

sys/arch/x86/pci/pci_machdep.c: revision 1.94

Fix detection of availability of MSI/MSI-X on some systems.

Try to find all functions on bus 0, device 0 to find a PCI host bridge.
Some CPU's host bridge is at 0:0.4. Tested by Intel Snow Ridge.
 1.79.2.2 12-Jun-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1280):

sys/arch/x86/x86/consinit.c: revision 1.29
sys/dev/hyperv/vmbusvar.h: revision 1.2
sys/dev/hyperv/genfb_vmbusvar.h: revision 1.1
sys/arch/x86/x86/x86_autoconf.c: revision 1.78
sys/arch/x86/x86/identcpu.c: revision 1.91
sys/arch/x86/x86/hyperv.c: revision 1.2
sys/arch/x86/x86/hyperv.c: revision 1.3
sys/arch/x86/x86/hyperv.c: revision 1.4
sys/arch/i386/conf/GENERIC: revision 1.1207
sys/dev/wscons/wsconsio.h: revision 1.123
sys/arch/x86/x86/hypervvar.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.528
sys/dev/hyperv/files.hyperv: revision 1.2
sys/arch/x86/include/autoconf.h: revision 1.6
sys/dev/hyperv/hyperv_common.c: revision 1.2
sys/arch/xen/x86/autoconf.c: revision 1.23
sys/arch/x86/pci/pci_machdep.c: revision 1.86
sys/dev/hyperv/hvkbd.c: revision 1.1
sys/dev/hyperv/hypervvar.h: revision 1.2
sys/dev/acpi/vmbus_acpi.c: revision 1.2
sys/dev/hyperv/vmbus.c: revision 1.3
sys/dev/hyperv/hvkbdvar.h: revision 1.1
sys/dev/hyperv/genfb_vmbus.c: revision 1.1

Added drivers for Hyper-V Synthetic Keyboard and Video device.

Avoid undefined reference to `hyperv_guid_video' without vmbus(4).

Avoid undefined reference to `hyperv_is_gen1' without hyperv(4).

Use efi_probe().
 1.79.2.1 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #740):

sys/arch/x86/pci/pci_machdep.c: revision 1.80

efiboot reports parent ppb bus/device/function of booted network inteface.
 1.82.2.1 10-Jun-2019  christos Sync with HEAD
 1.86.2.2 16-May-2025  martin Pull up following revision(s) (requested by manu in ticket #1955):

sys/arch/x86/pci/pci_machdep.c: revision 1.99 (via patch)

Search host bridge on all devices from PCI bus 0

We look for host bridge MSI capability to enable MSI on PCI devices,
which require locating the host bridge itself. Previously we assumed
it was on bus 0, device 0, but that assmption misses some setups.

For instance, Dell Poweredge r760xd2 has its host bridge on bus 0,
device 20, function 4.

This change iterates on all devices on bus 0 to find the host bridge.
 1.86.2.1 23-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1722):

sys/arch/x86/pci/pci_machdep.c: revision 1.94

Fix detection of availability of MSI/MSI-X on some systems.

Try to find all functions on bus 0, device 0 to find a PCI host bridge.
Some CPU's host bridge is at 0:0.4. Tested by Intel Snow Ridge.
 1.87.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.93.4.5 16-May-2025  martin Pull up following revision(s) (requested by manu in ticket #1120):

sys/arch/x86/pci/pci_machdep.c: revision 1.99 (via patch)

Search host bridge on all devices from PCI bus 0

We look for host bridge MSI capability to enable MSI on PCI devices,
which require locating the host bridge itself. Previously we assumed
it was on bus 0, device 0, but that assmption misses some setups.

For instance, Dell Poweredge r760xd2 has its host bridge on bus 0,
device 20, function 4.

This change iterates on all devices on bus 0 to find the host bridge.
 1.93.4.4 21-Oct-2023  martin Apply patch, requested by bouyer in ticket #433:

sys/arch/x86/pci/pci_machdep.c (apply patch)
sys/arch/x86/x86/genfb_machdep.c (apply patch)

Fix build of XEN kernels with genfb(4)
 1.93.4.3 18-Oct-2023  martin Pull up following revision(s) (requested by bouyer in ticket #428):

sys/arch/xen/xen/xen_machdep.c: revision 1.28
sys/arch/x86/pci/pci_machdep.c: revision 1.97
sys/arch/xen/xen/genfb_xen.c: revision 1.1
sys/arch/xen/xen/genfb_xen.c: revision 1.2
sys/arch/xen/include/hypervisor.h: revision 1.59
sys/arch/i386/conf/XEN3PAE_DOM0: revision 1.41 (patch)
sys/arch/x86/x86/genfb_machdep.c: revision 1.22
sys/arch/xen/x86/consinit.c: revision 1.18
sys/arch/xen/x86/autoconf.c: revision 1.26
sys/external/mit/xen-include-public/dist/xen/include/public/platform.h: revision 1.2
sys/arch/xen/conf/files.xen: revision 1.188
sys/arch/x86/x86/consinit.c: revision 1.37
sys/arch/xen/conf/files.xen: revision 1.189
sys/arch/x86/x86/consinit.c: revision 1.38
sys/external/mit/xen-include-public/dist/xen/include/public/xen.h: revision 1.2
sys/arch/x86/include/genfb_machdep.h: revision 1.7
sys/arch/xen/x86/pvh_consinit.c: revision 1.5
sys/arch/xen/x86/pvh_consinit.c: revision 1.6
sys/arch/amd64/conf/XEN3_DOM0: revision 1.201

Move the pvh_xencons so xen_machdep.c as early_xencons, so it can be
used in the future as early ouput for plain PV guests too.

Support non-VGA framebuffers for Xen dom0. This is mandatory for graphic
console on EFI-only hardware.

Add a xen_genfb_getbtinfo() function which will return a btinfo_framebuffer
structure, filled in with parameters provided by Xen

when runing as a Xen dom0, call xen_genfb_getbtinfo() instead of
lookup_bootinfo(BTINFO_FRAMEBUFFER) when adding properties to the
PCI graphic device (when genfb is attached) and in x86_genfb_init()
when genfb is used as console.

x86/x86/consinit.c: If running as a Xen dom0, use xen_genfb_getbtinfo()
to check if we have a genfb console

xen/x86/consinit.c: support genfb as possible console

xen/x86/consinit.c: use the hypervior IO as console until a better one
is found. If the hypervisor is using a serial port for boot messages,
we'll get NetBSD's boot message on the serial port too until
the real console takes over.

xen/x86/autoconf.c: rework device_register() to be closer to the x86 version.
Especially make sure that device_pci_register() is called.

Make sure to always fall back to xen_early_console, even for dom0

Enable genfb in DOM0 kernels

Add ext_lfb_base to dom0_vga_console_info, from recent Xen. We know if it's
present or not by checking dom0.info_size

Add XENPF_get_dom0_console, which gets a dom0_vga_console_info stucture
from the hypervisor. To be used by PVH dom0 kernels.

XENPVH option is not used. Fix consinit.c to use XENPVHVM as intended
and XENPVH from defflag
for a dom0 PVH, the dom0_vga_console_info structure has to be retrieved
using a platform hypercall; do so in the XENPVHVM case.

Now genfb works in a PVH dom0 running on Xen 4.18 (Xen 4.15 doesn't support
this platoform op, so no way to make it work here).
 1.93.4.2 18-Oct-2023  martin Pull up following revision(s) (requested by bouyer in ticket #425):

sys/arch/x86/pci/pci_machdep.c: revision 1.96
sys/arch/x86/acpi/acpi_machdep.c: revision 1.36
sys/arch/x86/x86/hyperv.c: revision 1.16
sys/arch/x86/x86/genfb_machdep.c: revision 1.21
sys/arch/x86/acpi/acpi_wakeup.c: revision 1.56
sys/arch/x86/include/genfb_machdep.h: revision 1.6

Declare
int acpi_md_vesa_modenum;
int acpi_md_vbios_reset;
struct vcons_screen x86_genfb_console_screen;

in genfb_machdep.h instead of locally as extern in various .c files.
 1.93.4.1 23-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #337):

sys/arch/x86/pci/pci_machdep.c: revision 1.94

Fix detection of availability of MSI/MSI-X on some systems.

Try to find all functions on bus 0, device 0 to find a PCI host bridge.
Some CPU's host bridge is at 0:0.4. Tested by Intel Snow Ridge.
 1.98.2.1 02-Aug-2025  perseant Sync with HEAD
 1.19 21-Nov-2023  gutteridge pci_machdep.c & pci_msi_machdep.c: comment fixes

Correct spelling and grammar in some comments.
 1.18 13-May-2023  andvar s/requied/required/ in comments (likely grammar should be also improved in the
future).
 1.17 23-May-2022  bouyer Work in progress on MSI/MSI-X on Xen (MSI works on my hardware, more work
needed for MSI-X):
- Xen silently rejects 32 bits writes to MSI configuration registers
(especially when setting PCI_MSI_CTL_MSI_ENABLE/PCI_MSIX_CTL_ENABLE),
it expects 16 bits writes. So introduce a pci_conf_write16(),
only available on XENPV (and working only for mode 1 without
PCI_OVERRIDE_CONF_WRITE) and use it to enable MSI or MSI-X on XENPV.
- for multi-MSI vectors, Xen allocates all of them in a single hypercall,
so it's not convenient to do it at intr_establish() time.
So do it at alloc() time and register the pirqs in the msipic structure.
xen_pic_to_gsi() now just returns the values cached in the msipic.
As a bonus, if the PHYSDEVOP_map_pirq hypercall fails we can fail
the alloc() and we don't need the xen_pci_msi*_probe() hacks.

options NO_PCI_MSI_MSIX still on by default for XEN3_DOM0.
 1.16 05-Dec-2021  msaitoh s/futher/further/ in comment.
 1.15 14-Mar-2021  skrll Remoave an extra space from a comment
 1.14 19-Jul-2020  jdolecek branches: 1.14.2;
for Xen MSI, fallback to INTx when PHYSDEVOP_map_pirq fails for the device

apparently Xen requires VT-d to be enabled in BIOS for PHYSDEVOP_map_pirq
to work, this change makes it work on systems with VT-d disabled or missing

adresses the panic part of PR port-xen/55285 by Patrick Welche
 1.13 28-Jul-2017  maxv branches: 1.13.2;
Don't include malloc.h.
 1.12 01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.11 14-Apr-2017  knakahara disable msi/msix when the system doesn't detect ioapic. This would fix PR kern/52111.

Some system does not detect ioapic when "boot -1", disable acpi, and so on.
In such cases, msi/msix doesn't work, so disable them.

This patch is implemented by nonaka@n.o, I just commit by proxy, thanks.
 1.10 28-Nov-2016  knakahara branches: 1.10.2;
fix build of amd64/i386 with NO_PCI_MSI_MSIX option.
 1.9 17-Aug-2015  knakahara branches: 1.9.2;
Add kernel code to support intrctl(8).
 1.8 13-Aug-2015  msaitoh - Don't take pci_attach_args as an argument in pci_msi[x]_count().
- Move prototypes of pci_msi[x]_count() from x86/x86/pci_machdep_common to
sys/dev/pci/pcivar.h.
- Move pci_msi[x]_count() from x86/pci/pci_msi_machdep.c to sys/dev/pci/pci.c
 1.7 11-Aug-2015  msaitoh Add missing opt_intrdebug.h.
 1.6 22-Jun-2015  msaitoh Don't check PCI_FLAGS_"MSI"_OKAY in pci_"msix"_alloc_common().
OK'd by knakahara.
 1.5 15-May-2015  knakahara branches: 1.5.2;
pci_msi_string() must be used by MD code only.
 1.4 15-May-2015  knakahara refactor: change function names and move them.
 1.3 15-May-2015  knakahara unify INTx, MSI and MSI-X APIs without alloc. (alloc API is under discussion)
 1.2 08-May-2015  knakahara add a const qualifier to struct pci_attach_args *pa argument
 1.1 27-Apr-2015  knakahara add x86 MD MSI/MSI-X support code.
 1.5.2.5 28-Aug-2017  skrll Sync with HEAD
 1.5.2.4 05-Dec-2016  skrll Sync with HEAD
 1.5.2.3 22-Sep-2015  skrll Sync with HEAD
 1.5.2.2 06-Jun-2015  skrll Sync with HEAD
 1.5.2.1 15-May-2015  skrll file pci_msi_machdep.c was added on branch nick-nhusb on 2015-06-06 14:40:04 +0000
 1.9.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.9.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.13.2.2 03-Dec-2017  jdolecek update from HEAD
 1.13.2.1 28-Jul-2017  jdolecek file pci_msi_machdep.c was added on branch tls-maxphys on 2017-12-03 11:36:50 +0000
 1.14.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3 17-Aug-2015  knakahara branches: 1.3.16;
Add kernel code to support intrctl(8).
 1.2 15-May-2015  knakahara branches: 1.2.2;
pci_msi_string() must be used by MD code only.
 1.1 15-May-2015  knakahara unify INTx, MSI and MSI-X APIs without alloc. (alloc API is under discussion)
 1.2.2.3 22-Sep-2015  skrll Sync with HEAD
 1.2.2.2 06-Jun-2015  skrll Sync with HEAD
 1.2.2.1 15-May-2015  skrll file pci_msi_machdep.h was added on branch nick-nhusb on 2015-06-06 14:40:04 +0000
 1.3.16.2 03-Dec-2017  jdolecek update from HEAD
 1.3.16.1 17-Aug-2015  jdolecek file pci_msi_machdep.h was added on branch tls-maxphys on 2017-12-03 11:36:50 +0000
 1.9 21-Jun-2021  christos prop_dictionary_set_cstring_nocopy -> prop_dictionary_set_string_nocopy
 1.8 01-Mar-2019  msaitoh branches: 1.8.16;
- Almost all ppbreg.h's definitions are also in pcireg.h. Remove duplicated
definitions from ppbreg.h and move some definitions from ppbreg.h to
pcireg.h.
- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard Timer Status
and Discard Timer SERR# Enable bit in pci_subr.c.
- PCI_BRIDGE_PREFETCHBASE32_REG and PCI_BRIDGE_PREFETCHLIMIT32_REG are
"upper" 32bit registers, rename to *UP32_REG to avoid confusion.
- Use macro.
 1.7 01-Jun-2017  chs branches: 1.7.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.6 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.5 27-Jul-2015  msaitoh KNF.
 1.4 27-Oct-2012  chs branches: 1.4.14;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.3 18-Oct-2011  dyoung branches: 1.3.2; 1.3.12;
Add an implementation of device_pci_props_register().
 1.2 13-Sep-2011  dyoung Clean up a bit: delete #if 1 and its corresponding #endif.
 1.1 29-Aug-2011  dyoung Move the code for grovelling in PCI configuration space for assigned
memory & I/O regions into its own module, pci_ranges.c, so that we can
leave it out on systems that won't need it.
 1.3.12.2 03-Dec-2017  jdolecek update from HEAD
 1.3.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.3.2.1 30-Oct-2012  yamt sync with head
 1.4.14.3 28-Aug-2017  skrll Sync with HEAD
 1.4.14.2 09-Jul-2016  skrll Sync with HEAD
 1.4.14.1 22-Sep-2015  skrll Sync with HEAD
 1.7.10.1 10-Jun-2019  christos Sync with HEAD
 1.8.16.1 01-Aug-2021  thorpej Sync with HEAD.
 1.22 19-Oct-2025  thorpej Use {,e}isabus_attach().
 1.21 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.20 24-Apr-2021  thorpej branches: 1.20.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.19 04-Oct-2019  mrg branches: 1.19.10;
add missing break.

surely it is not intended to treat viatech devices with
non VT82C686A's device id as maybe cyrix pci bridges.
 1.18 17-Jun-2019  msaitoh KNF. No functional change.
 1.17 11-Feb-2019  cherry We reorganise definitions for XEN source support as follows:

XEN - common sources required for baseline XEN support.
XENPV - sources required for support of XEN in PV mode.
XENPVHVM - sources required for support for XEN in HVM mode.
XENPVH - sources required for support for XEN in PVH mode.
 1.16 04-Mar-2018  jdolecek branches: 1.16.4;
according to VT82C686A chip specs, the VIA Technologies device 0x3057
is more a Power Management controller, rename the pcidevs entry and device
macro

PR kern/31963 by Nicolas Joly
 1.15 06-Apr-2012  plunky device_pmf_is_registered() is not required
 1.14 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.13 01-Jul-2011  dyoung branches: 1.13.2; 1.13.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.12 28-Apr-2010  dyoung On x86, change the bus_space_tag_t to a pointer to a struct
bus_space_tag. For now, bus_space_tag's only member is
bst_type, the type of space, which is either X86_BUS_SPACE_IO
or X86_BUS_SPACE_MEM. In the future, new bus_space_tag members
will refer to override-functions installed by a new function,
bus_space_tag_create(9).

Add pointers to constant struct bus_space_tag, x86_bus_space_io and
x86_bus_space_mem. Use them to replace most uses of X86_BUS_SPACE_IO
and X86_BUS_SPACE_MEM.

Add an x86-specific bus_space_is_equal(9) implementation that compares
the two tags' bst_type.
 1.11 08-Jan-2010  dyoung branches: 1.11.2; 1.11.4;
Move all copies of ifattr_match() to sys/kern/subr_autoconf.c.
 1.10 23-Aug-2009  jmcneill Save a line of dmesg by printing the vendor/product info on the same line
as the locators.
 1.9 18-Aug-2009  dyoung Allow detachment and re-attachment of an ISA bus at an PCI-ISA bus
bridge, isa0 at pcib0.
 1.8 02-Apr-2009  dyoung During shutdown, detach devices in an orderly fashion.

Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks. For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown. Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags. Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag. The default for kern.detachall is 0. SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress. In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs. Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
 1.7 04-Aug-2008  cegger branches: 1.7.2; 1.7.8;
struct cfdata -> cfdata_t
 1.6 03-Aug-2008  joerg Move some MD declarations from x86/pci/files.pci to x86/conf/files.x86,
so that Xen can use the former.

Drop Xen's pcib.c in favor of the x86 code and thereby unbreak ichlpcib.
 1.5 20-Jul-2008  martin Make the softc externally visible, so other bridges reusing this code
don't have to "get it right" manually.
 1.4 28-Apr-2008  martin branches: 1.4.2; 1.4.4; 1.4.6;
Remove clause 3 and 4 from TNF licenses
 1.3 22-Feb-2008  dyoung branches: 1.3.2; 1.3.4;
Add methods to detach self and children.

Use device_t and accessors. Use aprint_*_dev().
 1.2 09-Dec-2007  jmcneill branches: 1.2.6; 1.2.10;
Merge jmcneill-pm branch.
 1.1 26-Oct-2007  xtraeme branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10; 1.1.12; 1.1.14; 1.1.16;
Share pcib(4) and amdpcib(4) between i386 and amd64; one copy is enough.
 1.1.16.1 11-Dec-2007  yamt sync with head.
 1.1.14.1 26-Dec-2007  ad Sync with head.
 1.1.12.2 03-Dec-2007  ad Sync with HEAD.
 1.1.12.1 26-Oct-2007  ad file pcib.c was added on branch vmlocking on 2007-12-03 19:04:29 +0000
 1.1.10.2 13-Nov-2007  bouyer Sync with HEAD
 1.1.10.1 26-Oct-2007  bouyer file pcib.c was added on branch bouyer-xenamd64 on 2007-11-13 16:00:20 +0000
 1.1.8.4 23-Mar-2008  matt sync with HEAD
 1.1.8.3 09-Jan-2008  matt sync with HEAD
 1.1.8.2 06-Nov-2007  matt sync with HEAD
 1.1.8.1 26-Oct-2007  matt file pcib.c was added on branch matt-armv6 on 2007-11-06 23:23:44 +0000
 1.1.4.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.1.4.4 12-Nov-2007  joerg CG unused softc fields.
 1.1.4.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.1.4.2 28-Oct-2007  joerg Sync with HEAD.
 1.1.4.1 26-Oct-2007  joerg file pcib.c was added on branch jmcneill-pm on 2007-10-28 20:11:00 +0000
 1.1.2.4 27-Feb-2008  yamt sync with head.
 1.1.2.3 21-Jan-2008  yamt sync with head
 1.1.2.2 27-Oct-2007  yamt sync with head.
 1.1.2.1 26-Oct-2007  yamt file pcib.c was added on branch yamt-lazymbuf on 2007-10-27 11:28:58 +0000
 1.2.10.3 28-Sep-2008  mjf Sync with HEAD.
 1.2.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.2.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.2.6.1 24-Mar-2008  keiichi sync with head.
 1.3.4.6 11-Aug-2010  yamt sync with head.
 1.3.4.5 11-Mar-2010  yamt sync with head
 1.3.4.4 16-Sep-2009  yamt sync with head
 1.3.4.3 19-Aug-2009  yamt sync with head.
 1.3.4.2 04-May-2009  yamt sync with head.
 1.3.4.1 16-May-2008  yamt sync with head.
 1.3.2.1 18-May-2008  yamt sync with head.
 1.4.6.1 19-Oct-2008  haad Sync with HEAD.
 1.4.4.1 28-Jul-2008  simonb Sync with head.
 1.4.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.7.8.4 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.7.8.3 24-Oct-2010  jym Sync with HEAD
 1.7.8.2 01-Nov-2009  jym Sync with HEAD.
 1.7.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.11.4.1 30-May-2010  rmind sync with head
 1.11.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.13.6.2 29-Apr-2012  mrg sync to latest -current.
 1.13.6.1 18-Feb-2012  mrg merge to -current.
 1.13.2.1 17-Apr-2012  yamt sync with head
 1.16.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.16.4.1 10-Jun-2019  christos Sync with HEAD
 1.19.10.1 24-Mar-2021  thorpej Don't filter interface attributes in rescan functions for devices that
carry only a single interface attribute. The autoconfiguration machinery
already considers interface attributes when searching for possible parents.
 1.20.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 18-Aug-2009  dyoung Allow detachment and re-attachment of an ISA bus at an PCI-ISA bus
bridge, isa0 at pcib0.
 1.1 20-Jul-2008  martin branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.16; 1.1.20;
Make the softc externally visible, so other bridges reusing this code
don't have to "get it right" manually.
 1.1.20.3 19-Aug-2009  yamt sync with head.
 1.1.20.2 04-May-2009  yamt sync with head.
 1.1.20.1 20-Jul-2008  yamt file pcibvar.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:10 +0000
 1.1.16.1 01-Nov-2009  jym Sync with HEAD.
 1.1.8.2 19-Oct-2008  haad Sync with HEAD.
 1.1.8.1 20-Jul-2008  haad file pcibvar.h was added on branch haad-dm on 2008-10-19 22:16:07 +0000
 1.1.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.6.1 20-Jul-2008  mjf file pcibvar.h was added on branch mjf-devfs2 on 2008-09-28 10:40:12 +0000
 1.1.4.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.4.1 20-Jul-2008  wrstuden file pcibvar.h was added on branch wrstuden-revivesa on 2008-09-18 04:33:38 +0000
 1.1.2.2 28-Jul-2008  simonb Sync with head.
 1.1.2.1 20-Jul-2008  simonb file pcibvar.h was added on branch simonb-wapbl on 2008-07-28 14:37:26 +0000
 1.17 04-Nov-2017  cherry Remove bitrotted xen specific versions of pci, pciide machdep related code.

Use the common x86/ code instead.
 1.16 15-Oct-2016  jdolecek provide intr xname
 1.15 27-Jul-2015  msaitoh branches: 1.15.2;
KNF.
 1.14 27-Apr-2015  knakahara add intr_handle_t and let pci_intr_handle_t use it.
 1.13 12-May-2014  joerg branches: 1.13.4;
buf is only used in the ioapic case.
 1.12 29-Mar-2014  christos branches: 1.12.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.11 04-Apr-2011  dyoung branches: 1.11.4; 1.11.14; 1.11.18;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.10 06-Nov-2010  jakllsch branches: 1.10.2;
Implement pciide_machdep_compat_intr_disestablish() to help enable
detachment of compatibility-mapped pciide(4)-family controllers.
 1.9 01-May-2009  cegger branches: 1.9.2; 1.9.4;
- struct device * -> device_t
- remove useless parenthesis
 1.8 16-Apr-2008  cegger branches: 1.8.4; 1.8.18;
- use aprint_*_dev and device_xname
- use POSIX integer types
 1.7 01-Dec-2007  jmcneill branches: 1.7.14;
aprintify
 1.6 16-Nov-2006  christos branches: 1.6.8; 1.6.26; 1.6.28; 1.6.34;
__unused removal on arguments; approved by core.
 1.5 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.4 11-Dec-2005  christos branches: 1.4.20; 1.4.22;
merge ktrace-lwp.
 1.3 30-Oct-2003  fvdl branches: 1.3.4; 1.3.18;
* keep track of PCI buses that aren't known by firmware, but are found
by NetBSD
* use this info in in intr_find_mpmapping
* get rid of the last argument to intr_find_mpmapping, it was redundant
 1.2 16-Oct-2003  fvdl Add hooks and structures to allow the MP table intr mapping code a
better shot at finding a mapping. For PCI interrupts, if a bus
has no mappings, try its parent, with the swizzled pin, and the
bridge's device number.
 1.1 06-Sep-2003  fvdl Move the bulk of pci_intr_string into a seperate intr_string function. Use
that new function to print the pciide compat interrupt in pciide_machdep.c.
Share pciide_machdep.c between amd64 and i386.
 1.3.18.2 07-Dec-2007  yamt sync with head
 1.3.18.1 30-Dec-2006  yamt sync with head.
 1.3.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.4.2 03-Aug-2004  skrll Sync with HEAD
 1.3.4.1 30-Oct-2003  skrll file pciide_machdep.c was added on branch ktrace-lwp on 2004-08-03 10:43:04 +0000
 1.4.22.2 10-Dec-2006  yamt sync with head.
 1.4.22.1 22-Oct-2006  yamt sync with head
 1.4.20.1 18-Nov-2006  ad Sync with head.
 1.6.34.1 08-Dec-2007  mjf Sync with HEAD.
 1.6.28.1 09-Jan-2008  matt sync with HEAD
 1.6.26.1 01-Dec-2007  jmcneill Sync with HEAD.
 1.6.8.1 03-Dec-2007  ad Sync with HEAD.
 1.7.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.18.4 02-May-2011  jym Sync with head.
 1.8.18.3 10-Jan-2011  jym Sync with HEAD
 1.8.18.2 01-Nov-2009  jym Sync with HEAD.
 1.8.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.4.1 04-May-2009  yamt sync with head.
 1.9.4.2 21-Apr-2011  rmind sync with head
 1.9.4.1 05-Mar-2011  rmind sync with head
 1.9.2.1 09-Nov-2010  uebayasi Sync with HEAD.
 1.10.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.18.1 18-May-2014  rmind sync with head
 1.11.14.2 03-Dec-2017  jdolecek update from HEAD
 1.11.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.2.1 10-Aug-2014  tls Rebase.
 1.13.4.3 05-Dec-2016  skrll Sync with HEAD
 1.13.4.2 22-Sep-2015  skrll Sync with HEAD
 1.13.4.1 06-Jun-2015  skrll Sync with HEAD
 1.15.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.3 07-Apr-2020  christos Recognize more rdc devices (Andrius V.)
 1.2 01-Jul-2011  dyoung branches: 1.2.46; 1.2.54; 1.2.58;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.1 04-Apr-2011  bouyer branches: 1.1.2; 1.1.4; 1.1.8;
Add a driver for RDC's vortex86/PMX-1000 SoC PCI/ISA bridge, with support
for the integrated watchdog timer.
 1.1.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.1 04-Apr-2011  jruoho file rdcpcib.c was added on branch jruoho-x86intr on 2011-06-06 09:07:07 +0000
 1.1.4.3 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.1.4.2 02-May-2011  jym Sync with head.
 1.1.4.1 04-Apr-2011  jym file rdcpcib.c was added on branch jym-xensuspend on 2011-05-02 22:49:57 +0000
 1.1.2.2 21-Apr-2011  rmind sync with head
 1.1.2.1 04-Apr-2011  rmind file rdcpcib.c was added on branch rmind-uvmplock on 2011-04-21 01:41:32 +0000
 1.2.58.1 12-Jul-2020  martin Additionaly pull up the following revisions for ticket #998 to unbreak
the build:

sys/arch/x86/pci/rdcpcib.c 1.3

Recognize more RDC devices.
 1.2.54.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.46.1 20-Jul-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1578):

sys/dev/pci/pcidevs: revision 1.1404
sys/dev/pci/pcidevs: revision 1.1405
sys/arch/x86/pci/rdcpcib.c: revision 1.3

Add more RDC products (Andrius V)

Recognize more rdc devices (Andrius V.)

Fix typo
 1.10 12-Apr-2023  riastradh ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.

Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.9 22-Sep-2022  riastradh branches: 1.9.4;
tco(4): Nix PMC_TCO_BASE offset in TCO register definitions.

This just uses a subregion with PMC_TCO_BASE automatically applied.

No functional change intended.
 1.8 22-Sep-2022  riastradh tco(4): Use a subregion of the PMC registers for TCO registers.

This is an intermediate step that will let us decouple it from access
via PMBASE.
 1.7 22-Sep-2022  riastradh ichlpcib(4), tco(4): Rename iot -> pmt, ioh -> pmh.

Makes it clearer that this is specifically about the power management
controller (PMC) registers relative to PMBASE.
 1.6 22-Sep-2022  riastradh ichlpcib(4), tco(4): Take `lpcib_' off various names.

For PMC-specific ones, change `lpcib_' to `pmc_'. These are in a
separate PCI device in newer chipsets.

For TCO-specific ones, which may live in different places, whether at
their own base address or as an offset from PMBASE, just leave it as
`tco_' or `tcotimer'.

No functional change intended.
 1.5 22-Sep-2022  riastradh tco(4): Rename lpcib_tco_attach_args -> tco_attach_args.

No longer hangs off LPC bus, newer devices hang it off SMBus.
 1.4 22-Sep-2022  riastradh tco(4): Change has_rcba bit into version number.

Will be useful for newer Intel platform controller hubs.

No functional change intended. Module ABI is unchanged, although older
modules will do something nonseneical when confronted with versions
above 1 -- that will require a revbump (but with any luck, it will make
life easier for versions above 2 easier once we do that).
 1.3 21-Sep-2022  riastradh tco(4): Fix whitespace. No functional change intended.
 1.2 30-Aug-2015  christos branches: 1.2.16;
print the configuration information early so that it does not get intermingled
with possible error prints.
 1.1 03-May-2015  pgoyette branches: 1.1.2;
Separate the watchdog code from the pcib code, and make the watchdog
a loadable module.
 1.1.2.3 22-Sep-2015  skrll Sync with HEAD
 1.1.2.2 06-Jun-2015  skrll Sync with HEAD
 1.1.2.1 03-May-2015  skrll file tco.c was added on branch nick-nhusb on 2015-06-06 14:40:04 +0000
 1.2.16.2 03-Dec-2017  jdolecek update from HEAD
 1.2.16.1 30-Aug-2015  jdolecek file tco.c was added on branch tls-maxphys on 2017-12-03 11:36:50 +0000
 1.9.4.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #282):

sys/dev/pci/ichsmb.c: revision 1.82
sys/arch/amd64/conf/GENERIC: revision 1.602
sys/arch/x86/pci/tco.c: revision 1.10
sys/arch/x86/pci/tco.h: revision 1.5
sys/arch/x86/pci/ichlpcib.c: revision 1.59
sys/dev/ic/i82801lpcreg.h: revision 1.17
sys/arch/x86/pci/files.pci: revision 1.27
sys/dev/pci/files.pci: revision 1.446

ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.
Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.5 12-Apr-2023  riastradh ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.

Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.4 22-Sep-2022  riastradh branches: 1.4.4;
ichlpcib(4), tco(4): Rename iot -> pmt, ioh -> pmh.

Makes it clearer that this is specifically about the power management
controller (PMC) registers relative to PMBASE.
 1.3 22-Sep-2022  riastradh tco(4): Rename lpcib_tco_attach_args -> tco_attach_args.

No longer hangs off LPC bus, newer devices hang it off SMBus.
 1.2 22-Sep-2022  riastradh tco(4): Change has_rcba bit into version number.

Will be useful for newer Intel platform controller hubs.

No functional change intended. Module ABI is unchanged, although older
modules will do something nonseneical when confronted with versions
above 1 -- that will require a revbump (but with any luck, it will make
life easier for versions above 2 easier once we do that).
 1.1 03-May-2015  pgoyette branches: 1.1.2; 1.1.18;
Separate the watchdog code from the pcib code, and make the watchdog
a loadable module.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-May-2015  jdolecek file tco.h was added on branch tls-maxphys on 2017-12-03 11:36:50 +0000
 1.1.2.2 06-Jun-2015  skrll Sync with HEAD
 1.1.2.1 03-May-2015  skrll file tco.h was added on branch nick-nhusb on 2015-06-06 14:40:04 +0000
 1.4.4.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #282):

sys/dev/pci/ichsmb.c: revision 1.82
sys/arch/amd64/conf/GENERIC: revision 1.602
sys/arch/x86/pci/tco.c: revision 1.10
sys/arch/x86/pci/tco.h: revision 1.5
sys/arch/x86/pci/ichlpcib.c: revision 1.59
sys/dev/ic/i82801lpcreg.h: revision 1.17
sys/arch/x86/pci/files.pci: revision 1.27
sys/dev/pci/files.pci: revision 1.446

ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.
Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.4 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.3 24-Apr-2021  thorpej branches: 1.3.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.2 11-Jul-2016  msaitoh branches: 1.2.32;
KNF. No functional change.
 1.1 05-Dec-2012  christos branches: 1.1.2; 1.1.6; 1.1.18;
Intel Atom E600 PCI-LPC bridge, adds a watchdog + HPET support. Tested
on a Soekris net6501. (jmcneill)
 1.1.18.1 05-Oct-2016  skrll Sync with HEAD
 1.1.6.3 03-Dec-2017  jdolecek update from HEAD
 1.1.6.2 25-Feb-2013  tls resync with head
 1.1.6.1 05-Dec-2012  tls file tcpcib.c was added on branch tls-maxphys on 2013-02-25 00:29:05 +0000
 1.1.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.1.2.1 05-Dec-2012  yamt file tcpcib.c was added on branch yamt-pagecache on 2013-01-16 05:33:10 +0000
 1.2.32.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.3.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6 10-May-2023  riastradh x86/imc(4): Use config_detach_children.
 1.5 28-Sep-2022  msaitoh Fix compile error.
 1.4 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.3 24-Apr-2021  thorpej branches: 1.3.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.2 15-Mar-2018  maya branches: 1.2.6; 1.2.16;
Provide a default case also when building imc as builtin.

Fixes ALL kernel build. ok pgoyette.
 1.1 01-Mar-2018  pgoyette branches: 1.1.2;
Move the imc(4) and imcsmb(4) sources into architecture-specific
directory (for previous CVS history see the sys/dev/pci/imcsmb/
Attic)
 1.1.2.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.2.16.2 28-Mar-2021  thorpej - The third argument passed to the rescan function is a locs array, not
a pointer to flags.
- imc and imcsmb each carry only a single interface attribute, so no
need to be explicit.
 1.2.16.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.2.6.1 11-Oct-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1537):

sys/arch/x86/pci/imcsmb/imc.c: revision 1.5
sys/dev/pci/pcidevs: revision 1.1461-1.1468

add several samsung nvme entries

Add more Alder Lake devices.

Jasper Lake Intel Trace Hub on Compute Die is not 0x4da6 but 0x4e29.

Add Intel Core 8G (8core, H, Halo) Host Bridge, DRAM.

Sort by number. No functional change.

Add AMD 19h/6xh Root Complex.

Add AMD FCH SATA Controller D

add NVIDIA GeForce GTX 770

Fix compile error.
 1.3.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.7 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.6 10-May-2023  riastradh x86/imc(4): Use config_detach_children.
 1.5 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.4 24-Apr-2021  thorpej branches: 1.4.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.3 22-Dec-2019  thorpej branches: 1.3.10;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.2 03-Mar-2018  pgoyette branches: 1.2.4;
Fix the attach message - needs a ": "
 1.1 01-Mar-2018  pgoyette Move the imc(4) and imcsmb(4) sources into architecture-specific
directory (for previous CVS history see the sys/dev/pci/imcsmb/
Attic)
 1.2.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.10.2 28-Mar-2021  thorpej - The third argument passed to the rescan function is a locs array, not
a pointer to flags.
- imc and imcsmb each carry only a single interface attribute, so no
need to be explicit.
 1.3.10.1 23-Mar-2021  thorpej In imcsmb_rescan(), no need to explcitly check that we're being asked
to rescan on the "i2cbus" interface attribute. The autoconfiguration
machinery will not request a rescan of an interface attribute that a
device does not carry, and imcsmb only carries "i2cbus".
 1.4.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.1 01-Mar-2018  pgoyette Move the imc(4) and imcsmb(4) sources into architecture-specific
directory (for previous CVS history see the sys/dev/pci/imcsmb/
Attic)
 1.1 01-Mar-2018  pgoyette Move the imc(4) and imcsmb(4) sources into architecture-specific
directory (for previous CVS history see the sys/dev/pci/imcsmb/
Attic)

RSS XML Feed