History log of /openbsd-current/sys/dev/pci/pcireg.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.63 13-May-2024 kettenis

Implement hardware masking for MSI and MSI-X on amd64. Note that masking
MSIs can only be done for PCI devices that implement per-vector masking,
which a lot of hardware doesn't implement.

ok mlarkin@


Revision tags: OPENBSD_7_5_BASE
# 1.62 19-Jan-2024 kettenis

Implement Multiple Message MSI support on amd64. This is experimental code
to assist qwx(4) development. We may remove this code again at some point
in the future.

Multiple Message MSI has some serious design flaws, especially when
combined with the APIC interrupt controller architecture. It was
superseded by MSI-X. Unfortunately qwx(4) does not implement MSI-X.

ok stsp@, deraadt@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.61 17-Jun-2022 kettenis

Only probe device 0 on PCI busses corresponding to a PCIe root port or a
PCIe switch/bridge downstream port. This fixes an issue where a device would
show up 32 times if the PCIe port does not terminate configuration requests
targeted at device numbers 1-31 as required by the spec and the PCIe device
does not filter requests based on its own device number. Linux, NetBSD and
FreeBSD (to some extent) already do this.

This should fix an issue seen on Ampere Altra where the BMC's PCI bridge
and USB controller would show up multiple times.

ok jsg@


Revision tags: OPENBSD_7_1_BASE
# 1.60 31-Dec-2021 jsg

Interrups -> Interrupts


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.59 02-Nov-2019 kettenis

Add a few more PCIe capability registers and bits. As usual, the names
are taken from Intel chipset documentation. Prompted by a diff from kurt@.

ok kurt@


# 1.58 28-Oct-2019 stsp

Have iwm(4) configure the PCIe LTR.

Patch by Imre Vadasz.
Cross-check and pcireg.h tweak by kettenis@
ok patrick@


Revision tags: OPENBSD_6_6_BASE
# 1.57 30-May-2019 kettenis

Fix definitions of PCI_MSIX_MAU32 and add a define for the MSI-X function
mask bit.

ok mlarkin@, jmatthew@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.56 03-Aug-2018 kettenis

Let ahci(4) match on _CLS instead of _HID when attaching at acpi(4). Avoids
having to add many more _HID entries to the match table.

ok deraadt@, mlarkin@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.55 09-Aug-2017 mlarkin

vmd: allow guest PCI interrupt line reassignment.

I also added a couple config space register names to pcireg.h to try and
reduce the use of magic numbers in vmd/pci.c

ok pd@


# 1.54 12-Jun-2017 kevlo

From FreeBSD (r227593, r307982):
More and more RealTek controllers started to implement EEE feature.
Vendor driver seems to load a kind of firmware for EEE with
additional PHY fixups. It is known that the EEE feature may need
ASPM support. Unfortunately there is no documentation for EEE of
the controller so enabling ASPM may cause more problems.

The Realtek vendor drivers for FreeBSD and Linux also disable ASPM and
clock request. While here, add a define for the ECPM (Enable Clock Power
Management) bit.

Tested by stsp@ and myself.
ok stsp@


Revision tags: OPENBSD_6_1_BASE
# 1.53 25-Mar-2017 mlarkin

More PCI extended capabilities handling in pcidump.

From Simon Mages

ok deraadt@


# 1.52 22-Mar-2017 jsg

Add some more PCI classes and subclasses. Checked against EDK2 as
"PCI Code and ID Assignment Specification" is only available for those
willing to pay thousands of dollars for PDFs.

Prompted by a dmesg from an AMD Zen system which uses class 0x13
(Non-Essential Instrumentation) and System subclass 0x06 (IOMMU). There
is currently no public documentation for AMD family 17h to reference to
see if this is sane.

ok kettenis@ on an earlier version


# 1.51 16-Mar-2017 deraadt

Print PCIe Extended Capabilities, from Simon Mages
ok kettenis mlarkin


Revision tags: OPENBSD_6_0_BASE
# 1.50 02-Jun-2016 kettenis

Fix two issues in the MSI-X code. First, actually read the MSI-X capability
register. Second, correctly decode the table sizefromits contents.

First issue pointed out by David Hill (with the help of clang). Second
issue spotted after seeing a diff from Christiano Hasbaert.


# 1.49 04-May-2016 kettenis

Initial support for MSI-X. Only supported on amd64 for now. I have diffs to
actually use this in em(4) and xhci(4), but I'm not committing those yet
because we almost certainly need to save and restore the MSI-X registers
during suspend/resume. However, this allows mpi@ to play with multiple-vector
support in networking hardware.

Requested by mpi@
ok mlarkin@, mikeb@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.48 02-Jun-2015 mpi

Add missing define for hpb(4).


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.47 27-Apr-2014 stsp

Add PME_STATUS and PME_EN bitmasks for the PCI PMCSR register.
ok kettenis@


# 1.46 09-Apr-2014 dlg

apparently NVM is a type of mass storage now


Revision tags: OPENBSD_5_5_BASE
# 1.45 26-Aug-2013 jsg

add a define for the link capabilities register for
version 2 of the PCIe capability.


Revision tags: OPENBSD_5_4_BASE
# 1.44 03-Jun-2013 mikeb

Define some more DCSR/DCTL bits; ok kettenis


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.43 13-May-2012 kettenis

Add define for capability 0x12 (SATA).


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.42 19-Jun-2011 kettenis

Fix typo in the "fixed" HyperTransport MSI Mapping Capability address.


# 1.41 30-May-2011 kettenis

Enable MSI for HyperTransport devices that have MSI remapping enabled.


# 1.40 14-May-2011 kettenis

Add register definitions for PCI MSI capaility.

ok oga@, miod@, marco@, dlg@, krw@


Revision tags: OPENBSD_4_9_BASE
# 1.39 05-Dec-2010 kettenis

PCIe based sparc64 machines have always supported access to the extended PCIe
configuration space. So on pyro(4) and vpci(4) return the size appropriate
for the extended PCIe configuration space.

ok miod@


# 1.38 04-Dec-2010 miod

Introduce a new pci routine, pci_conf_size(), which returns the size of a
given pcitag_t configuration address space. Currently, all pci controllers
will return the usual 0x100 bytes of PCI configuration space, but this will
eventually change on PCIe-capable controlers.
ok kettenis@


# 1.37 01-Dec-2010 damien

Add definition for "Extended Synch" bit in PCIe Link Control register.
From PCI Express(R) Base Specification Rev 2.0.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 28-May-2009 damien

Add "Interrupt Disable" bit definition for the PCI Configuration Space
Command register. From PCI Express Base Specification Rev 2.0.
Use same naming as NetBSD.
Needed for wpi(4) and iwn(4).


Revision tags: OPENBSD_4_5_BASE
# 1.35 25-Nov-2008 damien

move some generic PCIe register flags used in wpi(4) and iwn(4)
into common pcireg.h

ok deraadt@, kettenis@, dlg@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 26-Nov-2007 jsg

Add PCI VPD read/write functions from NetBSD required for some things
dlg is playing with.

'put it in' dlg@


# 1.33 25-Nov-2007 kettenis

First step towards PCI Express/ExpressCard hotplug. Unplug should work on
detachable drivers.

"put it in" deraadt@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 31-Jul-2006 mickey

puc@cardbus (only added (commented out) to whom has puc@pci enabled)
tested on puc@pci by fkr and meself on the cardbus.
still needs a bit more work but generally works.
deraadt@ ok and some input from miod@


# 1.31 01-Jun-2006 brad

add 2 subclasses, subclass storage SAS and subclass system SD Host Controller.

From NetBSD


# 1.30 28-May-2006 uwe

Support for standard SD host controllers like the Ricoh 5C822, a small
generic bus layer, and SCSI emulation for SD/MMC memory cards.


# 1.29 11-May-2006 brad

add PCI multimedia subclass type of HD audio.


Revision tags: OPENBSD_3_9_BASE
# 1.28 31-Dec-2005 dlg

add macros for the expansion ROM base address register

ok brad@ grange@ fgsch@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.27 16-Nov-2004 brad

add PCI_ID_CODE

From NetBSD


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 06-Dec-2003 grange

Mark u_int64_t constants with ULL to make gcc3 happy.
ok drahn@


# 1.25 16-Nov-2003 avsm

convert __attribute__((__packed__)) to __packed so that parsers unaware
of gcc extensions have more of a chance.
ok mcbride@, no objections from millert@, deraadt@


# 1.24 06-Oct-2003 fgsch

power management status reg. definition; from netbsd.
ok deraadt@ henning@ krw@.


Revision tags: OPENBSD_3_4_BASE
# 1.23 27-Aug-2003 mickey

this bit is defined as prefetchable and not cachable and thus rename and use appropriately


Revision tags: UBC_SYNC_A
# 1.22 02-Apr-2003 grange

PCI_CAP_MBI should really be PCI_CAP_MSI
ok jason@


# 1.21 01-Apr-2003 grange

Add a couple of new pci subclasses and caps from NetBSD
ok jason@


Revision tags: OPENBSD_3_3_BASE
# 1.20 08-Feb-2003 jason

definitions and structures for vital product data (VPD); from netbsd


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 13-Jul-2002 mickey

define PCI_COMMAND_STATUS_BITS for printfs, according to the enlisted defines


Revision tags: OPENBSD_3_1_BASE
# 1.18 06-Apr-2002 jason

s/REESSERVED/RESERVED/


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.17 08-May-2001 mickey

branches: 1.17.4;
more class/subclass/caps ids; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.16 09-Feb-2001 aaron

Add PCI Power Management Control Register definitions; from NetBSD.


# 1.15 08-Nov-2000 art

Defines for min_gnt and max_lat fields in the bhlc reg.
Not used yet.


Revision tags: OPENBSD_2_8_BASE
# 1.14 20-Sep-2000 niklas

support 64bit BARs from NetBSD


# 1.13 02-Aug-2000 mickey

import a few useful consts from netbsd; mainly for pcibios thing slip


Revision tags: OPENBSD_2_7_BASE SMP_BASE kame_19991208
# 1.12 26-Oct-1999 downsj

branches: 1.12.2;
Missed earlier: add PCI_HDRTYPE_TYPE macro, from NetBSD.


Revision tags: OPENBSD_2_6_BASE
# 1.11 18-Jul-1999 csapuntz

Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.10 30-Jan-1999 niklas

A slew of manifest constants for pci configuration registers gotten from freebsd


Revision tags: OPENBSD_2_4_BASE
# 1.9 12-Jul-1998 deraadt

fix bhlcr shift values; fgsch@olimpo.com.br


# 1.8 25-Apr-1998 deraadt

UDF and 66MHz support; zubin@clouseau.arl.wustl.edu


Revision tags: OPENBSD_2_3_BASE
# 1.7 03-Feb-1998 deraadt

more pci subclasses and such; netbsd


# 1.6 03-Feb-1998 deraadt

more bridge types


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.5 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.4 31-Oct-1996 millert

Add ATM defines. From Jim Rees <rees@umich.edu>


Revision tags: OPENBSD_2_0_BASE
# 1.3 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.2 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.62 19-Jan-2024 kettenis

Implement Multiple Message MSI support on amd64. This is experimental code
to assist qwx(4) development. We may remove this code again at some point
in the future.

Multiple Message MSI has some serious design flaws, especially when
combined with the APIC interrupt controller architecture. It was
superseded by MSI-X. Unfortunately qwx(4) does not implement MSI-X.

ok stsp@, deraadt@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.61 17-Jun-2022 kettenis

Only probe device 0 on PCI busses corresponding to a PCIe root port or a
PCIe switch/bridge downstream port. This fixes an issue where a device would
show up 32 times if the PCIe port does not terminate configuration requests
targeted at device numbers 1-31 as required by the spec and the PCIe device
does not filter requests based on its own device number. Linux, NetBSD and
FreeBSD (to some extent) already do this.

This should fix an issue seen on Ampere Altra where the BMC's PCI bridge
and USB controller would show up multiple times.

ok jsg@


Revision tags: OPENBSD_7_1_BASE
# 1.60 31-Dec-2021 jsg

Interrups -> Interrupts


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.59 02-Nov-2019 kettenis

Add a few more PCIe capability registers and bits. As usual, the names
are taken from Intel chipset documentation. Prompted by a diff from kurt@.

ok kurt@


# 1.58 28-Oct-2019 stsp

Have iwm(4) configure the PCIe LTR.

Patch by Imre Vadasz.
Cross-check and pcireg.h tweak by kettenis@
ok patrick@


Revision tags: OPENBSD_6_6_BASE
# 1.57 30-May-2019 kettenis

Fix definitions of PCI_MSIX_MAU32 and add a define for the MSI-X function
mask bit.

ok mlarkin@, jmatthew@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.56 03-Aug-2018 kettenis

Let ahci(4) match on _CLS instead of _HID when attaching at acpi(4). Avoids
having to add many more _HID entries to the match table.

ok deraadt@, mlarkin@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.55 09-Aug-2017 mlarkin

vmd: allow guest PCI interrupt line reassignment.

I also added a couple config space register names to pcireg.h to try and
reduce the use of magic numbers in vmd/pci.c

ok pd@


# 1.54 12-Jun-2017 kevlo

From FreeBSD (r227593, r307982):
More and more RealTek controllers started to implement EEE feature.
Vendor driver seems to load a kind of firmware for EEE with
additional PHY fixups. It is known that the EEE feature may need
ASPM support. Unfortunately there is no documentation for EEE of
the controller so enabling ASPM may cause more problems.

The Realtek vendor drivers for FreeBSD and Linux also disable ASPM and
clock request. While here, add a define for the ECPM (Enable Clock Power
Management) bit.

Tested by stsp@ and myself.
ok stsp@


Revision tags: OPENBSD_6_1_BASE
# 1.53 25-Mar-2017 mlarkin

More PCI extended capabilities handling in pcidump.

From Simon Mages

ok deraadt@


# 1.52 22-Mar-2017 jsg

Add some more PCI classes and subclasses. Checked against EDK2 as
"PCI Code and ID Assignment Specification" is only available for those
willing to pay thousands of dollars for PDFs.

Prompted by a dmesg from an AMD Zen system which uses class 0x13
(Non-Essential Instrumentation) and System subclass 0x06 (IOMMU). There
is currently no public documentation for AMD family 17h to reference to
see if this is sane.

ok kettenis@ on an earlier version


# 1.51 16-Mar-2017 deraadt

Print PCIe Extended Capabilities, from Simon Mages
ok kettenis mlarkin


Revision tags: OPENBSD_6_0_BASE
# 1.50 02-Jun-2016 kettenis

Fix two issues in the MSI-X code. First, actually read the MSI-X capability
register. Second, correctly decode the table sizefromits contents.

First issue pointed out by David Hill (with the help of clang). Second
issue spotted after seeing a diff from Christiano Hasbaert.


# 1.49 04-May-2016 kettenis

Initial support for MSI-X. Only supported on amd64 for now. I have diffs to
actually use this in em(4) and xhci(4), but I'm not committing those yet
because we almost certainly need to save and restore the MSI-X registers
during suspend/resume. However, this allows mpi@ to play with multiple-vector
support in networking hardware.

Requested by mpi@
ok mlarkin@, mikeb@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.48 02-Jun-2015 mpi

Add missing define for hpb(4).


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.47 27-Apr-2014 stsp

Add PME_STATUS and PME_EN bitmasks for the PCI PMCSR register.
ok kettenis@


# 1.46 09-Apr-2014 dlg

apparently NVM is a type of mass storage now


Revision tags: OPENBSD_5_5_BASE
# 1.45 26-Aug-2013 jsg

add a define for the link capabilities register for
version 2 of the PCIe capability.


Revision tags: OPENBSD_5_4_BASE
# 1.44 03-Jun-2013 mikeb

Define some more DCSR/DCTL bits; ok kettenis


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.43 13-May-2012 kettenis

Add define for capability 0x12 (SATA).


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.42 19-Jun-2011 kettenis

Fix typo in the "fixed" HyperTransport MSI Mapping Capability address.


# 1.41 30-May-2011 kettenis

Enable MSI for HyperTransport devices that have MSI remapping enabled.


# 1.40 14-May-2011 kettenis

Add register definitions for PCI MSI capaility.

ok oga@, miod@, marco@, dlg@, krw@


Revision tags: OPENBSD_4_9_BASE
# 1.39 05-Dec-2010 kettenis

PCIe based sparc64 machines have always supported access to the extended PCIe
configuration space. So on pyro(4) and vpci(4) return the size appropriate
for the extended PCIe configuration space.

ok miod@


# 1.38 04-Dec-2010 miod

Introduce a new pci routine, pci_conf_size(), which returns the size of a
given pcitag_t configuration address space. Currently, all pci controllers
will return the usual 0x100 bytes of PCI configuration space, but this will
eventually change on PCIe-capable controlers.
ok kettenis@


# 1.37 01-Dec-2010 damien

Add definition for "Extended Synch" bit in PCIe Link Control register.
From PCI Express(R) Base Specification Rev 2.0.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 28-May-2009 damien

Add "Interrupt Disable" bit definition for the PCI Configuration Space
Command register. From PCI Express Base Specification Rev 2.0.
Use same naming as NetBSD.
Needed for wpi(4) and iwn(4).


Revision tags: OPENBSD_4_5_BASE
# 1.35 25-Nov-2008 damien

move some generic PCIe register flags used in wpi(4) and iwn(4)
into common pcireg.h

ok deraadt@, kettenis@, dlg@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 26-Nov-2007 jsg

Add PCI VPD read/write functions from NetBSD required for some things
dlg is playing with.

'put it in' dlg@


# 1.33 25-Nov-2007 kettenis

First step towards PCI Express/ExpressCard hotplug. Unplug should work on
detachable drivers.

"put it in" deraadt@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 31-Jul-2006 mickey

puc@cardbus (only added (commented out) to whom has puc@pci enabled)
tested on puc@pci by fkr and meself on the cardbus.
still needs a bit more work but generally works.
deraadt@ ok and some input from miod@


# 1.31 01-Jun-2006 brad

add 2 subclasses, subclass storage SAS and subclass system SD Host Controller.

From NetBSD


# 1.30 28-May-2006 uwe

Support for standard SD host controllers like the Ricoh 5C822, a small
generic bus layer, and SCSI emulation for SD/MMC memory cards.


# 1.29 11-May-2006 brad

add PCI multimedia subclass type of HD audio.


Revision tags: OPENBSD_3_9_BASE
# 1.28 31-Dec-2005 dlg

add macros for the expansion ROM base address register

ok brad@ grange@ fgsch@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.27 16-Nov-2004 brad

add PCI_ID_CODE

From NetBSD


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 06-Dec-2003 grange

Mark u_int64_t constants with ULL to make gcc3 happy.
ok drahn@


# 1.25 16-Nov-2003 avsm

convert __attribute__((__packed__)) to __packed so that parsers unaware
of gcc extensions have more of a chance.
ok mcbride@, no objections from millert@, deraadt@


# 1.24 06-Oct-2003 fgsch

power management status reg. definition; from netbsd.
ok deraadt@ henning@ krw@.


Revision tags: OPENBSD_3_4_BASE
# 1.23 27-Aug-2003 mickey

this bit is defined as prefetchable and not cachable and thus rename and use appropriately


Revision tags: UBC_SYNC_A
# 1.22 02-Apr-2003 grange

PCI_CAP_MBI should really be PCI_CAP_MSI
ok jason@


# 1.21 01-Apr-2003 grange

Add a couple of new pci subclasses and caps from NetBSD
ok jason@


Revision tags: OPENBSD_3_3_BASE
# 1.20 08-Feb-2003 jason

definitions and structures for vital product data (VPD); from netbsd


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 13-Jul-2002 mickey

define PCI_COMMAND_STATUS_BITS for printfs, according to the enlisted defines


Revision tags: OPENBSD_3_1_BASE
# 1.18 06-Apr-2002 jason

s/REESSERVED/RESERVED/


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.17 08-May-2001 mickey

branches: 1.17.4;
more class/subclass/caps ids; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.16 09-Feb-2001 aaron

Add PCI Power Management Control Register definitions; from NetBSD.


# 1.15 08-Nov-2000 art

Defines for min_gnt and max_lat fields in the bhlc reg.
Not used yet.


Revision tags: OPENBSD_2_8_BASE
# 1.14 20-Sep-2000 niklas

support 64bit BARs from NetBSD


# 1.13 02-Aug-2000 mickey

import a few useful consts from netbsd; mainly for pcibios thing slip


Revision tags: OPENBSD_2_7_BASE SMP_BASE kame_19991208
# 1.12 26-Oct-1999 downsj

branches: 1.12.2;
Missed earlier: add PCI_HDRTYPE_TYPE macro, from NetBSD.


Revision tags: OPENBSD_2_6_BASE
# 1.11 18-Jul-1999 csapuntz

Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.10 30-Jan-1999 niklas

A slew of manifest constants for pci configuration registers gotten from freebsd


Revision tags: OPENBSD_2_4_BASE
# 1.9 12-Jul-1998 deraadt

fix bhlcr shift values; fgsch@olimpo.com.br


# 1.8 25-Apr-1998 deraadt

UDF and 66MHz support; zubin@clouseau.arl.wustl.edu


Revision tags: OPENBSD_2_3_BASE
# 1.7 03-Feb-1998 deraadt

more pci subclasses and such; netbsd


# 1.6 03-Feb-1998 deraadt

more bridge types


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.5 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.4 31-Oct-1996 millert

Add ATM defines. From Jim Rees <rees@umich.edu>


Revision tags: OPENBSD_2_0_BASE
# 1.3 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.2 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.61 17-Jun-2022 kettenis

Only probe device 0 on PCI busses corresponding to a PCIe root port or a
PCIe switch/bridge downstream port. This fixes an issue where a device would
show up 32 times if the PCIe port does not terminate configuration requests
targeted at device numbers 1-31 as required by the spec and the PCIe device
does not filter requests based on its own device number. Linux, NetBSD and
FreeBSD (to some extent) already do this.

This should fix an issue seen on Ampere Altra where the BMC's PCI bridge
and USB controller would show up multiple times.

ok jsg@


Revision tags: OPENBSD_7_1_BASE
# 1.60 31-Dec-2021 jsg

Interrups -> Interrupts


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.59 02-Nov-2019 kettenis

Add a few more PCIe capability registers and bits. As usual, the names
are taken from Intel chipset documentation. Prompted by a diff from kurt@.

ok kurt@


# 1.58 28-Oct-2019 stsp

Have iwm(4) configure the PCIe LTR.

Patch by Imre Vadasz.
Cross-check and pcireg.h tweak by kettenis@
ok patrick@


Revision tags: OPENBSD_6_6_BASE
# 1.57 30-May-2019 kettenis

Fix definitions of PCI_MSIX_MAU32 and add a define for the MSI-X function
mask bit.

ok mlarkin@, jmatthew@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.56 03-Aug-2018 kettenis

Let ahci(4) match on _CLS instead of _HID when attaching at acpi(4). Avoids
having to add many more _HID entries to the match table.

ok deraadt@, mlarkin@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.55 09-Aug-2017 mlarkin

vmd: allow guest PCI interrupt line reassignment.

I also added a couple config space register names to pcireg.h to try and
reduce the use of magic numbers in vmd/pci.c

ok pd@


# 1.54 12-Jun-2017 kevlo

From FreeBSD (r227593, r307982):
More and more RealTek controllers started to implement EEE feature.
Vendor driver seems to load a kind of firmware for EEE with
additional PHY fixups. It is known that the EEE feature may need
ASPM support. Unfortunately there is no documentation for EEE of
the controller so enabling ASPM may cause more problems.

The Realtek vendor drivers for FreeBSD and Linux also disable ASPM and
clock request. While here, add a define for the ECPM (Enable Clock Power
Management) bit.

Tested by stsp@ and myself.
ok stsp@


Revision tags: OPENBSD_6_1_BASE
# 1.53 25-Mar-2017 mlarkin

More PCI extended capabilities handling in pcidump.

From Simon Mages

ok deraadt@


# 1.52 22-Mar-2017 jsg

Add some more PCI classes and subclasses. Checked against EDK2 as
"PCI Code and ID Assignment Specification" is only available for those
willing to pay thousands of dollars for PDFs.

Prompted by a dmesg from an AMD Zen system which uses class 0x13
(Non-Essential Instrumentation) and System subclass 0x06 (IOMMU). There
is currently no public documentation for AMD family 17h to reference to
see if this is sane.

ok kettenis@ on an earlier version


# 1.51 16-Mar-2017 deraadt

Print PCIe Extended Capabilities, from Simon Mages
ok kettenis mlarkin


Revision tags: OPENBSD_6_0_BASE
# 1.50 02-Jun-2016 kettenis

Fix two issues in the MSI-X code. First, actually read the MSI-X capability
register. Second, correctly decode the table sizefromits contents.

First issue pointed out by David Hill (with the help of clang). Second
issue spotted after seeing a diff from Christiano Hasbaert.


# 1.49 04-May-2016 kettenis

Initial support for MSI-X. Only supported on amd64 for now. I have diffs to
actually use this in em(4) and xhci(4), but I'm not committing those yet
because we almost certainly need to save and restore the MSI-X registers
during suspend/resume. However, this allows mpi@ to play with multiple-vector
support in networking hardware.

Requested by mpi@
ok mlarkin@, mikeb@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.48 02-Jun-2015 mpi

Add missing define for hpb(4).


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.47 27-Apr-2014 stsp

Add PME_STATUS and PME_EN bitmasks for the PCI PMCSR register.
ok kettenis@


# 1.46 09-Apr-2014 dlg

apparently NVM is a type of mass storage now


Revision tags: OPENBSD_5_5_BASE
# 1.45 26-Aug-2013 jsg

add a define for the link capabilities register for
version 2 of the PCIe capability.


Revision tags: OPENBSD_5_4_BASE
# 1.44 03-Jun-2013 mikeb

Define some more DCSR/DCTL bits; ok kettenis


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.43 13-May-2012 kettenis

Add define for capability 0x12 (SATA).


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.42 19-Jun-2011 kettenis

Fix typo in the "fixed" HyperTransport MSI Mapping Capability address.


# 1.41 30-May-2011 kettenis

Enable MSI for HyperTransport devices that have MSI remapping enabled.


# 1.40 14-May-2011 kettenis

Add register definitions for PCI MSI capaility.

ok oga@, miod@, marco@, dlg@, krw@


Revision tags: OPENBSD_4_9_BASE
# 1.39 05-Dec-2010 kettenis

PCIe based sparc64 machines have always supported access to the extended PCIe
configuration space. So on pyro(4) and vpci(4) return the size appropriate
for the extended PCIe configuration space.

ok miod@


# 1.38 04-Dec-2010 miod

Introduce a new pci routine, pci_conf_size(), which returns the size of a
given pcitag_t configuration address space. Currently, all pci controllers
will return the usual 0x100 bytes of PCI configuration space, but this will
eventually change on PCIe-capable controlers.
ok kettenis@


# 1.37 01-Dec-2010 damien

Add definition for "Extended Synch" bit in PCIe Link Control register.
From PCI Express(R) Base Specification Rev 2.0.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 28-May-2009 damien

Add "Interrupt Disable" bit definition for the PCI Configuration Space
Command register. From PCI Express Base Specification Rev 2.0.
Use same naming as NetBSD.
Needed for wpi(4) and iwn(4).


Revision tags: OPENBSD_4_5_BASE
# 1.35 25-Nov-2008 damien

move some generic PCIe register flags used in wpi(4) and iwn(4)
into common pcireg.h

ok deraadt@, kettenis@, dlg@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 26-Nov-2007 jsg

Add PCI VPD read/write functions from NetBSD required for some things
dlg is playing with.

'put it in' dlg@


# 1.33 25-Nov-2007 kettenis

First step towards PCI Express/ExpressCard hotplug. Unplug should work on
detachable drivers.

"put it in" deraadt@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 31-Jul-2006 mickey

puc@cardbus (only added (commented out) to whom has puc@pci enabled)
tested on puc@pci by fkr and meself on the cardbus.
still needs a bit more work but generally works.
deraadt@ ok and some input from miod@


# 1.31 01-Jun-2006 brad

add 2 subclasses, subclass storage SAS and subclass system SD Host Controller.

From NetBSD


# 1.30 28-May-2006 uwe

Support for standard SD host controllers like the Ricoh 5C822, a small
generic bus layer, and SCSI emulation for SD/MMC memory cards.


# 1.29 11-May-2006 brad

add PCI multimedia subclass type of HD audio.


Revision tags: OPENBSD_3_9_BASE
# 1.28 31-Dec-2005 dlg

add macros for the expansion ROM base address register

ok brad@ grange@ fgsch@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.27 16-Nov-2004 brad

add PCI_ID_CODE

From NetBSD


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 06-Dec-2003 grange

Mark u_int64_t constants with ULL to make gcc3 happy.
ok drahn@


# 1.25 16-Nov-2003 avsm

convert __attribute__((__packed__)) to __packed so that parsers unaware
of gcc extensions have more of a chance.
ok mcbride@, no objections from millert@, deraadt@


# 1.24 06-Oct-2003 fgsch

power management status reg. definition; from netbsd.
ok deraadt@ henning@ krw@.


Revision tags: OPENBSD_3_4_BASE
# 1.23 27-Aug-2003 mickey

this bit is defined as prefetchable and not cachable and thus rename and use appropriately


Revision tags: UBC_SYNC_A
# 1.22 02-Apr-2003 grange

PCI_CAP_MBI should really be PCI_CAP_MSI
ok jason@


# 1.21 01-Apr-2003 grange

Add a couple of new pci subclasses and caps from NetBSD
ok jason@


Revision tags: OPENBSD_3_3_BASE
# 1.20 08-Feb-2003 jason

definitions and structures for vital product data (VPD); from netbsd


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 13-Jul-2002 mickey

define PCI_COMMAND_STATUS_BITS for printfs, according to the enlisted defines


Revision tags: OPENBSD_3_1_BASE
# 1.18 06-Apr-2002 jason

s/REESSERVED/RESERVED/


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.17 08-May-2001 mickey

branches: 1.17.4;
more class/subclass/caps ids; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.16 09-Feb-2001 aaron

Add PCI Power Management Control Register definitions; from NetBSD.


# 1.15 08-Nov-2000 art

Defines for min_gnt and max_lat fields in the bhlc reg.
Not used yet.


Revision tags: OPENBSD_2_8_BASE
# 1.14 20-Sep-2000 niklas

support 64bit BARs from NetBSD


# 1.13 02-Aug-2000 mickey

import a few useful consts from netbsd; mainly for pcibios thing slip


Revision tags: OPENBSD_2_7_BASE SMP_BASE kame_19991208
# 1.12 26-Oct-1999 downsj

branches: 1.12.2;
Missed earlier: add PCI_HDRTYPE_TYPE macro, from NetBSD.


Revision tags: OPENBSD_2_6_BASE
# 1.11 18-Jul-1999 csapuntz

Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.10 30-Jan-1999 niklas

A slew of manifest constants for pci configuration registers gotten from freebsd


Revision tags: OPENBSD_2_4_BASE
# 1.9 12-Jul-1998 deraadt

fix bhlcr shift values; fgsch@olimpo.com.br


# 1.8 25-Apr-1998 deraadt

UDF and 66MHz support; zubin@clouseau.arl.wustl.edu


Revision tags: OPENBSD_2_3_BASE
# 1.7 03-Feb-1998 deraadt

more pci subclasses and such; netbsd


# 1.6 03-Feb-1998 deraadt

more bridge types


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.5 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.4 31-Oct-1996 millert

Add ATM defines. From Jim Rees <rees@umich.edu>


Revision tags: OPENBSD_2_0_BASE
# 1.3 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.2 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.60 31-Dec-2021 jsg

Interrups -> Interrupts


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.59 02-Nov-2019 kettenis

Add a few more PCIe capability registers and bits. As usual, the names
are taken from Intel chipset documentation. Prompted by a diff from kurt@.

ok kurt@


# 1.58 28-Oct-2019 stsp

Have iwm(4) configure the PCIe LTR.

Patch by Imre Vadasz.
Cross-check and pcireg.h tweak by kettenis@
ok patrick@


Revision tags: OPENBSD_6_6_BASE
# 1.57 30-May-2019 kettenis

Fix definitions of PCI_MSIX_MAU32 and add a define for the MSI-X function
mask bit.

ok mlarkin@, jmatthew@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.56 03-Aug-2018 kettenis

Let ahci(4) match on _CLS instead of _HID when attaching at acpi(4). Avoids
having to add many more _HID entries to the match table.

ok deraadt@, mlarkin@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.55 09-Aug-2017 mlarkin

vmd: allow guest PCI interrupt line reassignment.

I also added a couple config space register names to pcireg.h to try and
reduce the use of magic numbers in vmd/pci.c

ok pd@


# 1.54 12-Jun-2017 kevlo

From FreeBSD (r227593, r307982):
More and more RealTek controllers started to implement EEE feature.
Vendor driver seems to load a kind of firmware for EEE with
additional PHY fixups. It is known that the EEE feature may need
ASPM support. Unfortunately there is no documentation for EEE of
the controller so enabling ASPM may cause more problems.

The Realtek vendor drivers for FreeBSD and Linux also disable ASPM and
clock request. While here, add a define for the ECPM (Enable Clock Power
Management) bit.

Tested by stsp@ and myself.
ok stsp@


Revision tags: OPENBSD_6_1_BASE
# 1.53 25-Mar-2017 mlarkin

More PCI extended capabilities handling in pcidump.

From Simon Mages

ok deraadt@


# 1.52 22-Mar-2017 jsg

Add some more PCI classes and subclasses. Checked against EDK2 as
"PCI Code and ID Assignment Specification" is only available for those
willing to pay thousands of dollars for PDFs.

Prompted by a dmesg from an AMD Zen system which uses class 0x13
(Non-Essential Instrumentation) and System subclass 0x06 (IOMMU). There
is currently no public documentation for AMD family 17h to reference to
see if this is sane.

ok kettenis@ on an earlier version


# 1.51 16-Mar-2017 deraadt

Print PCIe Extended Capabilities, from Simon Mages
ok kettenis mlarkin


Revision tags: OPENBSD_6_0_BASE
# 1.50 02-Jun-2016 kettenis

Fix two issues in the MSI-X code. First, actually read the MSI-X capability
register. Second, correctly decode the table sizefromits contents.

First issue pointed out by David Hill (with the help of clang). Second
issue spotted after seeing a diff from Christiano Hasbaert.


# 1.49 04-May-2016 kettenis

Initial support for MSI-X. Only supported on amd64 for now. I have diffs to
actually use this in em(4) and xhci(4), but I'm not committing those yet
because we almost certainly need to save and restore the MSI-X registers
during suspend/resume. However, this allows mpi@ to play with multiple-vector
support in networking hardware.

Requested by mpi@
ok mlarkin@, mikeb@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.48 02-Jun-2015 mpi

Add missing define for hpb(4).


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.47 27-Apr-2014 stsp

Add PME_STATUS and PME_EN bitmasks for the PCI PMCSR register.
ok kettenis@


# 1.46 09-Apr-2014 dlg

apparently NVM is a type of mass storage now


Revision tags: OPENBSD_5_5_BASE
# 1.45 26-Aug-2013 jsg

add a define for the link capabilities register for
version 2 of the PCIe capability.


Revision tags: OPENBSD_5_4_BASE
# 1.44 03-Jun-2013 mikeb

Define some more DCSR/DCTL bits; ok kettenis


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.43 13-May-2012 kettenis

Add define for capability 0x12 (SATA).


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.42 19-Jun-2011 kettenis

Fix typo in the "fixed" HyperTransport MSI Mapping Capability address.


# 1.41 30-May-2011 kettenis

Enable MSI for HyperTransport devices that have MSI remapping enabled.


# 1.40 14-May-2011 kettenis

Add register definitions for PCI MSI capaility.

ok oga@, miod@, marco@, dlg@, krw@


Revision tags: OPENBSD_4_9_BASE
# 1.39 05-Dec-2010 kettenis

PCIe based sparc64 machines have always supported access to the extended PCIe
configuration space. So on pyro(4) and vpci(4) return the size appropriate
for the extended PCIe configuration space.

ok miod@


# 1.38 04-Dec-2010 miod

Introduce a new pci routine, pci_conf_size(), which returns the size of a
given pcitag_t configuration address space. Currently, all pci controllers
will return the usual 0x100 bytes of PCI configuration space, but this will
eventually change on PCIe-capable controlers.
ok kettenis@


# 1.37 01-Dec-2010 damien

Add definition for "Extended Synch" bit in PCIe Link Control register.
From PCI Express(R) Base Specification Rev 2.0.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 28-May-2009 damien

Add "Interrupt Disable" bit definition for the PCI Configuration Space
Command register. From PCI Express Base Specification Rev 2.0.
Use same naming as NetBSD.
Needed for wpi(4) and iwn(4).


Revision tags: OPENBSD_4_5_BASE
# 1.35 25-Nov-2008 damien

move some generic PCIe register flags used in wpi(4) and iwn(4)
into common pcireg.h

ok deraadt@, kettenis@, dlg@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 26-Nov-2007 jsg

Add PCI VPD read/write functions from NetBSD required for some things
dlg is playing with.

'put it in' dlg@


# 1.33 25-Nov-2007 kettenis

First step towards PCI Express/ExpressCard hotplug. Unplug should work on
detachable drivers.

"put it in" deraadt@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 31-Jul-2006 mickey

puc@cardbus (only added (commented out) to whom has puc@pci enabled)
tested on puc@pci by fkr and meself on the cardbus.
still needs a bit more work but generally works.
deraadt@ ok and some input from miod@


# 1.31 01-Jun-2006 brad

add 2 subclasses, subclass storage SAS and subclass system SD Host Controller.

From NetBSD


# 1.30 28-May-2006 uwe

Support for standard SD host controllers like the Ricoh 5C822, a small
generic bus layer, and SCSI emulation for SD/MMC memory cards.


# 1.29 11-May-2006 brad

add PCI multimedia subclass type of HD audio.


Revision tags: OPENBSD_3_9_BASE
# 1.28 31-Dec-2005 dlg

add macros for the expansion ROM base address register

ok brad@ grange@ fgsch@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.27 16-Nov-2004 brad

add PCI_ID_CODE

From NetBSD


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 06-Dec-2003 grange

Mark u_int64_t constants with ULL to make gcc3 happy.
ok drahn@


# 1.25 16-Nov-2003 avsm

convert __attribute__((__packed__)) to __packed so that parsers unaware
of gcc extensions have more of a chance.
ok mcbride@, no objections from millert@, deraadt@


# 1.24 06-Oct-2003 fgsch

power management status reg. definition; from netbsd.
ok deraadt@ henning@ krw@.


Revision tags: OPENBSD_3_4_BASE
# 1.23 27-Aug-2003 mickey

this bit is defined as prefetchable and not cachable and thus rename and use appropriately


Revision tags: UBC_SYNC_A
# 1.22 02-Apr-2003 grange

PCI_CAP_MBI should really be PCI_CAP_MSI
ok jason@


# 1.21 01-Apr-2003 grange

Add a couple of new pci subclasses and caps from NetBSD
ok jason@


Revision tags: OPENBSD_3_3_BASE
# 1.20 08-Feb-2003 jason

definitions and structures for vital product data (VPD); from netbsd


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 13-Jul-2002 mickey

define PCI_COMMAND_STATUS_BITS for printfs, according to the enlisted defines


Revision tags: OPENBSD_3_1_BASE
# 1.18 06-Apr-2002 jason

s/REESSERVED/RESERVED/


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.17 08-May-2001 mickey

branches: 1.17.4;
more class/subclass/caps ids; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.16 09-Feb-2001 aaron

Add PCI Power Management Control Register definitions; from NetBSD.


# 1.15 08-Nov-2000 art

Defines for min_gnt and max_lat fields in the bhlc reg.
Not used yet.


Revision tags: OPENBSD_2_8_BASE
# 1.14 20-Sep-2000 niklas

support 64bit BARs from NetBSD


# 1.13 02-Aug-2000 mickey

import a few useful consts from netbsd; mainly for pcibios thing slip


Revision tags: OPENBSD_2_7_BASE SMP_BASE kame_19991208
# 1.12 26-Oct-1999 downsj

branches: 1.12.2;
Missed earlier: add PCI_HDRTYPE_TYPE macro, from NetBSD.


Revision tags: OPENBSD_2_6_BASE
# 1.11 18-Jul-1999 csapuntz

Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.10 30-Jan-1999 niklas

A slew of manifest constants for pci configuration registers gotten from freebsd


Revision tags: OPENBSD_2_4_BASE
# 1.9 12-Jul-1998 deraadt

fix bhlcr shift values; fgsch@olimpo.com.br


# 1.8 25-Apr-1998 deraadt

UDF and 66MHz support; zubin@clouseau.arl.wustl.edu


Revision tags: OPENBSD_2_3_BASE
# 1.7 03-Feb-1998 deraadt

more pci subclasses and such; netbsd


# 1.6 03-Feb-1998 deraadt

more bridge types


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.5 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.4 31-Oct-1996 millert

Add ATM defines. From Jim Rees <rees@umich.edu>


Revision tags: OPENBSD_2_0_BASE
# 1.3 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.2 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.59 02-Nov-2019 kettenis

Add a few more PCIe capability registers and bits. As usual, the names
are taken from Intel chipset documentation. Prompted by a diff from kurt@.

ok kurt@


# 1.58 28-Oct-2019 stsp

Have iwm(4) configure the PCIe LTR.

Patch by Imre Vadasz.
Cross-check and pcireg.h tweak by kettenis@
ok patrick@


Revision tags: OPENBSD_6_6_BASE
# 1.57 30-May-2019 kettenis

Fix definitions of PCI_MSIX_MAU32 and add a define for the MSI-X function
mask bit.

ok mlarkin@, jmatthew@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.56 03-Aug-2018 kettenis

Let ahci(4) match on _CLS instead of _HID when attaching at acpi(4). Avoids
having to add many more _HID entries to the match table.

ok deraadt@, mlarkin@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.55 09-Aug-2017 mlarkin

vmd: allow guest PCI interrupt line reassignment.

I also added a couple config space register names to pcireg.h to try and
reduce the use of magic numbers in vmd/pci.c

ok pd@


# 1.54 12-Jun-2017 kevlo

From FreeBSD (r227593, r307982):
More and more RealTek controllers started to implement EEE feature.
Vendor driver seems to load a kind of firmware for EEE with
additional PHY fixups. It is known that the EEE feature may need
ASPM support. Unfortunately there is no documentation for EEE of
the controller so enabling ASPM may cause more problems.

The Realtek vendor drivers for FreeBSD and Linux also disable ASPM and
clock request. While here, add a define for the ECPM (Enable Clock Power
Management) bit.

Tested by stsp@ and myself.
ok stsp@


Revision tags: OPENBSD_6_1_BASE
# 1.53 25-Mar-2017 mlarkin

More PCI extended capabilities handling in pcidump.

From Simon Mages

ok deraadt@


# 1.52 22-Mar-2017 jsg

Add some more PCI classes and subclasses. Checked against EDK2 as
"PCI Code and ID Assignment Specification" is only available for those
willing to pay thousands of dollars for PDFs.

Prompted by a dmesg from an AMD Zen system which uses class 0x13
(Non-Essential Instrumentation) and System subclass 0x06 (IOMMU). There
is currently no public documentation for AMD family 17h to reference to
see if this is sane.

ok kettenis@ on an earlier version


# 1.51 16-Mar-2017 deraadt

Print PCIe Extended Capabilities, from Simon Mages
ok kettenis mlarkin


Revision tags: OPENBSD_6_0_BASE
# 1.50 02-Jun-2016 kettenis

Fix two issues in the MSI-X code. First, actually read the MSI-X capability
register. Second, correctly decode the table sizefromits contents.

First issue pointed out by David Hill (with the help of clang). Second
issue spotted after seeing a diff from Christiano Hasbaert.


# 1.49 04-May-2016 kettenis

Initial support for MSI-X. Only supported on amd64 for now. I have diffs to
actually use this in em(4) and xhci(4), but I'm not committing those yet
because we almost certainly need to save and restore the MSI-X registers
during suspend/resume. However, this allows mpi@ to play with multiple-vector
support in networking hardware.

Requested by mpi@
ok mlarkin@, mikeb@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.48 02-Jun-2015 mpi

Add missing define for hpb(4).


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.47 27-Apr-2014 stsp

Add PME_STATUS and PME_EN bitmasks for the PCI PMCSR register.
ok kettenis@


# 1.46 09-Apr-2014 dlg

apparently NVM is a type of mass storage now


Revision tags: OPENBSD_5_5_BASE
# 1.45 26-Aug-2013 jsg

add a define for the link capabilities register for
version 2 of the PCIe capability.


Revision tags: OPENBSD_5_4_BASE
# 1.44 03-Jun-2013 mikeb

Define some more DCSR/DCTL bits; ok kettenis


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.43 13-May-2012 kettenis

Add define for capability 0x12 (SATA).


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.42 19-Jun-2011 kettenis

Fix typo in the "fixed" HyperTransport MSI Mapping Capability address.


# 1.41 30-May-2011 kettenis

Enable MSI for HyperTransport devices that have MSI remapping enabled.


# 1.40 14-May-2011 kettenis

Add register definitions for PCI MSI capaility.

ok oga@, miod@, marco@, dlg@, krw@


Revision tags: OPENBSD_4_9_BASE
# 1.39 05-Dec-2010 kettenis

PCIe based sparc64 machines have always supported access to the extended PCIe
configuration space. So on pyro(4) and vpci(4) return the size appropriate
for the extended PCIe configuration space.

ok miod@


# 1.38 04-Dec-2010 miod

Introduce a new pci routine, pci_conf_size(), which returns the size of a
given pcitag_t configuration address space. Currently, all pci controllers
will return the usual 0x100 bytes of PCI configuration space, but this will
eventually change on PCIe-capable controlers.
ok kettenis@


# 1.37 01-Dec-2010 damien

Add definition for "Extended Synch" bit in PCIe Link Control register.
From PCI Express(R) Base Specification Rev 2.0.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 28-May-2009 damien

Add "Interrupt Disable" bit definition for the PCI Configuration Space
Command register. From PCI Express Base Specification Rev 2.0.
Use same naming as NetBSD.
Needed for wpi(4) and iwn(4).


Revision tags: OPENBSD_4_5_BASE
# 1.35 25-Nov-2008 damien

move some generic PCIe register flags used in wpi(4) and iwn(4)
into common pcireg.h

ok deraadt@, kettenis@, dlg@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 26-Nov-2007 jsg

Add PCI VPD read/write functions from NetBSD required for some things
dlg is playing with.

'put it in' dlg@


# 1.33 25-Nov-2007 kettenis

First step towards PCI Express/ExpressCard hotplug. Unplug should work on
detachable drivers.

"put it in" deraadt@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 31-Jul-2006 mickey

puc@cardbus (only added (commented out) to whom has puc@pci enabled)
tested on puc@pci by fkr and meself on the cardbus.
still needs a bit more work but generally works.
deraadt@ ok and some input from miod@


# 1.31 01-Jun-2006 brad

add 2 subclasses, subclass storage SAS and subclass system SD Host Controller.

From NetBSD


# 1.30 28-May-2006 uwe

Support for standard SD host controllers like the Ricoh 5C822, a small
generic bus layer, and SCSI emulation for SD/MMC memory cards.


# 1.29 11-May-2006 brad

add PCI multimedia subclass type of HD audio.


Revision tags: OPENBSD_3_9_BASE
# 1.28 31-Dec-2005 dlg

add macros for the expansion ROM base address register

ok brad@ grange@ fgsch@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.27 16-Nov-2004 brad

add PCI_ID_CODE

From NetBSD


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 06-Dec-2003 grange

Mark u_int64_t constants with ULL to make gcc3 happy.
ok drahn@


# 1.25 16-Nov-2003 avsm

convert __attribute__((__packed__)) to __packed so that parsers unaware
of gcc extensions have more of a chance.
ok mcbride@, no objections from millert@, deraadt@


# 1.24 06-Oct-2003 fgsch

power management status reg. definition; from netbsd.
ok deraadt@ henning@ krw@.


Revision tags: OPENBSD_3_4_BASE
# 1.23 27-Aug-2003 mickey

this bit is defined as prefetchable and not cachable and thus rename and use appropriately


Revision tags: UBC_SYNC_A
# 1.22 02-Apr-2003 grange

PCI_CAP_MBI should really be PCI_CAP_MSI
ok jason@


# 1.21 01-Apr-2003 grange

Add a couple of new pci subclasses and caps from NetBSD
ok jason@


Revision tags: OPENBSD_3_3_BASE
# 1.20 08-Feb-2003 jason

definitions and structures for vital product data (VPD); from netbsd


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 13-Jul-2002 mickey

define PCI_COMMAND_STATUS_BITS for printfs, according to the enlisted defines


Revision tags: OPENBSD_3_1_BASE
# 1.18 06-Apr-2002 jason

s/REESSERVED/RESERVED/


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.17 08-May-2001 mickey

branches: 1.17.4;
more class/subclass/caps ids; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.16 09-Feb-2001 aaron

Add PCI Power Management Control Register definitions; from NetBSD.


# 1.15 08-Nov-2000 art

Defines for min_gnt and max_lat fields in the bhlc reg.
Not used yet.


Revision tags: OPENBSD_2_8_BASE
# 1.14 20-Sep-2000 niklas

support 64bit BARs from NetBSD


# 1.13 02-Aug-2000 mickey

import a few useful consts from netbsd; mainly for pcibios thing slip


Revision tags: OPENBSD_2_7_BASE SMP_BASE kame_19991208
# 1.12 26-Oct-1999 downsj

branches: 1.12.2;
Missed earlier: add PCI_HDRTYPE_TYPE macro, from NetBSD.


Revision tags: OPENBSD_2_6_BASE
# 1.11 18-Jul-1999 csapuntz

Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.10 30-Jan-1999 niklas

A slew of manifest constants for pci configuration registers gotten from freebsd


Revision tags: OPENBSD_2_4_BASE
# 1.9 12-Jul-1998 deraadt

fix bhlcr shift values; fgsch@olimpo.com.br


# 1.8 25-Apr-1998 deraadt

UDF and 66MHz support; zubin@clouseau.arl.wustl.edu


Revision tags: OPENBSD_2_3_BASE
# 1.7 03-Feb-1998 deraadt

more pci subclasses and such; netbsd


# 1.6 03-Feb-1998 deraadt

more bridge types


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.5 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.4 31-Oct-1996 millert

Add ATM defines. From Jim Rees <rees@umich.edu>


Revision tags: OPENBSD_2_0_BASE
# 1.3 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.2 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.58 28-Oct-2019 stsp

Have iwm(4) configure the PCIe LTR.

Patch by Imre Vadasz.
Cross-check and pcireg.h tweak by kettenis@
ok patrick@


Revision tags: OPENBSD_6_6_BASE
# 1.57 30-May-2019 kettenis

Fix definitions of PCI_MSIX_MAU32 and add a define for the MSI-X function
mask bit.

ok mlarkin@, jmatthew@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.56 03-Aug-2018 kettenis

Let ahci(4) match on _CLS instead of _HID when attaching at acpi(4). Avoids
having to add many more _HID entries to the match table.

ok deraadt@, mlarkin@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.55 09-Aug-2017 mlarkin

vmd: allow guest PCI interrupt line reassignment.

I also added a couple config space register names to pcireg.h to try and
reduce the use of magic numbers in vmd/pci.c

ok pd@


# 1.54 12-Jun-2017 kevlo

From FreeBSD (r227593, r307982):
More and more RealTek controllers started to implement EEE feature.
Vendor driver seems to load a kind of firmware for EEE with
additional PHY fixups. It is known that the EEE feature may need
ASPM support. Unfortunately there is no documentation for EEE of
the controller so enabling ASPM may cause more problems.

The Realtek vendor drivers for FreeBSD and Linux also disable ASPM and
clock request. While here, add a define for the ECPM (Enable Clock Power
Management) bit.

Tested by stsp@ and myself.
ok stsp@


Revision tags: OPENBSD_6_1_BASE
# 1.53 25-Mar-2017 mlarkin

More PCI extended capabilities handling in pcidump.

From Simon Mages

ok deraadt@


# 1.52 22-Mar-2017 jsg

Add some more PCI classes and subclasses. Checked against EDK2 as
"PCI Code and ID Assignment Specification" is only available for those
willing to pay thousands of dollars for PDFs.

Prompted by a dmesg from an AMD Zen system which uses class 0x13
(Non-Essential Instrumentation) and System subclass 0x06 (IOMMU). There
is currently no public documentation for AMD family 17h to reference to
see if this is sane.

ok kettenis@ on an earlier version


# 1.51 16-Mar-2017 deraadt

Print PCIe Extended Capabilities, from Simon Mages
ok kettenis mlarkin


Revision tags: OPENBSD_6_0_BASE
# 1.50 02-Jun-2016 kettenis

Fix two issues in the MSI-X code. First, actually read the MSI-X capability
register. Second, correctly decode the table sizefromits contents.

First issue pointed out by David Hill (with the help of clang). Second
issue spotted after seeing a diff from Christiano Hasbaert.


# 1.49 04-May-2016 kettenis

Initial support for MSI-X. Only supported on amd64 for now. I have diffs to
actually use this in em(4) and xhci(4), but I'm not committing those yet
because we almost certainly need to save and restore the MSI-X registers
during suspend/resume. However, this allows mpi@ to play with multiple-vector
support in networking hardware.

Requested by mpi@
ok mlarkin@, mikeb@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.48 02-Jun-2015 mpi

Add missing define for hpb(4).


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.47 27-Apr-2014 stsp

Add PME_STATUS and PME_EN bitmasks for the PCI PMCSR register.
ok kettenis@


# 1.46 09-Apr-2014 dlg

apparently NVM is a type of mass storage now


Revision tags: OPENBSD_5_5_BASE
# 1.45 26-Aug-2013 jsg

add a define for the link capabilities register for
version 2 of the PCIe capability.


Revision tags: OPENBSD_5_4_BASE
# 1.44 03-Jun-2013 mikeb

Define some more DCSR/DCTL bits; ok kettenis


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.43 13-May-2012 kettenis

Add define for capability 0x12 (SATA).


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.42 19-Jun-2011 kettenis

Fix typo in the "fixed" HyperTransport MSI Mapping Capability address.


# 1.41 30-May-2011 kettenis

Enable MSI for HyperTransport devices that have MSI remapping enabled.


# 1.40 14-May-2011 kettenis

Add register definitions for PCI MSI capaility.

ok oga@, miod@, marco@, dlg@, krw@


Revision tags: OPENBSD_4_9_BASE
# 1.39 05-Dec-2010 kettenis

PCIe based sparc64 machines have always supported access to the extended PCIe
configuration space. So on pyro(4) and vpci(4) return the size appropriate
for the extended PCIe configuration space.

ok miod@


# 1.38 04-Dec-2010 miod

Introduce a new pci routine, pci_conf_size(), which returns the size of a
given pcitag_t configuration address space. Currently, all pci controllers
will return the usual 0x100 bytes of PCI configuration space, but this will
eventually change on PCIe-capable controlers.
ok kettenis@


# 1.37 01-Dec-2010 damien

Add definition for "Extended Synch" bit in PCIe Link Control register.
From PCI Express(R) Base Specification Rev 2.0.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 28-May-2009 damien

Add "Interrupt Disable" bit definition for the PCI Configuration Space
Command register. From PCI Express Base Specification Rev 2.0.
Use same naming as NetBSD.
Needed for wpi(4) and iwn(4).


Revision tags: OPENBSD_4_5_BASE
# 1.35 25-Nov-2008 damien

move some generic PCIe register flags used in wpi(4) and iwn(4)
into common pcireg.h

ok deraadt@, kettenis@, dlg@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 26-Nov-2007 jsg

Add PCI VPD read/write functions from NetBSD required for some things
dlg is playing with.

'put it in' dlg@


# 1.33 25-Nov-2007 kettenis

First step towards PCI Express/ExpressCard hotplug. Unplug should work on
detachable drivers.

"put it in" deraadt@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 31-Jul-2006 mickey

puc@cardbus (only added (commented out) to whom has puc@pci enabled)
tested on puc@pci by fkr and meself on the cardbus.
still needs a bit more work but generally works.
deraadt@ ok and some input from miod@


# 1.31 01-Jun-2006 brad

add 2 subclasses, subclass storage SAS and subclass system SD Host Controller.

From NetBSD


# 1.30 28-May-2006 uwe

Support for standard SD host controllers like the Ricoh 5C822, a small
generic bus layer, and SCSI emulation for SD/MMC memory cards.


# 1.29 11-May-2006 brad

add PCI multimedia subclass type of HD audio.


Revision tags: OPENBSD_3_9_BASE
# 1.28 31-Dec-2005 dlg

add macros for the expansion ROM base address register

ok brad@ grange@ fgsch@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.27 16-Nov-2004 brad

add PCI_ID_CODE

From NetBSD


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 06-Dec-2003 grange

Mark u_int64_t constants with ULL to make gcc3 happy.
ok drahn@


# 1.25 16-Nov-2003 avsm

convert __attribute__((__packed__)) to __packed so that parsers unaware
of gcc extensions have more of a chance.
ok mcbride@, no objections from millert@, deraadt@


# 1.24 06-Oct-2003 fgsch

power management status reg. definition; from netbsd.
ok deraadt@ henning@ krw@.


Revision tags: OPENBSD_3_4_BASE
# 1.23 27-Aug-2003 mickey

this bit is defined as prefetchable and not cachable and thus rename and use appropriately


Revision tags: UBC_SYNC_A
# 1.22 02-Apr-2003 grange

PCI_CAP_MBI should really be PCI_CAP_MSI
ok jason@


# 1.21 01-Apr-2003 grange

Add a couple of new pci subclasses and caps from NetBSD
ok jason@


Revision tags: OPENBSD_3_3_BASE
# 1.20 08-Feb-2003 jason

definitions and structures for vital product data (VPD); from netbsd


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 13-Jul-2002 mickey

define PCI_COMMAND_STATUS_BITS for printfs, according to the enlisted defines


Revision tags: OPENBSD_3_1_BASE
# 1.18 06-Apr-2002 jason

s/REESSERVED/RESERVED/


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.17 08-May-2001 mickey

branches: 1.17.4;
more class/subclass/caps ids; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.16 09-Feb-2001 aaron

Add PCI Power Management Control Register definitions; from NetBSD.


# 1.15 08-Nov-2000 art

Defines for min_gnt and max_lat fields in the bhlc reg.
Not used yet.


Revision tags: OPENBSD_2_8_BASE
# 1.14 20-Sep-2000 niklas

support 64bit BARs from NetBSD


# 1.13 02-Aug-2000 mickey

import a few useful consts from netbsd; mainly for pcibios thing slip


Revision tags: OPENBSD_2_7_BASE SMP_BASE kame_19991208
# 1.12 26-Oct-1999 downsj

branches: 1.12.2;
Missed earlier: add PCI_HDRTYPE_TYPE macro, from NetBSD.


Revision tags: OPENBSD_2_6_BASE
# 1.11 18-Jul-1999 csapuntz

Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.10 30-Jan-1999 niklas

A slew of manifest constants for pci configuration registers gotten from freebsd


Revision tags: OPENBSD_2_4_BASE
# 1.9 12-Jul-1998 deraadt

fix bhlcr shift values; fgsch@olimpo.com.br


# 1.8 25-Apr-1998 deraadt

UDF and 66MHz support; zubin@clouseau.arl.wustl.edu


Revision tags: OPENBSD_2_3_BASE
# 1.7 03-Feb-1998 deraadt

more pci subclasses and such; netbsd


# 1.6 03-Feb-1998 deraadt

more bridge types


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.5 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.4 31-Oct-1996 millert

Add ATM defines. From Jim Rees <rees@umich.edu>


Revision tags: OPENBSD_2_0_BASE
# 1.3 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.2 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.57 30-May-2019 kettenis

Fix definitions of PCI_MSIX_MAU32 and add a define for the MSI-X function
mask bit.

ok mlarkin@, jmatthew@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.56 03-Aug-2018 kettenis

Let ahci(4) match on _CLS instead of _HID when attaching at acpi(4). Avoids
having to add many more _HID entries to the match table.

ok deraadt@, mlarkin@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.55 09-Aug-2017 mlarkin

vmd: allow guest PCI interrupt line reassignment.

I also added a couple config space register names to pcireg.h to try and
reduce the use of magic numbers in vmd/pci.c

ok pd@


# 1.54 12-Jun-2017 kevlo

From FreeBSD (r227593, r307982):
More and more RealTek controllers started to implement EEE feature.
Vendor driver seems to load a kind of firmware for EEE with
additional PHY fixups. It is known that the EEE feature may need
ASPM support. Unfortunately there is no documentation for EEE of
the controller so enabling ASPM may cause more problems.

The Realtek vendor drivers for FreeBSD and Linux also disable ASPM and
clock request. While here, add a define for the ECPM (Enable Clock Power
Management) bit.

Tested by stsp@ and myself.
ok stsp@


Revision tags: OPENBSD_6_1_BASE
# 1.53 25-Mar-2017 mlarkin

More PCI extended capabilities handling in pcidump.

From Simon Mages

ok deraadt@


# 1.52 22-Mar-2017 jsg

Add some more PCI classes and subclasses. Checked against EDK2 as
"PCI Code and ID Assignment Specification" is only available for those
willing to pay thousands of dollars for PDFs.

Prompted by a dmesg from an AMD Zen system which uses class 0x13
(Non-Essential Instrumentation) and System subclass 0x06 (IOMMU). There
is currently no public documentation for AMD family 17h to reference to
see if this is sane.

ok kettenis@ on an earlier version


# 1.51 16-Mar-2017 deraadt

Print PCIe Extended Capabilities, from Simon Mages
ok kettenis mlarkin


Revision tags: OPENBSD_6_0_BASE
# 1.50 02-Jun-2016 kettenis

Fix two issues in the MSI-X code. First, actually read the MSI-X capability
register. Second, correctly decode the table sizefromits contents.

First issue pointed out by David Hill (with the help of clang). Second
issue spotted after seeing a diff from Christiano Hasbaert.


# 1.49 04-May-2016 kettenis

Initial support for MSI-X. Only supported on amd64 for now. I have diffs to
actually use this in em(4) and xhci(4), but I'm not committing those yet
because we almost certainly need to save and restore the MSI-X registers
during suspend/resume. However, this allows mpi@ to play with multiple-vector
support in networking hardware.

Requested by mpi@
ok mlarkin@, mikeb@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.48 02-Jun-2015 mpi

Add missing define for hpb(4).


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.47 27-Apr-2014 stsp

Add PME_STATUS and PME_EN bitmasks for the PCI PMCSR register.
ok kettenis@


# 1.46 09-Apr-2014 dlg

apparently NVM is a type of mass storage now


Revision tags: OPENBSD_5_5_BASE
# 1.45 26-Aug-2013 jsg

add a define for the link capabilities register for
version 2 of the PCIe capability.


Revision tags: OPENBSD_5_4_BASE
# 1.44 03-Jun-2013 mikeb

Define some more DCSR/DCTL bits; ok kettenis


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.43 13-May-2012 kettenis

Add define for capability 0x12 (SATA).


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.42 19-Jun-2011 kettenis

Fix typo in the "fixed" HyperTransport MSI Mapping Capability address.


# 1.41 30-May-2011 kettenis

Enable MSI for HyperTransport devices that have MSI remapping enabled.


# 1.40 14-May-2011 kettenis

Add register definitions for PCI MSI capaility.

ok oga@, miod@, marco@, dlg@, krw@


Revision tags: OPENBSD_4_9_BASE
# 1.39 05-Dec-2010 kettenis

PCIe based sparc64 machines have always supported access to the extended PCIe
configuration space. So on pyro(4) and vpci(4) return the size appropriate
for the extended PCIe configuration space.

ok miod@


# 1.38 04-Dec-2010 miod

Introduce a new pci routine, pci_conf_size(), which returns the size of a
given pcitag_t configuration address space. Currently, all pci controllers
will return the usual 0x100 bytes of PCI configuration space, but this will
eventually change on PCIe-capable controlers.
ok kettenis@


# 1.37 01-Dec-2010 damien

Add definition for "Extended Synch" bit in PCIe Link Control register.
From PCI Express(R) Base Specification Rev 2.0.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 28-May-2009 damien

Add "Interrupt Disable" bit definition for the PCI Configuration Space
Command register. From PCI Express Base Specification Rev 2.0.
Use same naming as NetBSD.
Needed for wpi(4) and iwn(4).


Revision tags: OPENBSD_4_5_BASE
# 1.35 25-Nov-2008 damien

move some generic PCIe register flags used in wpi(4) and iwn(4)
into common pcireg.h

ok deraadt@, kettenis@, dlg@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 26-Nov-2007 jsg

Add PCI VPD read/write functions from NetBSD required for some things
dlg is playing with.

'put it in' dlg@


# 1.33 25-Nov-2007 kettenis

First step towards PCI Express/ExpressCard hotplug. Unplug should work on
detachable drivers.

"put it in" deraadt@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 31-Jul-2006 mickey

puc@cardbus (only added (commented out) to whom has puc@pci enabled)
tested on puc@pci by fkr and meself on the cardbus.
still needs a bit more work but generally works.
deraadt@ ok and some input from miod@


# 1.31 01-Jun-2006 brad

add 2 subclasses, subclass storage SAS and subclass system SD Host Controller.

From NetBSD


# 1.30 28-May-2006 uwe

Support for standard SD host controllers like the Ricoh 5C822, a small
generic bus layer, and SCSI emulation for SD/MMC memory cards.


# 1.29 11-May-2006 brad

add PCI multimedia subclass type of HD audio.


Revision tags: OPENBSD_3_9_BASE
# 1.28 31-Dec-2005 dlg

add macros for the expansion ROM base address register

ok brad@ grange@ fgsch@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.27 16-Nov-2004 brad

add PCI_ID_CODE

From NetBSD


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 06-Dec-2003 grange

Mark u_int64_t constants with ULL to make gcc3 happy.
ok drahn@


# 1.25 16-Nov-2003 avsm

convert __attribute__((__packed__)) to __packed so that parsers unaware
of gcc extensions have more of a chance.
ok mcbride@, no objections from millert@, deraadt@


# 1.24 06-Oct-2003 fgsch

power management status reg. definition; from netbsd.
ok deraadt@ henning@ krw@.


Revision tags: OPENBSD_3_4_BASE
# 1.23 27-Aug-2003 mickey

this bit is defined as prefetchable and not cachable and thus rename and use appropriately


Revision tags: UBC_SYNC_A
# 1.22 02-Apr-2003 grange

PCI_CAP_MBI should really be PCI_CAP_MSI
ok jason@


# 1.21 01-Apr-2003 grange

Add a couple of new pci subclasses and caps from NetBSD
ok jason@


Revision tags: OPENBSD_3_3_BASE
# 1.20 08-Feb-2003 jason

definitions and structures for vital product data (VPD); from netbsd


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 13-Jul-2002 mickey

define PCI_COMMAND_STATUS_BITS for printfs, according to the enlisted defines


Revision tags: OPENBSD_3_1_BASE
# 1.18 06-Apr-2002 jason

s/REESSERVED/RESERVED/


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.17 08-May-2001 mickey

branches: 1.17.4;
more class/subclass/caps ids; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.16 09-Feb-2001 aaron

Add PCI Power Management Control Register definitions; from NetBSD.


# 1.15 08-Nov-2000 art

Defines for min_gnt and max_lat fields in the bhlc reg.
Not used yet.


Revision tags: OPENBSD_2_8_BASE
# 1.14 20-Sep-2000 niklas

support 64bit BARs from NetBSD


# 1.13 02-Aug-2000 mickey

import a few useful consts from netbsd; mainly for pcibios thing slip


Revision tags: OPENBSD_2_7_BASE SMP_BASE kame_19991208
# 1.12 26-Oct-1999 downsj

branches: 1.12.2;
Missed earlier: add PCI_HDRTYPE_TYPE macro, from NetBSD.


Revision tags: OPENBSD_2_6_BASE
# 1.11 18-Jul-1999 csapuntz

Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.10 30-Jan-1999 niklas

A slew of manifest constants for pci configuration registers gotten from freebsd


Revision tags: OPENBSD_2_4_BASE
# 1.9 12-Jul-1998 deraadt

fix bhlcr shift values; fgsch@olimpo.com.br


# 1.8 25-Apr-1998 deraadt

UDF and 66MHz support; zubin@clouseau.arl.wustl.edu


Revision tags: OPENBSD_2_3_BASE
# 1.7 03-Feb-1998 deraadt

more pci subclasses and such; netbsd


# 1.6 03-Feb-1998 deraadt

more bridge types


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.5 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.4 31-Oct-1996 millert

Add ATM defines. From Jim Rees <rees@umich.edu>


Revision tags: OPENBSD_2_0_BASE
# 1.3 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.2 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.56 03-Aug-2018 kettenis

Let ahci(4) match on _CLS instead of _HID when attaching at acpi(4). Avoids
having to add many more _HID entries to the match table.

ok deraadt@, mlarkin@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.55 09-Aug-2017 mlarkin

vmd: allow guest PCI interrupt line reassignment.

I also added a couple config space register names to pcireg.h to try and
reduce the use of magic numbers in vmd/pci.c

ok pd@


# 1.54 12-Jun-2017 kevlo

From FreeBSD (r227593, r307982):
More and more RealTek controllers started to implement EEE feature.
Vendor driver seems to load a kind of firmware for EEE with
additional PHY fixups. It is known that the EEE feature may need
ASPM support. Unfortunately there is no documentation for EEE of
the controller so enabling ASPM may cause more problems.

The Realtek vendor drivers for FreeBSD and Linux also disable ASPM and
clock request. While here, add a define for the ECPM (Enable Clock Power
Management) bit.

Tested by stsp@ and myself.
ok stsp@


Revision tags: OPENBSD_6_1_BASE
# 1.53 25-Mar-2017 mlarkin

More PCI extended capabilities handling in pcidump.

From Simon Mages

ok deraadt@


# 1.52 22-Mar-2017 jsg

Add some more PCI classes and subclasses. Checked against EDK2 as
"PCI Code and ID Assignment Specification" is only available for those
willing to pay thousands of dollars for PDFs.

Prompted by a dmesg from an AMD Zen system which uses class 0x13
(Non-Essential Instrumentation) and System subclass 0x06 (IOMMU). There
is currently no public documentation for AMD family 17h to reference to
see if this is sane.

ok kettenis@ on an earlier version


# 1.51 16-Mar-2017 deraadt

Print PCIe Extended Capabilities, from Simon Mages
ok kettenis mlarkin


Revision tags: OPENBSD_6_0_BASE
# 1.50 02-Jun-2016 kettenis

Fix two issues in the MSI-X code. First, actually read the MSI-X capability
register. Second, correctly decode the table sizefromits contents.

First issue pointed out by David Hill (with the help of clang). Second
issue spotted after seeing a diff from Christiano Hasbaert.


# 1.49 04-May-2016 kettenis

Initial support for MSI-X. Only supported on amd64 for now. I have diffs to
actually use this in em(4) and xhci(4), but I'm not committing those yet
because we almost certainly need to save and restore the MSI-X registers
during suspend/resume. However, this allows mpi@ to play with multiple-vector
support in networking hardware.

Requested by mpi@
ok mlarkin@, mikeb@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.48 02-Jun-2015 mpi

Add missing define for hpb(4).


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.47 27-Apr-2014 stsp

Add PME_STATUS and PME_EN bitmasks for the PCI PMCSR register.
ok kettenis@


# 1.46 09-Apr-2014 dlg

apparently NVM is a type of mass storage now


Revision tags: OPENBSD_5_5_BASE
# 1.45 26-Aug-2013 jsg

add a define for the link capabilities register for
version 2 of the PCIe capability.


Revision tags: OPENBSD_5_4_BASE
# 1.44 03-Jun-2013 mikeb

Define some more DCSR/DCTL bits; ok kettenis


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.43 13-May-2012 kettenis

Add define for capability 0x12 (SATA).


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.42 19-Jun-2011 kettenis

Fix typo in the "fixed" HyperTransport MSI Mapping Capability address.


# 1.41 30-May-2011 kettenis

Enable MSI for HyperTransport devices that have MSI remapping enabled.


# 1.40 14-May-2011 kettenis

Add register definitions for PCI MSI capaility.

ok oga@, miod@, marco@, dlg@, krw@


Revision tags: OPENBSD_4_9_BASE
# 1.39 05-Dec-2010 kettenis

PCIe based sparc64 machines have always supported access to the extended PCIe
configuration space. So on pyro(4) and vpci(4) return the size appropriate
for the extended PCIe configuration space.

ok miod@


# 1.38 04-Dec-2010 miod

Introduce a new pci routine, pci_conf_size(), which returns the size of a
given pcitag_t configuration address space. Currently, all pci controllers
will return the usual 0x100 bytes of PCI configuration space, but this will
eventually change on PCIe-capable controlers.
ok kettenis@


# 1.37 01-Dec-2010 damien

Add definition for "Extended Synch" bit in PCIe Link Control register.
From PCI Express(R) Base Specification Rev 2.0.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 28-May-2009 damien

Add "Interrupt Disable" bit definition for the PCI Configuration Space
Command register. From PCI Express Base Specification Rev 2.0.
Use same naming as NetBSD.
Needed for wpi(4) and iwn(4).


Revision tags: OPENBSD_4_5_BASE
# 1.35 25-Nov-2008 damien

move some generic PCIe register flags used in wpi(4) and iwn(4)
into common pcireg.h

ok deraadt@, kettenis@, dlg@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 26-Nov-2007 jsg

Add PCI VPD read/write functions from NetBSD required for some things
dlg is playing with.

'put it in' dlg@


# 1.33 25-Nov-2007 kettenis

First step towards PCI Express/ExpressCard hotplug. Unplug should work on
detachable drivers.

"put it in" deraadt@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 31-Jul-2006 mickey

puc@cardbus (only added (commented out) to whom has puc@pci enabled)
tested on puc@pci by fkr and meself on the cardbus.
still needs a bit more work but generally works.
deraadt@ ok and some input from miod@


# 1.31 01-Jun-2006 brad

add 2 subclasses, subclass storage SAS and subclass system SD Host Controller.

From NetBSD


# 1.30 28-May-2006 uwe

Support for standard SD host controllers like the Ricoh 5C822, a small
generic bus layer, and SCSI emulation for SD/MMC memory cards.


# 1.29 11-May-2006 brad

add PCI multimedia subclass type of HD audio.


Revision tags: OPENBSD_3_9_BASE
# 1.28 31-Dec-2005 dlg

add macros for the expansion ROM base address register

ok brad@ grange@ fgsch@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.27 16-Nov-2004 brad

add PCI_ID_CODE

From NetBSD


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 06-Dec-2003 grange

Mark u_int64_t constants with ULL to make gcc3 happy.
ok drahn@


# 1.25 16-Nov-2003 avsm

convert __attribute__((__packed__)) to __packed so that parsers unaware
of gcc extensions have more of a chance.
ok mcbride@, no objections from millert@, deraadt@


# 1.24 06-Oct-2003 fgsch

power management status reg. definition; from netbsd.
ok deraadt@ henning@ krw@.


Revision tags: OPENBSD_3_4_BASE
# 1.23 27-Aug-2003 mickey

this bit is defined as prefetchable and not cachable and thus rename and use appropriately


Revision tags: UBC_SYNC_A
# 1.22 02-Apr-2003 grange

PCI_CAP_MBI should really be PCI_CAP_MSI
ok jason@


# 1.21 01-Apr-2003 grange

Add a couple of new pci subclasses and caps from NetBSD
ok jason@


Revision tags: OPENBSD_3_3_BASE
# 1.20 08-Feb-2003 jason

definitions and structures for vital product data (VPD); from netbsd


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 13-Jul-2002 mickey

define PCI_COMMAND_STATUS_BITS for printfs, according to the enlisted defines


Revision tags: OPENBSD_3_1_BASE
# 1.18 06-Apr-2002 jason

s/REESSERVED/RESERVED/


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.17 08-May-2001 mickey

branches: 1.17.4;
more class/subclass/caps ids; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.16 09-Feb-2001 aaron

Add PCI Power Management Control Register definitions; from NetBSD.


# 1.15 08-Nov-2000 art

Defines for min_gnt and max_lat fields in the bhlc reg.
Not used yet.


Revision tags: OPENBSD_2_8_BASE
# 1.14 20-Sep-2000 niklas

support 64bit BARs from NetBSD


# 1.13 02-Aug-2000 mickey

import a few useful consts from netbsd; mainly for pcibios thing slip


Revision tags: OPENBSD_2_7_BASE SMP_BASE kame_19991208
# 1.12 26-Oct-1999 downsj

branches: 1.12.2;
Missed earlier: add PCI_HDRTYPE_TYPE macro, from NetBSD.


Revision tags: OPENBSD_2_6_BASE
# 1.11 18-Jul-1999 csapuntz

Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.10 30-Jan-1999 niklas

A slew of manifest constants for pci configuration registers gotten from freebsd


Revision tags: OPENBSD_2_4_BASE
# 1.9 12-Jul-1998 deraadt

fix bhlcr shift values; fgsch@olimpo.com.br


# 1.8 25-Apr-1998 deraadt

UDF and 66MHz support; zubin@clouseau.arl.wustl.edu


Revision tags: OPENBSD_2_3_BASE
# 1.7 03-Feb-1998 deraadt

more pci subclasses and such; netbsd


# 1.6 03-Feb-1998 deraadt

more bridge types


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.5 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.4 31-Oct-1996 millert

Add ATM defines. From Jim Rees <rees@umich.edu>


Revision tags: OPENBSD_2_0_BASE
# 1.3 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.2 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_2_BASE
# 1.55 09-Aug-2017 mlarkin

vmd: allow guest PCI interrupt line reassignment.

I also added a couple config space register names to pcireg.h to try and
reduce the use of magic numbers in vmd/pci.c

ok pd@


# 1.54 12-Jun-2017 kevlo

From FreeBSD (r227593, r307982):
More and more RealTek controllers started to implement EEE feature.
Vendor driver seems to load a kind of firmware for EEE with
additional PHY fixups. It is known that the EEE feature may need
ASPM support. Unfortunately there is no documentation for EEE of
the controller so enabling ASPM may cause more problems.

The Realtek vendor drivers for FreeBSD and Linux also disable ASPM and
clock request. While here, add a define for the ECPM (Enable Clock Power
Management) bit.

Tested by stsp@ and myself.
ok stsp@


Revision tags: OPENBSD_6_1_BASE
# 1.53 25-Mar-2017 mlarkin

More PCI extended capabilities handling in pcidump.

From Simon Mages

ok deraadt@


# 1.52 22-Mar-2017 jsg

Add some more PCI classes and subclasses. Checked against EDK2 as
"PCI Code and ID Assignment Specification" is only available for those
willing to pay thousands of dollars for PDFs.

Prompted by a dmesg from an AMD Zen system which uses class 0x13
(Non-Essential Instrumentation) and System subclass 0x06 (IOMMU). There
is currently no public documentation for AMD family 17h to reference to
see if this is sane.

ok kettenis@ on an earlier version


# 1.51 16-Mar-2017 deraadt

Print PCIe Extended Capabilities, from Simon Mages
ok kettenis mlarkin


Revision tags: OPENBSD_6_0_BASE
# 1.50 02-Jun-2016 kettenis

Fix two issues in the MSI-X code. First, actually read the MSI-X capability
register. Second, correctly decode the table sizefromits contents.

First issue pointed out by David Hill (with the help of clang). Second
issue spotted after seeing a diff from Christiano Hasbaert.


# 1.49 04-May-2016 kettenis

Initial support for MSI-X. Only supported on amd64 for now. I have diffs to
actually use this in em(4) and xhci(4), but I'm not committing those yet
because we almost certainly need to save and restore the MSI-X registers
during suspend/resume. However, this allows mpi@ to play with multiple-vector
support in networking hardware.

Requested by mpi@
ok mlarkin@, mikeb@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.48 02-Jun-2015 mpi

Add missing define for hpb(4).


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.47 27-Apr-2014 stsp

Add PME_STATUS and PME_EN bitmasks for the PCI PMCSR register.
ok kettenis@


# 1.46 09-Apr-2014 dlg

apparently NVM is a type of mass storage now


Revision tags: OPENBSD_5_5_BASE
# 1.45 26-Aug-2013 jsg

add a define for the link capabilities register for
version 2 of the PCIe capability.


Revision tags: OPENBSD_5_4_BASE
# 1.44 03-Jun-2013 mikeb

Define some more DCSR/DCTL bits; ok kettenis


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.43 13-May-2012 kettenis

Add define for capability 0x12 (SATA).


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.42 19-Jun-2011 kettenis

Fix typo in the "fixed" HyperTransport MSI Mapping Capability address.


# 1.41 30-May-2011 kettenis

Enable MSI for HyperTransport devices that have MSI remapping enabled.


# 1.40 14-May-2011 kettenis

Add register definitions for PCI MSI capaility.

ok oga@, miod@, marco@, dlg@, krw@


Revision tags: OPENBSD_4_9_BASE
# 1.39 05-Dec-2010 kettenis

PCIe based sparc64 machines have always supported access to the extended PCIe
configuration space. So on pyro(4) and vpci(4) return the size appropriate
for the extended PCIe configuration space.

ok miod@


# 1.38 04-Dec-2010 miod

Introduce a new pci routine, pci_conf_size(), which returns the size of a
given pcitag_t configuration address space. Currently, all pci controllers
will return the usual 0x100 bytes of PCI configuration space, but this will
eventually change on PCIe-capable controlers.
ok kettenis@


# 1.37 01-Dec-2010 damien

Add definition for "Extended Synch" bit in PCIe Link Control register.
From PCI Express(R) Base Specification Rev 2.0.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 28-May-2009 damien

Add "Interrupt Disable" bit definition for the PCI Configuration Space
Command register. From PCI Express Base Specification Rev 2.0.
Use same naming as NetBSD.
Needed for wpi(4) and iwn(4).


Revision tags: OPENBSD_4_5_BASE
# 1.35 25-Nov-2008 damien

move some generic PCIe register flags used in wpi(4) and iwn(4)
into common pcireg.h

ok deraadt@, kettenis@, dlg@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 26-Nov-2007 jsg

Add PCI VPD read/write functions from NetBSD required for some things
dlg is playing with.

'put it in' dlg@


# 1.33 25-Nov-2007 kettenis

First step towards PCI Express/ExpressCard hotplug. Unplug should work on
detachable drivers.

"put it in" deraadt@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 31-Jul-2006 mickey

puc@cardbus (only added (commented out) to whom has puc@pci enabled)
tested on puc@pci by fkr and meself on the cardbus.
still needs a bit more work but generally works.
deraadt@ ok and some input from miod@


# 1.31 01-Jun-2006 brad

add 2 subclasses, subclass storage SAS and subclass system SD Host Controller.

From NetBSD


# 1.30 28-May-2006 uwe

Support for standard SD host controllers like the Ricoh 5C822, a small
generic bus layer, and SCSI emulation for SD/MMC memory cards.


# 1.29 11-May-2006 brad

add PCI multimedia subclass type of HD audio.


Revision tags: OPENBSD_3_9_BASE
# 1.28 31-Dec-2005 dlg

add macros for the expansion ROM base address register

ok brad@ grange@ fgsch@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.27 16-Nov-2004 brad

add PCI_ID_CODE

From NetBSD


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 06-Dec-2003 grange

Mark u_int64_t constants with ULL to make gcc3 happy.
ok drahn@


# 1.25 16-Nov-2003 avsm

convert __attribute__((__packed__)) to __packed so that parsers unaware
of gcc extensions have more of a chance.
ok mcbride@, no objections from millert@, deraadt@


# 1.24 06-Oct-2003 fgsch

power management status reg. definition; from netbsd.
ok deraadt@ henning@ krw@.


Revision tags: OPENBSD_3_4_BASE
# 1.23 27-Aug-2003 mickey

this bit is defined as prefetchable and not cachable and thus rename and use appropriately


Revision tags: UBC_SYNC_A
# 1.22 02-Apr-2003 grange

PCI_CAP_MBI should really be PCI_CAP_MSI
ok jason@


# 1.21 01-Apr-2003 grange

Add a couple of new pci subclasses and caps from NetBSD
ok jason@


Revision tags: OPENBSD_3_3_BASE
# 1.20 08-Feb-2003 jason

definitions and structures for vital product data (VPD); from netbsd


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 13-Jul-2002 mickey

define PCI_COMMAND_STATUS_BITS for printfs, according to the enlisted defines


Revision tags: OPENBSD_3_1_BASE
# 1.18 06-Apr-2002 jason

s/REESSERVED/RESERVED/


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.17 08-May-2001 mickey

branches: 1.17.4;
more class/subclass/caps ids; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.16 09-Feb-2001 aaron

Add PCI Power Management Control Register definitions; from NetBSD.


# 1.15 08-Nov-2000 art

Defines for min_gnt and max_lat fields in the bhlc reg.
Not used yet.


Revision tags: OPENBSD_2_8_BASE
# 1.14 20-Sep-2000 niklas

support 64bit BARs from NetBSD


# 1.13 02-Aug-2000 mickey

import a few useful consts from netbsd; mainly for pcibios thing slip


Revision tags: OPENBSD_2_7_BASE SMP_BASE kame_19991208
# 1.12 26-Oct-1999 downsj

branches: 1.12.2;
Missed earlier: add PCI_HDRTYPE_TYPE macro, from NetBSD.


Revision tags: OPENBSD_2_6_BASE
# 1.11 18-Jul-1999 csapuntz

Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.10 30-Jan-1999 niklas

A slew of manifest constants for pci configuration registers gotten from freebsd


Revision tags: OPENBSD_2_4_BASE
# 1.9 12-Jul-1998 deraadt

fix bhlcr shift values; fgsch@olimpo.com.br


# 1.8 25-Apr-1998 deraadt

UDF and 66MHz support; zubin@clouseau.arl.wustl.edu


Revision tags: OPENBSD_2_3_BASE
# 1.7 03-Feb-1998 deraadt

more pci subclasses and such; netbsd


# 1.6 03-Feb-1998 deraadt

more bridge types


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.5 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.4 31-Oct-1996 millert

Add ATM defines. From Jim Rees <rees@umich.edu>


Revision tags: OPENBSD_2_0_BASE
# 1.3 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.2 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision