History log of /netbsd-current/sys/arch/sparc64/dev/pci_machdep.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.83 23-Jun-2024 riastradh

pci: Pass cookie through pci_find_device, pci_enumerate_bus, take 2.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This will allow pci_find_device callers to pass a cookie through to
the match function so they can keep state or pass in extra parameters
like b/d/f numbers, which will allow us to nix some horrible kludges
in the Linux PCI API emulation for drm (and, perhaps, Intel wifi).

This change drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.

Take 2: Make sure to handle NULL match function.


# 1.82 20-May-2024 riastradh

Revert "pci: Pass cookie through pci_find_device, pci_enumerate_bus."

Evidently something is wrong with this, to be diagnosed and redone
once the builds and tests are in better shape.


# 1.81 20-May-2024 riastradh

pci: Pass cookie through pci_find_device, pci_enumerate_bus.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.


# 1.80 20-Dec-2023 thorpej

Remove unnecessary <sys/malloc.h>.


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.79 01-Oct-2022 charlotte

Don't try to make a tag based on node 0


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.78 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 nick-nhusb-base-20170204 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 nick-nhusb-base-20161204 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE nick-nhusb-base-20161004 localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.77 29-Mar-2014 christos

branches: 1.77.28; 1.77.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


# 1.76 26-Mar-2014 christos

kill sprintf


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.75 27-Oct-2012 chs

branches: 1.75.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.74 12-Aug-2011 mrg

branches: 1.74.2; 1.74.12;
convert some open-coded SPDB_PROBE printf calls to use DPRINTF() macro.


# 1.73 01-Jul-2011 dyoung

#include <sys/bus.h> instead of <machine/bus.h>.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.72 11-May-2011 macallan

when looking for a device's node we want to start with the child nodes of the
root bus, not its peers


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.71 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.70 20-Mar-2011 mrg

remove unnecessary iommuvar.h and psycho{reg,var}.h includes.


# 1.69 16-Mar-2011 mrg

don't try to turn on parity or set the latency timer, or dump pci config
space for the pci bridge in sparc64_pci_enumerate_bus(). it doesn't work
on PCIe adapters. #if 0'ed for now, should move this into psycho/schizo.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.68 18-Dec-2010 mrg

branches: 1.68.2;
allow sparc64 spc_find_ino() to be NULL; schizo doesn't need it.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.67 07-Jan-2010 jdc

branches: 1.67.4;
Cope with up to four "interrupts" properties for a node.
Just use the first one for now. This should be improved.
OK: mrg@.


# 1.66 06-Jan-2010 mrg

move the guts of pci_intr_map() into pci_machdep.c, and move the schizo
ign addition into a hook. also, don't double shift the ign in set_intr.

tested on U60 and SB2500.


Revision tags: matt-premerge-20091211
# 1.65 30-Nov-2009 mrg

convert pci_intr_map() into a chipset tag function pointer, and implement
the schizo version slightly differently.

pull out the schizo's IGN from the upaid, not the apparently broken device
ID register. from openbsd.

with this i appear to have valid working interrupts on the SB2500.

tested on U60 and SB2500.


XXX: we can probably kill (*spc_find_ino)() now that pci_intr_map() itself
XXX: is no longer a first class function.


# 1.64 28-Nov-2009 mrg

give more debug output about mapping interrupts.


# 1.63 27-Nov-2009 mrg

clean up some debug messages a little bit.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.62 10-Dec-2008 nakayama

pci_make_tag:
- add assertion for checking spc_busnode initialization.


# 1.61 10-Dec-2008 mrg

ofpci_make_tag():
don't write PCI_COMMAND_STATUS_REG with
PCI_COMMAND_(MEM|MASTER|IO)_ENABLE, or it in.
sparc_pci_childspace():
move psycho.c:get_childspace() into pci_machdep.c but rename it
psycho_alloc_bus_tag():
use M_ZERO


# 1.60 07-Dec-2008 mrg

a few clean up/rearrange changes, somewhat inspired from openbsd's
schizo.c:

- rename pp_busnode{} -> spc_busnode{}, and move it to
sparc_pci_chipset{}

- move public pci functions pci_conf_read(), pci_conf_write() and
pci_intr_establish() into psycho.c, renaming them in the process,
and add pointers through sparc_pci_chipset{} to access them.
as part of this, add PDB_INTMAP and PDB_CONF debug options to
psycho.c

- move and rename sparc64 private pci_find_ino() into
sparc_pci_chipset{}, like the above

- update psycho_alloc_chipset() to set the new 4 function members


no functional change intended. XXX: not tested on cardbus.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.59 30-May-2008 ad

branches: 1.59.4; 1.59.6;
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.58 29-May-2008 mrg

remove clause #3 from my license where there are no other
copyright holders involved.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.57 24-Mar-2008 cube

branches: 1.57.2; 1.57.4; 1.57.6;
Change previous to use aprint_error_dev.


# 1.56 23-Mar-2008 macallan

use device_xname()


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.55 03-Feb-2008 martin

branches: 1.55.6;
Do not panic when trying to disestablish a pci interrupt.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base nick-csl-alignment-base matt-mips64-base yamt-idlelwp-base8 ppcoea-renovation-base thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.54 04-Apr-2007 tnn

branches: 1.54.14; 1.54.20;
pci_find_ino(): Use interrupt pin from pci_attach_args when mapping interrupts.
Use *ihp as a pure output. Fix case where interrupt pin #D was incorrectly
mapped. Some cosmetic changes while here. Ok'd by martin.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 newlock2-base netbsd-4-base
# 1.53 21-Oct-2006 mrg

branches: 1.53.4; 1.53.8; 1.53.10;
remove "struct cacheline" and the "cacheline" variable. (it was only set
in cpu_attach(), overwritten by multiple cpus, and only one member of the
12 or more were ever used again.) add an ecache_min_line_size to replace
this functionality.

clean up some non-SMP friendly code from cpu_attach():
- only reset the fpu state on the boot cpu
- don't bother printing "FPU version 0" always
- don't call getver() and ignore the result
- print the UPA id on the first cpu0: line

only print mp_tramp address #ifdef DEBUG.

reset the fpu state in cpu_hatch(), like cpu_attach() does for the boot cpu.


cpu_attach() is now free of SMP-unfriendly code.


# 1.52 15-Oct-2006 martin

Missing initializers


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.51 11-Feb-2006 cdi

branches: 1.51.14; 1.51.16;
ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.


# 1.50 11-Dec-2005 christos

branches: 1.50.2; 1.50.4; 1.50.6;
merge ktrace-lwp.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 yamt-readahead-base3 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 yamt-readahead-base2 netbsd-3-0-RC2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base netbsd-3-0-RC1 yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base ktrace-lwp-base
# 1.49 17-Aug-2004 drochner

branches: 1.49.12;
make PCI devices attachable/detachable (as far as the particular drivers
allow), and allow to rescan a bus selectively (ie only the device/
function I'm looking at)


# 1.48 29-Jul-2004 drochner

give the special PCI bus enumerator a sparc64_ prefix and make the
PCI_MACHDEP_ENUMERATE_BUS macro point to it


# 1.47 11-Jun-2004 petrov

pci_find_ino: support pci-pci bridges.


# 1.46 04-Apr-2004 nakayama

Revert a part of rev. 1.44.

OF_getprop can get only the first "reg" property with a statically
allocated buffer, but prom_getprop cannot.
This should fix a "kernel trap 30: data access exception" when you
invoke a pcictl(8).


Revision tags: netbsd-2-0-base
# 1.45 28-Mar-2004 nakayama

branches: 1.45.2;
Set prom_getprop args correctly.


# 1.44 21-Mar-2004 pk

Some more promlib interface conversions.


# 1.43 21-Mar-2004 pk

Two commas went missing in last commit.


# 1.42 21-Mar-2004 pk

Partial switch to the promlib interface.


# 1.41 21-Jan-2004 petrov

For pci devices without ofw mapping find ino by pci bus/slot/device
information, from OpenBSD.


# 1.40 09-Nov-2003 martin

Nuke bcopy/bzero.


# 1.39 22-Aug-2003 petrov

Cosmetic: move DEBUG defines.


# 1.38 15-Jul-2003 lukem

__KERNEL_RCSID()


# 1.37 05-May-2003 martin

branches: 1.37.2;
When overwriting the cache line size configuration, do not use the magic
value 0x10, but instead calculate a line size that is properly aligned
to the IOMMU strbuf cache and our external cache line size.
From FreeBSD.


# 1.36 04-May-2003 martin

Move the bus speed query code into it's own function and make it default
to 33 MHz. Cosmetics, no functional change.


# 1.35 22-Mar-2003 nakayama

PCI-CardBus bridge support for sparc64:
- handle devices which has no OBP node.
- move PCI latency-timer initialization from pci_intr_map to
pci_enumerate_bus.
- make PCI bus free space extents for cardbus devices.
- fix PCI config space map size.
- some code integrations.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.34 10-Dec-2002 pk

Remove the `flags' argument from bus_intr_establish().


Revision tags: kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.33 28-Sep-2002 martin

Set the PCI latency timer for bus master devices.

Slightly different to the patch suggested by Takeshi Nakayama in PR 18451
(idea from FreeBSD).

Additional input from Jason Thorpe: do not hard code the bus frequency,
instead get it from OpenFirmware.


Revision tags: gehenna-devsw-base
# 1.32 29-Jun-2002 eeh

Turn on parity checking for the PCI bus.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.31 16-May-2002 eeh

branches: 1.31.2;
Make the PCI code actually work.


# 1.30 16-May-2002 thorpej

branches: 1.30.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.


# 1.29 15-May-2002 thorpej

Garbage-collect __PCI_DEV_FUNCORDER.


# 1.28 15-May-2002 thorpej

Implement pci_decompose_tag().


# 1.27 06-May-2002 eeh

Add ofpci_make_tag().


Revision tags: eeh-devprop-base
# 1.26 20-Mar-2002 eeh

Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.


Revision tags: newlock-base ifpoll-base thorpej-mips-cache-base
# 1.25 17-Oct-2001 thorpej

branches: 1.25.4;
Fix the semantics of __PCI_DEV_FUNCORDER so that they're actually useful:
If __PCI_DEV_FUNCORDER is defined, don't do the song-and-dance to check if
a device is multi-function; machdep code is going to tell us exactly which
functions to probe.

Note this required changing how pci_func_devorder() works in the
sparc64 PCI machdep code; now the "curnode" is assumed to point
to the bus, rather than some function (typically 0) on the device,
just as pci_bus_devorder() makes that assumption.

All this should allow the PCI code to actually locate the second
HME device on a Sun Netra t1, which is at 3,1 -- previously, the
PCI code would have missed it because there is no device at 3,0.

(Sun deserves a brick to the head for this one -- this seems clearly
out of line with the PCI spec.)


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.24 15-Sep-2001 mrg

in pci_conf_read() and pci_conf_write(), convert all printf()'s to only
occur if SPDB_CONF (and hence DEBUG). also convert the panic in
pci_conf_write() to a SPDB_CONF warning and a return.

this cleans up pcictl(8) support.


Revision tags: thorpej-devvp-base
# 1.23 23-Aug-2001 eeh

branches: 1.23.2;
Fix backwards compare. (From Jason Wright)


# 1.22 20-Jul-2001 eeh

PCI overhaul.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.21 21-Mar-2001 mrg

branches: 1.21.2;
adapt to systems with out interrupt-map & interrupt-map-mask properties.


# 1.20 06-Mar-2001 mrg

rework pci_attach_hook() to just deal with the INO, not the full
interrupt number. properly find interrupts for the E250. modify
pci_intr_map() accordingly. retire psycho_intr_map(). deal with
INO values upto 0x3f, not upto 0x32. restructure sabre_init() and
psycho_init() to be more similar, and display each psycho's IGN.
psycho_intr_establish() deals with INO upto 0x3f, values from 0x32
and higher get 0 for IPL.

tested on E250 & U5.


# 1.19 02-Mar-2001 mrg

branches: 1.19.2;
use pci_bus_devorder() and pci_dev_funcorder()


# 1.18 19-Jan-2001 martin

Enable IO space mapping by default.
Fixes PR 11940.


# 1.17 14-Jan-2001 martin

Fix format warnings to make it compile again.


# 1.16 28-Dec-2000 sommerfeld

Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q


# 1.15 26-Jul-2000 pk

On-board devices on psycho machines seem to have the `interrupt' property
in the parent bus format (i.e. an INO) rather than being represented as
an PCI interrupt line. Provide a hack to work around this in pci_attach_hook().


Revision tags: mrg-merge-1-5-top
# 1.14 18-Jul-2000 pk

Use probeget() in pci_config_read() for the psycho, to avoid bus
faults when probing PCI space.


# 1.13 09-Jul-2000 pk

Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.


# 1.12 29-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


# 1.11 26-Jun-2000 mrg

remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.


Revision tags: netbsd-1-5-base
# 1.10 18-Jun-2000 mrg

branches: 1.10.2;
kill dead code.


# 1.9 08-Jun-2000 eeh

Turn on PCI MEM and DMA.


# 1.8 04-Jun-2000 cgd

Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).


Revision tags: minoura-xpg4dl-base
# 1.7 24-May-2000 eeh

branches: 1.7.2;
Use the PCI function code to distinguish simba bus A from bus B instead
of the current hack.


# 1.6 17-May-2000 mrg

add a note about US IIi and PCI_INTERRUPT_LINE register


# 1.5 08-Apr-2000 mrg

- store the ebus's parent so we can find the IOMMU
- use generic iommu routines in the ebus code (uses the above)
- add some more comments.


# 1.4 05-Apr-2000 mrg

clean this up some.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.3 05-Jun-1999 eeh

branches: 1.3.2; 1.3.4;
Make pbrobeget() and probeset() work for 64-bit values as well. To do this
the arguments are changed so the address is first and the ASI second so we
can have the address in %o0:%o1 and not worry about unused registers.

Also a bit of copyright cleanup.


# 1.2 05-Jun-1999 mrg

clean up a bit, implement pci_conf_{read,write}() with probe[gs]et() (not yet used).


# 1.1 04-Jun-1999 mrg

PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...


# 1.82 20-May-2024 riastradh

Revert "pci: Pass cookie through pci_find_device, pci_enumerate_bus."

Evidently something is wrong with this, to be diagnosed and redone
once the builds and tests are in better shape.


# 1.81 20-May-2024 riastradh

pci: Pass cookie through pci_find_device, pci_enumerate_bus.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.


# 1.80 20-Dec-2023 thorpej

Remove unnecessary <sys/malloc.h>.


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.79 01-Oct-2022 charlotte

Don't try to make a tag based on node 0


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.78 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 nick-nhusb-base-20170204 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 nick-nhusb-base-20161204 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE nick-nhusb-base-20161004 localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.77 29-Mar-2014 christos

branches: 1.77.28; 1.77.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


# 1.76 26-Mar-2014 christos

kill sprintf


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.75 27-Oct-2012 chs

branches: 1.75.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.74 12-Aug-2011 mrg

branches: 1.74.2; 1.74.12;
convert some open-coded SPDB_PROBE printf calls to use DPRINTF() macro.


# 1.73 01-Jul-2011 dyoung

#include <sys/bus.h> instead of <machine/bus.h>.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.72 11-May-2011 macallan

when looking for a device's node we want to start with the child nodes of the
root bus, not its peers


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.71 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.70 20-Mar-2011 mrg

remove unnecessary iommuvar.h and psycho{reg,var}.h includes.


# 1.69 16-Mar-2011 mrg

don't try to turn on parity or set the latency timer, or dump pci config
space for the pci bridge in sparc64_pci_enumerate_bus(). it doesn't work
on PCIe adapters. #if 0'ed for now, should move this into psycho/schizo.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.68 18-Dec-2010 mrg

branches: 1.68.2;
allow sparc64 spc_find_ino() to be NULL; schizo doesn't need it.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.67 07-Jan-2010 jdc

branches: 1.67.4;
Cope with up to four "interrupts" properties for a node.
Just use the first one for now. This should be improved.
OK: mrg@.


# 1.66 06-Jan-2010 mrg

move the guts of pci_intr_map() into pci_machdep.c, and move the schizo
ign addition into a hook. also, don't double shift the ign in set_intr.

tested on U60 and SB2500.


Revision tags: matt-premerge-20091211
# 1.65 30-Nov-2009 mrg

convert pci_intr_map() into a chipset tag function pointer, and implement
the schizo version slightly differently.

pull out the schizo's IGN from the upaid, not the apparently broken device
ID register. from openbsd.

with this i appear to have valid working interrupts on the SB2500.

tested on U60 and SB2500.


XXX: we can probably kill (*spc_find_ino)() now that pci_intr_map() itself
XXX: is no longer a first class function.


# 1.64 28-Nov-2009 mrg

give more debug output about mapping interrupts.


# 1.63 27-Nov-2009 mrg

clean up some debug messages a little bit.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.62 10-Dec-2008 nakayama

pci_make_tag:
- add assertion for checking spc_busnode initialization.


# 1.61 10-Dec-2008 mrg

ofpci_make_tag():
don't write PCI_COMMAND_STATUS_REG with
PCI_COMMAND_(MEM|MASTER|IO)_ENABLE, or it in.
sparc_pci_childspace():
move psycho.c:get_childspace() into pci_machdep.c but rename it
psycho_alloc_bus_tag():
use M_ZERO


# 1.60 07-Dec-2008 mrg

a few clean up/rearrange changes, somewhat inspired from openbsd's
schizo.c:

- rename pp_busnode{} -> spc_busnode{}, and move it to
sparc_pci_chipset{}

- move public pci functions pci_conf_read(), pci_conf_write() and
pci_intr_establish() into psycho.c, renaming them in the process,
and add pointers through sparc_pci_chipset{} to access them.
as part of this, add PDB_INTMAP and PDB_CONF debug options to
psycho.c

- move and rename sparc64 private pci_find_ino() into
sparc_pci_chipset{}, like the above

- update psycho_alloc_chipset() to set the new 4 function members


no functional change intended. XXX: not tested on cardbus.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.59 30-May-2008 ad

branches: 1.59.4; 1.59.6;
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.58 29-May-2008 mrg

remove clause #3 from my license where there are no other
copyright holders involved.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.57 24-Mar-2008 cube

branches: 1.57.2; 1.57.4; 1.57.6;
Change previous to use aprint_error_dev.


# 1.56 23-Mar-2008 macallan

use device_xname()


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.55 03-Feb-2008 martin

branches: 1.55.6;
Do not panic when trying to disestablish a pci interrupt.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base nick-csl-alignment-base matt-mips64-base yamt-idlelwp-base8 ppcoea-renovation-base thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.54 04-Apr-2007 tnn

branches: 1.54.14; 1.54.20;
pci_find_ino(): Use interrupt pin from pci_attach_args when mapping interrupts.
Use *ihp as a pure output. Fix case where interrupt pin #D was incorrectly
mapped. Some cosmetic changes while here. Ok'd by martin.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 newlock2-base netbsd-4-base
# 1.53 21-Oct-2006 mrg

branches: 1.53.4; 1.53.8; 1.53.10;
remove "struct cacheline" and the "cacheline" variable. (it was only set
in cpu_attach(), overwritten by multiple cpus, and only one member of the
12 or more were ever used again.) add an ecache_min_line_size to replace
this functionality.

clean up some non-SMP friendly code from cpu_attach():
- only reset the fpu state on the boot cpu
- don't bother printing "FPU version 0" always
- don't call getver() and ignore the result
- print the UPA id on the first cpu0: line

only print mp_tramp address #ifdef DEBUG.

reset the fpu state in cpu_hatch(), like cpu_attach() does for the boot cpu.


cpu_attach() is now free of SMP-unfriendly code.


# 1.52 15-Oct-2006 martin

Missing initializers


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.51 11-Feb-2006 cdi

branches: 1.51.14; 1.51.16;
ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.


# 1.50 11-Dec-2005 christos

branches: 1.50.2; 1.50.4; 1.50.6;
merge ktrace-lwp.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 yamt-readahead-base3 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 yamt-readahead-base2 netbsd-3-0-RC2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base netbsd-3-0-RC1 yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base ktrace-lwp-base
# 1.49 17-Aug-2004 drochner

branches: 1.49.12;
make PCI devices attachable/detachable (as far as the particular drivers
allow), and allow to rescan a bus selectively (ie only the device/
function I'm looking at)


# 1.48 29-Jul-2004 drochner

give the special PCI bus enumerator a sparc64_ prefix and make the
PCI_MACHDEP_ENUMERATE_BUS macro point to it


# 1.47 11-Jun-2004 petrov

pci_find_ino: support pci-pci bridges.


# 1.46 04-Apr-2004 nakayama

Revert a part of rev. 1.44.

OF_getprop can get only the first "reg" property with a statically
allocated buffer, but prom_getprop cannot.
This should fix a "kernel trap 30: data access exception" when you
invoke a pcictl(8).


Revision tags: netbsd-2-0-base
# 1.45 28-Mar-2004 nakayama

branches: 1.45.2;
Set prom_getprop args correctly.


# 1.44 21-Mar-2004 pk

Some more promlib interface conversions.


# 1.43 21-Mar-2004 pk

Two commas went missing in last commit.


# 1.42 21-Mar-2004 pk

Partial switch to the promlib interface.


# 1.41 21-Jan-2004 petrov

For pci devices without ofw mapping find ino by pci bus/slot/device
information, from OpenBSD.


# 1.40 09-Nov-2003 martin

Nuke bcopy/bzero.


# 1.39 22-Aug-2003 petrov

Cosmetic: move DEBUG defines.


# 1.38 15-Jul-2003 lukem

__KERNEL_RCSID()


# 1.37 05-May-2003 martin

branches: 1.37.2;
When overwriting the cache line size configuration, do not use the magic
value 0x10, but instead calculate a line size that is properly aligned
to the IOMMU strbuf cache and our external cache line size.
From FreeBSD.


# 1.36 04-May-2003 martin

Move the bus speed query code into it's own function and make it default
to 33 MHz. Cosmetics, no functional change.


# 1.35 22-Mar-2003 nakayama

PCI-CardBus bridge support for sparc64:
- handle devices which has no OBP node.
- move PCI latency-timer initialization from pci_intr_map to
pci_enumerate_bus.
- make PCI bus free space extents for cardbus devices.
- fix PCI config space map size.
- some code integrations.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.34 10-Dec-2002 pk

Remove the `flags' argument from bus_intr_establish().


Revision tags: kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.33 28-Sep-2002 martin

Set the PCI latency timer for bus master devices.

Slightly different to the patch suggested by Takeshi Nakayama in PR 18451
(idea from FreeBSD).

Additional input from Jason Thorpe: do not hard code the bus frequency,
instead get it from OpenFirmware.


Revision tags: gehenna-devsw-base
# 1.32 29-Jun-2002 eeh

Turn on parity checking for the PCI bus.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.31 16-May-2002 eeh

branches: 1.31.2;
Make the PCI code actually work.


# 1.30 16-May-2002 thorpej

branches: 1.30.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.


# 1.29 15-May-2002 thorpej

Garbage-collect __PCI_DEV_FUNCORDER.


# 1.28 15-May-2002 thorpej

Implement pci_decompose_tag().


# 1.27 06-May-2002 eeh

Add ofpci_make_tag().


Revision tags: eeh-devprop-base
# 1.26 20-Mar-2002 eeh

Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.


Revision tags: newlock-base ifpoll-base thorpej-mips-cache-base
# 1.25 17-Oct-2001 thorpej

branches: 1.25.4;
Fix the semantics of __PCI_DEV_FUNCORDER so that they're actually useful:
If __PCI_DEV_FUNCORDER is defined, don't do the song-and-dance to check if
a device is multi-function; machdep code is going to tell us exactly which
functions to probe.

Note this required changing how pci_func_devorder() works in the
sparc64 PCI machdep code; now the "curnode" is assumed to point
to the bus, rather than some function (typically 0) on the device,
just as pci_bus_devorder() makes that assumption.

All this should allow the PCI code to actually locate the second
HME device on a Sun Netra t1, which is at 3,1 -- previously, the
PCI code would have missed it because there is no device at 3,0.

(Sun deserves a brick to the head for this one -- this seems clearly
out of line with the PCI spec.)


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.24 15-Sep-2001 mrg

in pci_conf_read() and pci_conf_write(), convert all printf()'s to only
occur if SPDB_CONF (and hence DEBUG). also convert the panic in
pci_conf_write() to a SPDB_CONF warning and a return.

this cleans up pcictl(8) support.


Revision tags: thorpej-devvp-base
# 1.23 23-Aug-2001 eeh

branches: 1.23.2;
Fix backwards compare. (From Jason Wright)


# 1.22 20-Jul-2001 eeh

PCI overhaul.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.21 21-Mar-2001 mrg

branches: 1.21.2;
adapt to systems with out interrupt-map & interrupt-map-mask properties.


# 1.20 06-Mar-2001 mrg

rework pci_attach_hook() to just deal with the INO, not the full
interrupt number. properly find interrupts for the E250. modify
pci_intr_map() accordingly. retire psycho_intr_map(). deal with
INO values upto 0x3f, not upto 0x32. restructure sabre_init() and
psycho_init() to be more similar, and display each psycho's IGN.
psycho_intr_establish() deals with INO upto 0x3f, values from 0x32
and higher get 0 for IPL.

tested on E250 & U5.


# 1.19 02-Mar-2001 mrg

branches: 1.19.2;
use pci_bus_devorder() and pci_dev_funcorder()


# 1.18 19-Jan-2001 martin

Enable IO space mapping by default.
Fixes PR 11940.


# 1.17 14-Jan-2001 martin

Fix format warnings to make it compile again.


# 1.16 28-Dec-2000 sommerfeld

Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q


# 1.15 26-Jul-2000 pk

On-board devices on psycho machines seem to have the `interrupt' property
in the parent bus format (i.e. an INO) rather than being represented as
an PCI interrupt line. Provide a hack to work around this in pci_attach_hook().


Revision tags: mrg-merge-1-5-top
# 1.14 18-Jul-2000 pk

Use probeget() in pci_config_read() for the psycho, to avoid bus
faults when probing PCI space.


# 1.13 09-Jul-2000 pk

Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.


# 1.12 29-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


# 1.11 26-Jun-2000 mrg

remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.


Revision tags: netbsd-1-5-base
# 1.10 18-Jun-2000 mrg

branches: 1.10.2;
kill dead code.


# 1.9 08-Jun-2000 eeh

Turn on PCI MEM and DMA.


# 1.8 04-Jun-2000 cgd

Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).


Revision tags: minoura-xpg4dl-base
# 1.7 24-May-2000 eeh

branches: 1.7.2;
Use the PCI function code to distinguish simba bus A from bus B instead
of the current hack.


# 1.6 17-May-2000 mrg

add a note about US IIi and PCI_INTERRUPT_LINE register


# 1.5 08-Apr-2000 mrg

- store the ebus's parent so we can find the IOMMU
- use generic iommu routines in the ebus code (uses the above)
- add some more comments.


# 1.4 05-Apr-2000 mrg

clean this up some.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.3 05-Jun-1999 eeh

branches: 1.3.2; 1.3.4;
Make pbrobeget() and probeset() work for 64-bit values as well. To do this
the arguments are changed so the address is first and the ASI second so we
can have the address in %o0:%o1 and not worry about unused registers.

Also a bit of copyright cleanup.


# 1.2 05-Jun-1999 mrg

clean up a bit, implement pci_conf_{read,write}() with probe[gs]et() (not yet used).


# 1.1 04-Jun-1999 mrg

PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...


# 1.80 20-Dec-2023 thorpej

Remove unnecessary <sys/malloc.h>.


Revision tags: thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.79 01-Oct-2022 charlotte

Don't try to make a tag based on node 0


Revision tags: netbsd-9-3-RELEASE thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.78 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 nick-nhusb-base-20170204 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 nick-nhusb-base-20161204 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE nick-nhusb-base-20161004 localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.77 29-Mar-2014 christos

branches: 1.77.28; 1.77.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


# 1.76 26-Mar-2014 christos

kill sprintf


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.75 27-Oct-2012 chs

branches: 1.75.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.74 12-Aug-2011 mrg

branches: 1.74.2; 1.74.12;
convert some open-coded SPDB_PROBE printf calls to use DPRINTF() macro.


# 1.73 01-Jul-2011 dyoung

#include <sys/bus.h> instead of <machine/bus.h>.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.72 11-May-2011 macallan

when looking for a device's node we want to start with the child nodes of the
root bus, not its peers


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.71 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.70 20-Mar-2011 mrg

remove unnecessary iommuvar.h and psycho{reg,var}.h includes.


# 1.69 16-Mar-2011 mrg

don't try to turn on parity or set the latency timer, or dump pci config
space for the pci bridge in sparc64_pci_enumerate_bus(). it doesn't work
on PCIe adapters. #if 0'ed for now, should move this into psycho/schizo.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.68 18-Dec-2010 mrg

branches: 1.68.2;
allow sparc64 spc_find_ino() to be NULL; schizo doesn't need it.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.67 07-Jan-2010 jdc

branches: 1.67.4;
Cope with up to four "interrupts" properties for a node.
Just use the first one for now. This should be improved.
OK: mrg@.


# 1.66 06-Jan-2010 mrg

move the guts of pci_intr_map() into pci_machdep.c, and move the schizo
ign addition into a hook. also, don't double shift the ign in set_intr.

tested on U60 and SB2500.


Revision tags: matt-premerge-20091211
# 1.65 30-Nov-2009 mrg

convert pci_intr_map() into a chipset tag function pointer, and implement
the schizo version slightly differently.

pull out the schizo's IGN from the upaid, not the apparently broken device
ID register. from openbsd.

with this i appear to have valid working interrupts on the SB2500.

tested on U60 and SB2500.


XXX: we can probably kill (*spc_find_ino)() now that pci_intr_map() itself
XXX: is no longer a first class function.


# 1.64 28-Nov-2009 mrg

give more debug output about mapping interrupts.


# 1.63 27-Nov-2009 mrg

clean up some debug messages a little bit.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.62 10-Dec-2008 nakayama

pci_make_tag:
- add assertion for checking spc_busnode initialization.


# 1.61 10-Dec-2008 mrg

ofpci_make_tag():
don't write PCI_COMMAND_STATUS_REG with
PCI_COMMAND_(MEM|MASTER|IO)_ENABLE, or it in.
sparc_pci_childspace():
move psycho.c:get_childspace() into pci_machdep.c but rename it
psycho_alloc_bus_tag():
use M_ZERO


# 1.60 07-Dec-2008 mrg

a few clean up/rearrange changes, somewhat inspired from openbsd's
schizo.c:

- rename pp_busnode{} -> spc_busnode{}, and move it to
sparc_pci_chipset{}

- move public pci functions pci_conf_read(), pci_conf_write() and
pci_intr_establish() into psycho.c, renaming them in the process,
and add pointers through sparc_pci_chipset{} to access them.
as part of this, add PDB_INTMAP and PDB_CONF debug options to
psycho.c

- move and rename sparc64 private pci_find_ino() into
sparc_pci_chipset{}, like the above

- update psycho_alloc_chipset() to set the new 4 function members


no functional change intended. XXX: not tested on cardbus.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.59 30-May-2008 ad

branches: 1.59.4; 1.59.6;
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.58 29-May-2008 mrg

remove clause #3 from my license where there are no other
copyright holders involved.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.57 24-Mar-2008 cube

branches: 1.57.2; 1.57.4; 1.57.6;
Change previous to use aprint_error_dev.


# 1.56 23-Mar-2008 macallan

use device_xname()


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.55 03-Feb-2008 martin

branches: 1.55.6;
Do not panic when trying to disestablish a pci interrupt.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base nick-csl-alignment-base matt-mips64-base yamt-idlelwp-base8 ppcoea-renovation-base thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.54 04-Apr-2007 tnn

branches: 1.54.14; 1.54.20;
pci_find_ino(): Use interrupt pin from pci_attach_args when mapping interrupts.
Use *ihp as a pure output. Fix case where interrupt pin #D was incorrectly
mapped. Some cosmetic changes while here. Ok'd by martin.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 newlock2-base netbsd-4-base
# 1.53 21-Oct-2006 mrg

branches: 1.53.4; 1.53.8; 1.53.10;
remove "struct cacheline" and the "cacheline" variable. (it was only set
in cpu_attach(), overwritten by multiple cpus, and only one member of the
12 or more were ever used again.) add an ecache_min_line_size to replace
this functionality.

clean up some non-SMP friendly code from cpu_attach():
- only reset the fpu state on the boot cpu
- don't bother printing "FPU version 0" always
- don't call getver() and ignore the result
- print the UPA id on the first cpu0: line

only print mp_tramp address #ifdef DEBUG.

reset the fpu state in cpu_hatch(), like cpu_attach() does for the boot cpu.


cpu_attach() is now free of SMP-unfriendly code.


# 1.52 15-Oct-2006 martin

Missing initializers


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.51 11-Feb-2006 cdi

branches: 1.51.14; 1.51.16;
ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.


# 1.50 11-Dec-2005 christos

branches: 1.50.2; 1.50.4; 1.50.6;
merge ktrace-lwp.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 yamt-readahead-base3 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 yamt-readahead-base2 netbsd-3-0-RC2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base netbsd-3-0-RC1 yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base ktrace-lwp-base
# 1.49 17-Aug-2004 drochner

branches: 1.49.12;
make PCI devices attachable/detachable (as far as the particular drivers
allow), and allow to rescan a bus selectively (ie only the device/
function I'm looking at)


# 1.48 29-Jul-2004 drochner

give the special PCI bus enumerator a sparc64_ prefix and make the
PCI_MACHDEP_ENUMERATE_BUS macro point to it


# 1.47 11-Jun-2004 petrov

pci_find_ino: support pci-pci bridges.


# 1.46 04-Apr-2004 nakayama

Revert a part of rev. 1.44.

OF_getprop can get only the first "reg" property with a statically
allocated buffer, but prom_getprop cannot.
This should fix a "kernel trap 30: data access exception" when you
invoke a pcictl(8).


Revision tags: netbsd-2-0-base
# 1.45 28-Mar-2004 nakayama

branches: 1.45.2;
Set prom_getprop args correctly.


# 1.44 21-Mar-2004 pk

Some more promlib interface conversions.


# 1.43 21-Mar-2004 pk

Two commas went missing in last commit.


# 1.42 21-Mar-2004 pk

Partial switch to the promlib interface.


# 1.41 21-Jan-2004 petrov

For pci devices without ofw mapping find ino by pci bus/slot/device
information, from OpenBSD.


# 1.40 09-Nov-2003 martin

Nuke bcopy/bzero.


# 1.39 22-Aug-2003 petrov

Cosmetic: move DEBUG defines.


# 1.38 15-Jul-2003 lukem

__KERNEL_RCSID()


# 1.37 05-May-2003 martin

branches: 1.37.2;
When overwriting the cache line size configuration, do not use the magic
value 0x10, but instead calculate a line size that is properly aligned
to the IOMMU strbuf cache and our external cache line size.
From FreeBSD.


# 1.36 04-May-2003 martin

Move the bus speed query code into it's own function and make it default
to 33 MHz. Cosmetics, no functional change.


# 1.35 22-Mar-2003 nakayama

PCI-CardBus bridge support for sparc64:
- handle devices which has no OBP node.
- move PCI latency-timer initialization from pci_intr_map to
pci_enumerate_bus.
- make PCI bus free space extents for cardbus devices.
- fix PCI config space map size.
- some code integrations.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.34 10-Dec-2002 pk

Remove the `flags' argument from bus_intr_establish().


Revision tags: kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.33 28-Sep-2002 martin

Set the PCI latency timer for bus master devices.

Slightly different to the patch suggested by Takeshi Nakayama in PR 18451
(idea from FreeBSD).

Additional input from Jason Thorpe: do not hard code the bus frequency,
instead get it from OpenFirmware.


Revision tags: gehenna-devsw-base
# 1.32 29-Jun-2002 eeh

Turn on parity checking for the PCI bus.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.31 16-May-2002 eeh

branches: 1.31.2;
Make the PCI code actually work.


# 1.30 16-May-2002 thorpej

branches: 1.30.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.


# 1.29 15-May-2002 thorpej

Garbage-collect __PCI_DEV_FUNCORDER.


# 1.28 15-May-2002 thorpej

Implement pci_decompose_tag().


# 1.27 06-May-2002 eeh

Add ofpci_make_tag().


Revision tags: eeh-devprop-base
# 1.26 20-Mar-2002 eeh

Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.


Revision tags: newlock-base ifpoll-base thorpej-mips-cache-base
# 1.25 17-Oct-2001 thorpej

branches: 1.25.4;
Fix the semantics of __PCI_DEV_FUNCORDER so that they're actually useful:
If __PCI_DEV_FUNCORDER is defined, don't do the song-and-dance to check if
a device is multi-function; machdep code is going to tell us exactly which
functions to probe.

Note this required changing how pci_func_devorder() works in the
sparc64 PCI machdep code; now the "curnode" is assumed to point
to the bus, rather than some function (typically 0) on the device,
just as pci_bus_devorder() makes that assumption.

All this should allow the PCI code to actually locate the second
HME device on a Sun Netra t1, which is at 3,1 -- previously, the
PCI code would have missed it because there is no device at 3,0.

(Sun deserves a brick to the head for this one -- this seems clearly
out of line with the PCI spec.)


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.24 15-Sep-2001 mrg

in pci_conf_read() and pci_conf_write(), convert all printf()'s to only
occur if SPDB_CONF (and hence DEBUG). also convert the panic in
pci_conf_write() to a SPDB_CONF warning and a return.

this cleans up pcictl(8) support.


Revision tags: thorpej-devvp-base
# 1.23 23-Aug-2001 eeh

branches: 1.23.2;
Fix backwards compare. (From Jason Wright)


# 1.22 20-Jul-2001 eeh

PCI overhaul.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.21 21-Mar-2001 mrg

branches: 1.21.2;
adapt to systems with out interrupt-map & interrupt-map-mask properties.


# 1.20 06-Mar-2001 mrg

rework pci_attach_hook() to just deal with the INO, not the full
interrupt number. properly find interrupts for the E250. modify
pci_intr_map() accordingly. retire psycho_intr_map(). deal with
INO values upto 0x3f, not upto 0x32. restructure sabre_init() and
psycho_init() to be more similar, and display each psycho's IGN.
psycho_intr_establish() deals with INO upto 0x3f, values from 0x32
and higher get 0 for IPL.

tested on E250 & U5.


# 1.19 02-Mar-2001 mrg

branches: 1.19.2;
use pci_bus_devorder() and pci_dev_funcorder()


# 1.18 19-Jan-2001 martin

Enable IO space mapping by default.
Fixes PR 11940.


# 1.17 14-Jan-2001 martin

Fix format warnings to make it compile again.


# 1.16 28-Dec-2000 sommerfeld

Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q


# 1.15 26-Jul-2000 pk

On-board devices on psycho machines seem to have the `interrupt' property
in the parent bus format (i.e. an INO) rather than being represented as
an PCI interrupt line. Provide a hack to work around this in pci_attach_hook().


Revision tags: mrg-merge-1-5-top
# 1.14 18-Jul-2000 pk

Use probeget() in pci_config_read() for the psycho, to avoid bus
faults when probing PCI space.


# 1.13 09-Jul-2000 pk

Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.


# 1.12 29-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


# 1.11 26-Jun-2000 mrg

remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.


Revision tags: netbsd-1-5-base
# 1.10 18-Jun-2000 mrg

branches: 1.10.2;
kill dead code.


# 1.9 08-Jun-2000 eeh

Turn on PCI MEM and DMA.


# 1.8 04-Jun-2000 cgd

Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).


Revision tags: minoura-xpg4dl-base
# 1.7 24-May-2000 eeh

branches: 1.7.2;
Use the PCI function code to distinguish simba bus A from bus B instead
of the current hack.


# 1.6 17-May-2000 mrg

add a note about US IIi and PCI_INTERRUPT_LINE register


# 1.5 08-Apr-2000 mrg

- store the ebus's parent so we can find the IOMMU
- use generic iommu routines in the ebus code (uses the above)
- add some more comments.


# 1.4 05-Apr-2000 mrg

clean this up some.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.3 05-Jun-1999 eeh

branches: 1.3.2; 1.3.4;
Make pbrobeget() and probeset() work for 64-bit values as well. To do this
the arguments are changed so the address is first and the ASI second so we
can have the address in %o0:%o1 and not worry about unused registers.

Also a bit of copyright cleanup.


# 1.2 05-Jun-1999 mrg

clean up a bit, implement pci_conf_{read,write}() with probe[gs]et() (not yet used).


# 1.1 04-Jun-1999 mrg

PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...


# 1.79 01-Oct-2022 charlotte

Don't try to make a tag based on node 0


Revision tags: netbsd-9-3-RELEASE thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.78 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 nick-nhusb-base-20170204 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 nick-nhusb-base-20161204 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE nick-nhusb-base-20161004 localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.77 29-Mar-2014 christos

branches: 1.77.28; 1.77.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


# 1.76 26-Mar-2014 christos

kill sprintf


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.75 27-Oct-2012 chs

branches: 1.75.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.74 12-Aug-2011 mrg

branches: 1.74.2; 1.74.12;
convert some open-coded SPDB_PROBE printf calls to use DPRINTF() macro.


# 1.73 01-Jul-2011 dyoung

#include <sys/bus.h> instead of <machine/bus.h>.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.72 11-May-2011 macallan

when looking for a device's node we want to start with the child nodes of the
root bus, not its peers


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.71 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.70 20-Mar-2011 mrg

remove unnecessary iommuvar.h and psycho{reg,var}.h includes.


# 1.69 16-Mar-2011 mrg

don't try to turn on parity or set the latency timer, or dump pci config
space for the pci bridge in sparc64_pci_enumerate_bus(). it doesn't work
on PCIe adapters. #if 0'ed for now, should move this into psycho/schizo.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.68 18-Dec-2010 mrg

branches: 1.68.2;
allow sparc64 spc_find_ino() to be NULL; schizo doesn't need it.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.67 07-Jan-2010 jdc

branches: 1.67.4;
Cope with up to four "interrupts" properties for a node.
Just use the first one for now. This should be improved.
OK: mrg@.


# 1.66 06-Jan-2010 mrg

move the guts of pci_intr_map() into pci_machdep.c, and move the schizo
ign addition into a hook. also, don't double shift the ign in set_intr.

tested on U60 and SB2500.


Revision tags: matt-premerge-20091211
# 1.65 30-Nov-2009 mrg

convert pci_intr_map() into a chipset tag function pointer, and implement
the schizo version slightly differently.

pull out the schizo's IGN from the upaid, not the apparently broken device
ID register. from openbsd.

with this i appear to have valid working interrupts on the SB2500.

tested on U60 and SB2500.


XXX: we can probably kill (*spc_find_ino)() now that pci_intr_map() itself
XXX: is no longer a first class function.


# 1.64 28-Nov-2009 mrg

give more debug output about mapping interrupts.


# 1.63 27-Nov-2009 mrg

clean up some debug messages a little bit.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.62 10-Dec-2008 nakayama

pci_make_tag:
- add assertion for checking spc_busnode initialization.


# 1.61 10-Dec-2008 mrg

ofpci_make_tag():
don't write PCI_COMMAND_STATUS_REG with
PCI_COMMAND_(MEM|MASTER|IO)_ENABLE, or it in.
sparc_pci_childspace():
move psycho.c:get_childspace() into pci_machdep.c but rename it
psycho_alloc_bus_tag():
use M_ZERO


# 1.60 07-Dec-2008 mrg

a few clean up/rearrange changes, somewhat inspired from openbsd's
schizo.c:

- rename pp_busnode{} -> spc_busnode{}, and move it to
sparc_pci_chipset{}

- move public pci functions pci_conf_read(), pci_conf_write() and
pci_intr_establish() into psycho.c, renaming them in the process,
and add pointers through sparc_pci_chipset{} to access them.
as part of this, add PDB_INTMAP and PDB_CONF debug options to
psycho.c

- move and rename sparc64 private pci_find_ino() into
sparc_pci_chipset{}, like the above

- update psycho_alloc_chipset() to set the new 4 function members


no functional change intended. XXX: not tested on cardbus.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.59 30-May-2008 ad

branches: 1.59.4; 1.59.6;
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.58 29-May-2008 mrg

remove clause #3 from my license where there are no other
copyright holders involved.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.57 24-Mar-2008 cube

branches: 1.57.2; 1.57.4; 1.57.6;
Change previous to use aprint_error_dev.


# 1.56 23-Mar-2008 macallan

use device_xname()


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.55 03-Feb-2008 martin

branches: 1.55.6;
Do not panic when trying to disestablish a pci interrupt.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base nick-csl-alignment-base matt-mips64-base yamt-idlelwp-base8 ppcoea-renovation-base thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.54 04-Apr-2007 tnn

branches: 1.54.14; 1.54.20;
pci_find_ino(): Use interrupt pin from pci_attach_args when mapping interrupts.
Use *ihp as a pure output. Fix case where interrupt pin #D was incorrectly
mapped. Some cosmetic changes while here. Ok'd by martin.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 newlock2-base netbsd-4-base
# 1.53 21-Oct-2006 mrg

branches: 1.53.4; 1.53.8; 1.53.10;
remove "struct cacheline" and the "cacheline" variable. (it was only set
in cpu_attach(), overwritten by multiple cpus, and only one member of the
12 or more were ever used again.) add an ecache_min_line_size to replace
this functionality.

clean up some non-SMP friendly code from cpu_attach():
- only reset the fpu state on the boot cpu
- don't bother printing "FPU version 0" always
- don't call getver() and ignore the result
- print the UPA id on the first cpu0: line

only print mp_tramp address #ifdef DEBUG.

reset the fpu state in cpu_hatch(), like cpu_attach() does for the boot cpu.


cpu_attach() is now free of SMP-unfriendly code.


# 1.52 15-Oct-2006 martin

Missing initializers


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.51 11-Feb-2006 cdi

branches: 1.51.14; 1.51.16;
ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.


# 1.50 11-Dec-2005 christos

branches: 1.50.2; 1.50.4; 1.50.6;
merge ktrace-lwp.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 yamt-readahead-base3 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 yamt-readahead-base2 netbsd-3-0-RC2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base netbsd-3-0-RC1 yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base ktrace-lwp-base
# 1.49 17-Aug-2004 drochner

branches: 1.49.12;
make PCI devices attachable/detachable (as far as the particular drivers
allow), and allow to rescan a bus selectively (ie only the device/
function I'm looking at)


# 1.48 29-Jul-2004 drochner

give the special PCI bus enumerator a sparc64_ prefix and make the
PCI_MACHDEP_ENUMERATE_BUS macro point to it


# 1.47 11-Jun-2004 petrov

pci_find_ino: support pci-pci bridges.


# 1.46 04-Apr-2004 nakayama

Revert a part of rev. 1.44.

OF_getprop can get only the first "reg" property with a statically
allocated buffer, but prom_getprop cannot.
This should fix a "kernel trap 30: data access exception" when you
invoke a pcictl(8).


Revision tags: netbsd-2-0-base
# 1.45 28-Mar-2004 nakayama

branches: 1.45.2;
Set prom_getprop args correctly.


# 1.44 21-Mar-2004 pk

Some more promlib interface conversions.


# 1.43 21-Mar-2004 pk

Two commas went missing in last commit.


# 1.42 21-Mar-2004 pk

Partial switch to the promlib interface.


# 1.41 21-Jan-2004 petrov

For pci devices without ofw mapping find ino by pci bus/slot/device
information, from OpenBSD.


# 1.40 09-Nov-2003 martin

Nuke bcopy/bzero.


# 1.39 22-Aug-2003 petrov

Cosmetic: move DEBUG defines.


# 1.38 15-Jul-2003 lukem

__KERNEL_RCSID()


# 1.37 05-May-2003 martin

branches: 1.37.2;
When overwriting the cache line size configuration, do not use the magic
value 0x10, but instead calculate a line size that is properly aligned
to the IOMMU strbuf cache and our external cache line size.
From FreeBSD.


# 1.36 04-May-2003 martin

Move the bus speed query code into it's own function and make it default
to 33 MHz. Cosmetics, no functional change.


# 1.35 22-Mar-2003 nakayama

PCI-CardBus bridge support for sparc64:
- handle devices which has no OBP node.
- move PCI latency-timer initialization from pci_intr_map to
pci_enumerate_bus.
- make PCI bus free space extents for cardbus devices.
- fix PCI config space map size.
- some code integrations.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.34 10-Dec-2002 pk

Remove the `flags' argument from bus_intr_establish().


Revision tags: kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.33 28-Sep-2002 martin

Set the PCI latency timer for bus master devices.

Slightly different to the patch suggested by Takeshi Nakayama in PR 18451
(idea from FreeBSD).

Additional input from Jason Thorpe: do not hard code the bus frequency,
instead get it from OpenFirmware.


Revision tags: gehenna-devsw-base
# 1.32 29-Jun-2002 eeh

Turn on parity checking for the PCI bus.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.31 16-May-2002 eeh

branches: 1.31.2;
Make the PCI code actually work.


# 1.30 16-May-2002 thorpej

branches: 1.30.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.


# 1.29 15-May-2002 thorpej

Garbage-collect __PCI_DEV_FUNCORDER.


# 1.28 15-May-2002 thorpej

Implement pci_decompose_tag().


# 1.27 06-May-2002 eeh

Add ofpci_make_tag().


Revision tags: eeh-devprop-base
# 1.26 20-Mar-2002 eeh

Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.


Revision tags: newlock-base ifpoll-base thorpej-mips-cache-base
# 1.25 17-Oct-2001 thorpej

branches: 1.25.4;
Fix the semantics of __PCI_DEV_FUNCORDER so that they're actually useful:
If __PCI_DEV_FUNCORDER is defined, don't do the song-and-dance to check if
a device is multi-function; machdep code is going to tell us exactly which
functions to probe.

Note this required changing how pci_func_devorder() works in the
sparc64 PCI machdep code; now the "curnode" is assumed to point
to the bus, rather than some function (typically 0) on the device,
just as pci_bus_devorder() makes that assumption.

All this should allow the PCI code to actually locate the second
HME device on a Sun Netra t1, which is at 3,1 -- previously, the
PCI code would have missed it because there is no device at 3,0.

(Sun deserves a brick to the head for this one -- this seems clearly
out of line with the PCI spec.)


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.24 15-Sep-2001 mrg

in pci_conf_read() and pci_conf_write(), convert all printf()'s to only
occur if SPDB_CONF (and hence DEBUG). also convert the panic in
pci_conf_write() to a SPDB_CONF warning and a return.

this cleans up pcictl(8) support.


Revision tags: thorpej-devvp-base
# 1.23 23-Aug-2001 eeh

branches: 1.23.2;
Fix backwards compare. (From Jason Wright)


# 1.22 20-Jul-2001 eeh

PCI overhaul.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.21 21-Mar-2001 mrg

branches: 1.21.2;
adapt to systems with out interrupt-map & interrupt-map-mask properties.


# 1.20 06-Mar-2001 mrg

rework pci_attach_hook() to just deal with the INO, not the full
interrupt number. properly find interrupts for the E250. modify
pci_intr_map() accordingly. retire psycho_intr_map(). deal with
INO values upto 0x3f, not upto 0x32. restructure sabre_init() and
psycho_init() to be more similar, and display each psycho's IGN.
psycho_intr_establish() deals with INO upto 0x3f, values from 0x32
and higher get 0 for IPL.

tested on E250 & U5.


# 1.19 02-Mar-2001 mrg

branches: 1.19.2;
use pci_bus_devorder() and pci_dev_funcorder()


# 1.18 19-Jan-2001 martin

Enable IO space mapping by default.
Fixes PR 11940.


# 1.17 14-Jan-2001 martin

Fix format warnings to make it compile again.


# 1.16 28-Dec-2000 sommerfeld

Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q


# 1.15 26-Jul-2000 pk

On-board devices on psycho machines seem to have the `interrupt' property
in the parent bus format (i.e. an INO) rather than being represented as
an PCI interrupt line. Provide a hack to work around this in pci_attach_hook().


Revision tags: mrg-merge-1-5-top
# 1.14 18-Jul-2000 pk

Use probeget() in pci_config_read() for the psycho, to avoid bus
faults when probing PCI space.


# 1.13 09-Jul-2000 pk

Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.


# 1.12 29-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


# 1.11 26-Jun-2000 mrg

remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.


Revision tags: netbsd-1-5-base
# 1.10 18-Jun-2000 mrg

branches: 1.10.2;
kill dead code.


# 1.9 08-Jun-2000 eeh

Turn on PCI MEM and DMA.


# 1.8 04-Jun-2000 cgd

Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).


Revision tags: minoura-xpg4dl-base
# 1.7 24-May-2000 eeh

branches: 1.7.2;
Use the PCI function code to distinguish simba bus A from bus B instead
of the current hack.


# 1.6 17-May-2000 mrg

add a note about US IIi and PCI_INTERRUPT_LINE register


# 1.5 08-Apr-2000 mrg

- store the ebus's parent so we can find the IOMMU
- use generic iommu routines in the ebus code (uses the above)
- add some more comments.


# 1.4 05-Apr-2000 mrg

clean this up some.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.3 05-Jun-1999 eeh

branches: 1.3.2; 1.3.4;
Make pbrobeget() and probeset() work for 64-bit values as well. To do this
the arguments are changed so the address is first and the ASI second so we
can have the address in %o0:%o1 and not worry about unused registers.

Also a bit of copyright cleanup.


# 1.2 05-Jun-1999 mrg

clean up a bit, implement pci_conf_{read,write}() with probe[gs]et() (not yet used).


# 1.1 04-Jun-1999 mrg

PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.78 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 nick-nhusb-base-20170204 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 nick-nhusb-base-20161204 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE nick-nhusb-base-20161004 localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.77 29-Mar-2014 christos

branches: 1.77.28;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


# 1.76 26-Mar-2014 christos

kill sprintf


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.75 27-Oct-2012 chs

branches: 1.75.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.74 12-Aug-2011 mrg

branches: 1.74.2; 1.74.12;
convert some open-coded SPDB_PROBE printf calls to use DPRINTF() macro.


# 1.73 01-Jul-2011 dyoung

#include <sys/bus.h> instead of <machine/bus.h>.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.72 11-May-2011 macallan

when looking for a device's node we want to start with the child nodes of the
root bus, not its peers


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.71 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.70 20-Mar-2011 mrg

remove unnecessary iommuvar.h and psycho{reg,var}.h includes.


# 1.69 16-Mar-2011 mrg

don't try to turn on parity or set the latency timer, or dump pci config
space for the pci bridge in sparc64_pci_enumerate_bus(). it doesn't work
on PCIe adapters. #if 0'ed for now, should move this into psycho/schizo.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.68 18-Dec-2010 mrg

branches: 1.68.2;
allow sparc64 spc_find_ino() to be NULL; schizo doesn't need it.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.67 07-Jan-2010 jdc

branches: 1.67.4;
Cope with up to four "interrupts" properties for a node.
Just use the first one for now. This should be improved.
OK: mrg@.


# 1.66 06-Jan-2010 mrg

move the guts of pci_intr_map() into pci_machdep.c, and move the schizo
ign addition into a hook. also, don't double shift the ign in set_intr.

tested on U60 and SB2500.


Revision tags: matt-premerge-20091211
# 1.65 30-Nov-2009 mrg

convert pci_intr_map() into a chipset tag function pointer, and implement
the schizo version slightly differently.

pull out the schizo's IGN from the upaid, not the apparently broken device
ID register. from openbsd.

with this i appear to have valid working interrupts on the SB2500.

tested on U60 and SB2500.


XXX: we can probably kill (*spc_find_ino)() now that pci_intr_map() itself
XXX: is no longer a first class function.


# 1.64 28-Nov-2009 mrg

give more debug output about mapping interrupts.


# 1.63 27-Nov-2009 mrg

clean up some debug messages a little bit.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.62 10-Dec-2008 nakayama

pci_make_tag:
- add assertion for checking spc_busnode initialization.


# 1.61 10-Dec-2008 mrg

ofpci_make_tag():
don't write PCI_COMMAND_STATUS_REG with
PCI_COMMAND_(MEM|MASTER|IO)_ENABLE, or it in.
sparc_pci_childspace():
move psycho.c:get_childspace() into pci_machdep.c but rename it
psycho_alloc_bus_tag():
use M_ZERO


# 1.60 07-Dec-2008 mrg

a few clean up/rearrange changes, somewhat inspired from openbsd's
schizo.c:

- rename pp_busnode{} -> spc_busnode{}, and move it to
sparc_pci_chipset{}

- move public pci functions pci_conf_read(), pci_conf_write() and
pci_intr_establish() into psycho.c, renaming them in the process,
and add pointers through sparc_pci_chipset{} to access them.
as part of this, add PDB_INTMAP and PDB_CONF debug options to
psycho.c

- move and rename sparc64 private pci_find_ino() into
sparc_pci_chipset{}, like the above

- update psycho_alloc_chipset() to set the new 4 function members


no functional change intended. XXX: not tested on cardbus.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.59 30-May-2008 ad

branches: 1.59.4; 1.59.6;
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.58 29-May-2008 mrg

remove clause #3 from my license where there are no other
copyright holders involved.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.57 24-Mar-2008 cube

branches: 1.57.2; 1.57.4; 1.57.6;
Change previous to use aprint_error_dev.


# 1.56 23-Mar-2008 macallan

use device_xname()


Revision tags: keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.55 03-Feb-2008 martin

branches: 1.55.6;
Do not panic when trying to disestablish a pci interrupt.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base nick-csl-alignment-base matt-mips64-base yamt-idlelwp-base8 ppcoea-renovation-base thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.54 04-Apr-2007 tnn

branches: 1.54.14; 1.54.20;
pci_find_ino(): Use interrupt pin from pci_attach_args when mapping interrupts.
Use *ihp as a pure output. Fix case where interrupt pin #D was incorrectly
mapped. Some cosmetic changes while here. Ok'd by martin.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 newlock2-base netbsd-4-base
# 1.53 21-Oct-2006 mrg

branches: 1.53.4; 1.53.8; 1.53.10;
remove "struct cacheline" and the "cacheline" variable. (it was only set
in cpu_attach(), overwritten by multiple cpus, and only one member of the
12 or more were ever used again.) add an ecache_min_line_size to replace
this functionality.

clean up some non-SMP friendly code from cpu_attach():
- only reset the fpu state on the boot cpu
- don't bother printing "FPU version 0" always
- don't call getver() and ignore the result
- print the UPA id on the first cpu0: line

only print mp_tramp address #ifdef DEBUG.

reset the fpu state in cpu_hatch(), like cpu_attach() does for the boot cpu.


cpu_attach() is now free of SMP-unfriendly code.


# 1.52 15-Oct-2006 martin

Missing initializers


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.51 11-Feb-2006 cdi

branches: 1.51.14; 1.51.16;
ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.


# 1.50 11-Dec-2005 christos

branches: 1.50.2; 1.50.4; 1.50.6;
merge ktrace-lwp.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 yamt-readahead-base3 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 yamt-readahead-base2 netbsd-3-0-RC2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base netbsd-3-0-RC1 yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base ktrace-lwp-base
# 1.49 17-Aug-2004 drochner

branches: 1.49.12;
make PCI devices attachable/detachable (as far as the particular drivers
allow), and allow to rescan a bus selectively (ie only the device/
function I'm looking at)


# 1.48 29-Jul-2004 drochner

give the special PCI bus enumerator a sparc64_ prefix and make the
PCI_MACHDEP_ENUMERATE_BUS macro point to it


# 1.47 11-Jun-2004 petrov

pci_find_ino: support pci-pci bridges.


# 1.46 04-Apr-2004 nakayama

Revert a part of rev. 1.44.

OF_getprop can get only the first "reg" property with a statically
allocated buffer, but prom_getprop cannot.
This should fix a "kernel trap 30: data access exception" when you
invoke a pcictl(8).


Revision tags: netbsd-2-0-base
# 1.45 28-Mar-2004 nakayama

branches: 1.45.2;
Set prom_getprop args correctly.


# 1.44 21-Mar-2004 pk

Some more promlib interface conversions.


# 1.43 21-Mar-2004 pk

Two commas went missing in last commit.


# 1.42 21-Mar-2004 pk

Partial switch to the promlib interface.


# 1.41 21-Jan-2004 petrov

For pci devices without ofw mapping find ino by pci bus/slot/device
information, from OpenBSD.


# 1.40 09-Nov-2003 martin

Nuke bcopy/bzero.


# 1.39 22-Aug-2003 petrov

Cosmetic: move DEBUG defines.


# 1.38 15-Jul-2003 lukem

__KERNEL_RCSID()


# 1.37 05-May-2003 martin

branches: 1.37.2;
When overwriting the cache line size configuration, do not use the magic
value 0x10, but instead calculate a line size that is properly aligned
to the IOMMU strbuf cache and our external cache line size.
From FreeBSD.


# 1.36 04-May-2003 martin

Move the bus speed query code into it's own function and make it default
to 33 MHz. Cosmetics, no functional change.


# 1.35 22-Mar-2003 nakayama

PCI-CardBus bridge support for sparc64:
- handle devices which has no OBP node.
- move PCI latency-timer initialization from pci_intr_map to
pci_enumerate_bus.
- make PCI bus free space extents for cardbus devices.
- fix PCI config space map size.
- some code integrations.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.34 10-Dec-2002 pk

Remove the `flags' argument from bus_intr_establish().


Revision tags: kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.33 28-Sep-2002 martin

Set the PCI latency timer for bus master devices.

Slightly different to the patch suggested by Takeshi Nakayama in PR 18451
(idea from FreeBSD).

Additional input from Jason Thorpe: do not hard code the bus frequency,
instead get it from OpenFirmware.


Revision tags: gehenna-devsw-base
# 1.32 29-Jun-2002 eeh

Turn on parity checking for the PCI bus.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.31 16-May-2002 eeh

branches: 1.31.2;
Make the PCI code actually work.


# 1.30 16-May-2002 thorpej

branches: 1.30.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.


# 1.29 15-May-2002 thorpej

Garbage-collect __PCI_DEV_FUNCORDER.


# 1.28 15-May-2002 thorpej

Implement pci_decompose_tag().


# 1.27 06-May-2002 eeh

Add ofpci_make_tag().


Revision tags: eeh-devprop-base
# 1.26 20-Mar-2002 eeh

Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.


Revision tags: newlock-base ifpoll-base thorpej-mips-cache-base
# 1.25 17-Oct-2001 thorpej

branches: 1.25.4;
Fix the semantics of __PCI_DEV_FUNCORDER so that they're actually useful:
If __PCI_DEV_FUNCORDER is defined, don't do the song-and-dance to check if
a device is multi-function; machdep code is going to tell us exactly which
functions to probe.

Note this required changing how pci_func_devorder() works in the
sparc64 PCI machdep code; now the "curnode" is assumed to point
to the bus, rather than some function (typically 0) on the device,
just as pci_bus_devorder() makes that assumption.

All this should allow the PCI code to actually locate the second
HME device on a Sun Netra t1, which is at 3,1 -- previously, the
PCI code would have missed it because there is no device at 3,0.

(Sun deserves a brick to the head for this one -- this seems clearly
out of line with the PCI spec.)


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.24 15-Sep-2001 mrg

in pci_conf_read() and pci_conf_write(), convert all printf()'s to only
occur if SPDB_CONF (and hence DEBUG). also convert the panic in
pci_conf_write() to a SPDB_CONF warning and a return.

this cleans up pcictl(8) support.


Revision tags: thorpej-devvp-base
# 1.23 23-Aug-2001 eeh

branches: 1.23.2;
Fix backwards compare. (From Jason Wright)


# 1.22 20-Jul-2001 eeh

PCI overhaul.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.21 21-Mar-2001 mrg

branches: 1.21.2;
adapt to systems with out interrupt-map & interrupt-map-mask properties.


# 1.20 06-Mar-2001 mrg

rework pci_attach_hook() to just deal with the INO, not the full
interrupt number. properly find interrupts for the E250. modify
pci_intr_map() accordingly. retire psycho_intr_map(). deal with
INO values upto 0x3f, not upto 0x32. restructure sabre_init() and
psycho_init() to be more similar, and display each psycho's IGN.
psycho_intr_establish() deals with INO upto 0x3f, values from 0x32
and higher get 0 for IPL.

tested on E250 & U5.


# 1.19 02-Mar-2001 mrg

branches: 1.19.2;
use pci_bus_devorder() and pci_dev_funcorder()


# 1.18 19-Jan-2001 martin

Enable IO space mapping by default.
Fixes PR 11940.


# 1.17 14-Jan-2001 martin

Fix format warnings to make it compile again.


# 1.16 28-Dec-2000 sommerfeld

Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q


# 1.15 26-Jul-2000 pk

On-board devices on psycho machines seem to have the `interrupt' property
in the parent bus format (i.e. an INO) rather than being represented as
an PCI interrupt line. Provide a hack to work around this in pci_attach_hook().


Revision tags: mrg-merge-1-5-top
# 1.14 18-Jul-2000 pk

Use probeget() in pci_config_read() for the psycho, to avoid bus
faults when probing PCI space.


# 1.13 09-Jul-2000 pk

Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.


# 1.12 29-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


# 1.11 26-Jun-2000 mrg

remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.


Revision tags: netbsd-1-5-base
# 1.10 18-Jun-2000 mrg

branches: 1.10.2;
kill dead code.


# 1.9 08-Jun-2000 eeh

Turn on PCI MEM and DMA.


# 1.8 04-Jun-2000 cgd

Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).


Revision tags: minoura-xpg4dl-base
# 1.7 24-May-2000 eeh

branches: 1.7.2;
Use the PCI function code to distinguish simba bus A from bus B instead
of the current hack.


# 1.6 17-May-2000 mrg

add a note about US IIi and PCI_INTERRUPT_LINE register


# 1.5 08-Apr-2000 mrg

- store the ebus's parent so we can find the IOMMU
- use generic iommu routines in the ebus code (uses the above)
- add some more comments.


# 1.4 05-Apr-2000 mrg

clean this up some.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.3 05-Jun-1999 eeh

branches: 1.3.2; 1.3.4;
Make pbrobeget() and probeset() work for 64-bit values as well. To do this
the arguments are changed so the address is first and the ASI second so we
can have the address in %o0:%o1 and not worry about unused registers.

Also a bit of copyright cleanup.


# 1.2 05-Jun-1999 mrg

clean up a bit, implement pci_conf_{read,write}() with probe[gs]et() (not yet used).


# 1.1 04-Jun-1999 mrg

PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...