Home | History | Annotate | Download | only in pci
History log of /src/sys/arch/ofppc/pci/ofwpci.c
RevisionDateAuthorComments
 1.21  07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.20  12-May-2021  thorpej branches: 1.20.4;
Pass along our device handle to the PCI bus instance we attach.
 1.19  24-Apr-2021  thorpej branches: 1.19.2; 1.19.4;
Merge thorpej-cfargs branch:

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

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

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

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

...and a sentinel value CFARG_EOL.

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

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.18  21-Nov-2020  thorpej branches: 1.18.2;
malloc(9) -> kmem(9)
 1.17  07-Jul-2020  thorpej branches: 1.17.2;
Overhaul the interface to pci_configure_bus():
- Don't expose how PCI bus configuration resource management is implemented.
Provide a new resource provider API:

==> pciconf_resource_init() -- Initialize a PCI configuration resources
container.
==> pciconf_resource_add() -- Add a PCI configuration resource to the
container (I/O, MEM, or prefetchable MEM). Multiple resources of
each type may be added.
==> pciconf_resource_fini() -- Tear down the PCI configurtation resources
container once the bus has been configured.

This is much easier to use than the previous method of providing an
extent map for each kind of resource, and works better for e.g. ACPI
platforms that provide potentially multiple PCI resources in tables
provided by firmware.

- Re-implement PCI configuration resource management using vmem arenas,
rather than extent maps.
 1.16  14-Jun-2020  chs replace EX_NOWAIT with EX_WAITOK in device attach methods.
remove checks for failures that can no longer occur.
 1.15  10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.14  11-Jan-2017  christos branches: 1.14.16;
PR/51827: David Binderman: delete pointless local variable
 1.13  19-Oct-2016  nonaka Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.12  28-Feb-2014  matt branches: 1.12.6; 1.12.10;
Use PRIxPTR
 1.11  27-Jan-2012  para branches: 1.11.6; 1.11.10;
converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.10  18-Jun-2011  matt branches: 1.10.2; 1.10.6;
struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.9  17-May-2011  dyoung branches: 1.9.2;
PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

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

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

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.8  28-Apr-2008  martin branches: 1.8.22; 1.8.28;
Remove clause 3 and 4 from TNF licenses
 1.7  08-Apr-2008  garbled branches: 1.7.2; 1.7.4;
SMP support for ofppc. (finally) Much thanks to Matt Thomas for help in
figuring out all the crazy nuances of getting this working, and to
Michael Lorenz for testing/fixing my changes on macppc. Tested with a
quad-proc 7044-270.
Summary of changes:

Bumped CPU_MAXNUM to 16 on ofppc.
Added md_* routines to ofppc/cpu.c, to sync the timebase, and awaken the CPUs.
Fixed a bug in the test for a 64bit bridge cpu early in locore.S
Added code to set the interrupt priority for all CPUs with an openpic.
Change rtas to probe before cpus, to allow use of the rtas freeze/thaw
timebase code routines.
Fix CPU_INFO_FOREACH macro to iterate through detected cpus, not CPU_MAXNUM.
Change most uses of ci_cpuid to ci_index, to deal with CPUs that do not allow
writing to SPR_PIR. Don't write SPR_PIR unless the secondary cpu identifies
itself as 0.
Change the hatchstack/interrupt stack allocations to allocate a 8192byte
interrupt stack, and a 4096 byte hatch stack, align them to 16 bytes, and
allocate them no lower than 0x10000. Allocate them separately to prevent the
hatch stack corrupting the interrupt stack later on.
If the CPU is a 64bit cpu, copy SPR_ASR in cpu_hatch()
Set the idle stack to ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_sp.
Add OF_start_cpu(). Add a routine to ofwoea_initppc to spin up secondary
procs early, and place them into a spinloop waiting for the hatch routines
to be ready.
Modify the ipi routines to deal with openpics that reverse byte order on read
from an ipi register. (such as on the 7044)
Change the rtas setup to allocate the rtas physical base address above
the kernel, to avoid mucking up the hatch/interrupt stacks.
 1.6  11-Feb-2008  garbled branches: 1.6.6;
Use model_init to clean up how we decide the ranges for
PCI_NETBSD_CONFIGURE. Add some code to hopefully better handle the
firepower and powerstackII, based on the OFW dumps from those machines.
Untested on those machines, but doesn't break anything on pegasos/7044.
 1.5  17-Jan-2008  garbled Add support to ofppc for the IBM 7044-270 machine. This is a POWER3-II
based machine. Currently the kernel to run on this machine is
incompatible with the standard GENERIC kernel, so for now, we have a
separate GENERIC_B64. Eventually, I hope to combine the two.

Please note, this is a port of 32bit ofppc, not a powerpc64 port.

Thanks to Matt Thomas and Kevin Bowling for helping to make this port
possible.

Summary of changes:

Change ofwpci to use the ofmethod config for configuring the PCI bus,
rather than indirect configuration.
Move the wiring of the interrupt controllers from at the start of the
boot, into the configuration of the first PCI bus.
Rewrite the map_isa_ioregs() hack to work on a machine without BATs
Fix a ton of bugs in the genofw_find_pics routine, and in the map_space code.
Split the pic_openpic into openpic_common and pic_openpic.
Create a new pic_distopenpic driver, for the distributed openpic found on
some newer IBM machines.
Fix a bad panic in pmap_extract on 64bit bridge mode
 1.4  26-Oct-2007  garbled branches: 1.4.2; 1.4.4; 1.4.6; 1.4.12;
Add code to properly detect the interrupt mapping on the PegasosII, and any
other OFW machine that fails our first two methods.
 1.3  25-Oct-2007  garbled Add a bunch of fixes and minor rewrites to ofppc to bring it closer to
working properly. This is still a work in progress, and all work so far
has been based on the PegasosII machne.

1) Rewrite how the ISA memory and IO space maps are found. More work
will still need to be done in this area.
2) Add a new OFW method of pci configuration. So far I can only get this
to work on the primary PCI bus on the Pegasos. Unsure if this is a
pegasos bug or a code bug.
3) Add the rtas device to ofppc, and add an "rtas_reboot" function to
rtas to allow me to reboot the PegasosII. The rtas driver works, and is
a great start but needs to be changed slightly to allow easier access to
the functions from outside the driver.
4) Fix a number of bugs that existed in the shared PCI code for ofw that
probably weren't tickled by macppc.

There is much much more left to do here, this is all still a work in
progress, but this commit will allow other people to play around with the
code if they want to.
 1.2  17-Oct-2007  garbled branches: 1.2.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.1  21-Jun-2007  garbled branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
file ofwpci.c was initially added on branch ppcoea-renovation.
 1.1.10.2  13-Nov-2007  bouyer Sync with HEAD
 1.1.10.1  25-Oct-2007  bouyer Sync with HEAD.
 1.1.8.1  18-Oct-2007  yamt sync with head.
 1.1.6.2  28-Oct-2007  joerg Sync with HEAD.
 1.1.6.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.1  21-Jun-2007  garbled Completely rewrite ofppc from scratch.

1) Change it to be like the other ppc ports, and directly interface with
hardware, rather than trying to be slick and access everything through
the OFW. Instead, we gather configuration information from OFW, and use
that to discover hardware.

2) Change it over to powerpc bus_space and bus_dma.

3) Timecounters, generic soft interrupts.

4) Make use of the shared code in powerpc. (pic code, oea, bat code, etc)

5) Probably other stuff.. almost nothing remains of the original port.

It is assumed that in it's present state this will not run on any
machines. However, it should be pretty close, and will just need some
massaging and care from someone with access to hardware to make it work.
The code is written to target a CHRP compatible machine, but there is no
reason it cannot be ported to other machines like the Pegasos or Efika.
I simply don't have the knowledge of those machines to structure the code
for them, but I have attempted to keep it generic enough that such work
could still be done.

If anyone with access to hardware would like to take this on, I will
gladly assist as much as possible.
 1.2.2.3  03-Dec-2007  ad Sync with HEAD.
 1.2.2.2  23-Oct-2007  ad Sync with head.
 1.2.2.1  17-Oct-2007  ad file ofwpci.c was added on branch vmlocking on 2007-10-23 20:36:01 +0000
 1.4.12.1  19-Jan-2008  bouyer Sync with HEAD
 1.4.6.3  23-Mar-2008  matt sync with HEAD
 1.4.6.2  06-Nov-2007  matt sync with HEAD
 1.4.6.1  26-Oct-2007  matt file ofwpci.c was added on branch matt-armv6 on 2007-11-06 23:20:04 +0000
 1.4.4.1  18-Feb-2008  mjf Sync with HEAD.
 1.4.2.4  27-Feb-2008  yamt sync with head.
 1.4.2.3  21-Jan-2008  yamt sync with head
 1.4.2.2  27-Oct-2007  yamt sync with head.
 1.4.2.1  26-Oct-2007  yamt file ofwpci.c was added on branch yamt-lazymbuf on 2007-10-27 11:27:31 +0000
 1.6.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.7.4.1  16-May-2008  yamt sync with head.
 1.7.2.1  18-May-2008  yamt sync with head.
 1.8.28.1  06-Jun-2011  jruoho Sync with HEAD.
 1.8.22.1  31-May-2011  rmind sync with head
 1.9.2.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.6.1  18-Feb-2012  mrg merge to -current.
 1.10.2.2  22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.2.1  17-Apr-2012  yamt sync with head
 1.11.10.1  18-May-2014  rmind sync with head
 1.11.6.2  03-Dec-2017  jdolecek update from HEAD
 1.11.6.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.10.2  20-Mar-2017  pgoyette Sync with HEAD
 1.12.10.1  04-Nov-2016  pgoyette Sync with HEAD
 1.12.6.2  05-Feb-2017  skrll Sync with HEAD
 1.12.6.1  05-Dec-2016  skrll Sync with HEAD
 1.14.16.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.17.2.1  14-Dec-2020  thorpej Sync w/ HEAD.
 1.18.2.1  23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.19.4.1  31-May-2021  cjep sync with head
 1.19.2.1  13-May-2021  thorpej Sync with HEAD.
 1.20.4.1  04-Aug-2021  thorpej Adapt to CFARGS().

RSS XML Feed