From owner-p4-projects@FreeBSD.ORG Tue Mar 2 23:47:35 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8B5BC16A4D0; Tue, 2 Mar 2004 23:47:35 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 624F016A4CE for ; Tue, 2 Mar 2004 23:47:35 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 56F8443D3F for ; Tue, 2 Mar 2004 23:47:35 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i237lZGe081197 for ; Tue, 2 Mar 2004 23:47:35 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i237lYrI081194 for perforce@freebsd.org; Tue, 2 Mar 2004 23:47:34 -0800 (PST) (envelope-from peter@freebsd.org) Date: Tue, 2 Mar 2004 23:47:34 -0800 (PST) Message-Id: <200403030747.i237lYrI081194@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 48042 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Mar 2004 07:47:36 -0000 http://perforce.freebsd.org/chv.cgi?CH=48042 Change 48042 by peter@peter_daintree on 2004/03/02 23:46:57 initial pass at i386->amd64 updates. given no pcibios, large parts of this are going to disappear again, but it keeps an integration record. Affected files ... .. //depot/projects/hammer/sys/amd64/include/pci_cfgreg.h#8 integrate .. //depot/projects/hammer/sys/amd64/pci/pci_bus.c#13 integrate .. //depot/projects/hammer/sys/amd64/pci/pci_cfgreg.c#12 integrate .. //depot/projects/hammer/sys/amd64/pci/pci_pir.c#1 branch Differences ... ==== //depot/projects/hammer/sys/amd64/include/pci_cfgreg.h#8 (text+ko) ==== @@ -45,4 +45,3 @@ int pci_cfgregopen(void); u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); -int pci_cfgintr(int bus, int device, int pin, int oldirq); ==== //depot/projects/hammer/sys/amd64/pci/pci_bus.c#13 (text+ko) ==== @@ -33,18 +33,17 @@ #include #include #include -#include #include #include #include #include #include +#ifdef CPU_ELAN +#include +#endif #include #include -#include -#include -#include #include "pcib_if.h" @@ -432,9 +431,16 @@ int legacy_pcib_attach(device_t dev) { + int bus; - device_add_child(dev, "pci", pcib_get_bus(dev)); - + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); + if (pci_pir_probe(bus, 0)) + pci_pir_parse(); + device_add_child(dev, "pci", bus); return bus_generic_attach(dev); } @@ -612,3 +618,71 @@ static devclass_t pcibus_pnp_devclass; DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + + {0, 0} +}; + +static driver_t pcibios_pcib_driver = { + "pcib", + pcibios_pcib_pci_methods, + sizeof(struct pcib_softc), +}; + +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} ==== //depot/projects/hammer/sys/amd64/pci/pci_cfgreg.c#12 (text+ko) ==== @@ -29,24 +29,15 @@ #include __FBSDID("$FreeBSD: src/sys/amd64/pci/pci_cfgreg.c,v 1.105 2004/01/28 20:46:31 peter Exp $"); -#include /* XXX trim includes */ +#include #include #include -#include -#include -#include #include #include -#include -#include -#include #include #include -#include #include -#include "pcib_if.h" - static int cfgmech; static int devmax; @@ -108,18 +99,6 @@ pcireg_cfgwrite(bus, slot, func, reg, data, bytes); } -/* - * Route a PCI interrupt - */ -int -pci_cfgintr(int bus, int device, int pin, int oldirq) -{ - - printf("pci_cfgintr: can't route an interrupt to %d:%d INT%c without ACPI\n", bus, - device, 'A' + pin - 1); - return (PCI_INVALID_IRQ); -} - /* * Configuration space access using direct register operations */