The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sparc64/pci/ofw_pcib_subr.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2003 by Thomas Moestl <tmm@FreeBSD.org>
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   17  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   18  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   19  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   20  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   21  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   22  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
   23  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   24  */
   25 
   26 #include <sys/cdefs.h>
   27 __FBSDID("$FreeBSD: releng/11.2/sys/sparc64/pci/ofw_pcib_subr.c 259516 2013-12-17 15:11:24Z nwhitehorn $");
   28 
   29 #include "opt_ofw_pci.h"
   30 
   31 #include <sys/param.h>
   32 #include <sys/systm.h>
   33 #include <sys/bus.h>
   34 #include <sys/rman.h>
   35 
   36 #include <dev/ofw/ofw_bus.h>
   37 #include <dev/ofw/ofw_pci.h>
   38 #include <dev/ofw/openfirm.h>
   39 
   40 #include <machine/bus.h>
   41 
   42 #include <dev/pci/pcireg.h>
   43 #include <dev/pci/pcivar.h>
   44 #include <dev/pci/pcib_private.h>
   45 
   46 #include "pcib_if.h"
   47 
   48 #include <sparc64/pci/ofw_pci.h>
   49 #include <sparc64/pci/ofw_pcib_subr.h>
   50 
   51 void
   52 ofw_pcib_gen_setup(device_t bridge)
   53 {
   54         struct ofw_pcib_gen_softc *sc;
   55 
   56         sc = device_get_softc(bridge);
   57         sc->ops_pcib_sc.dev = bridge;
   58         sc->ops_node = ofw_bus_get_node(bridge);
   59         KASSERT(sc->ops_node != 0,
   60             ("ofw_pcib_gen_setup: no ofw pci parent bus!"));
   61 
   62         ofw_bus_setup_iinfo(sc->ops_node, &sc->ops_iinfo,
   63             sizeof(ofw_pci_intr_t));
   64 }
   65 
   66 int
   67 ofw_pcib_gen_route_interrupt(device_t bridge, device_t dev, int intpin)
   68 {
   69         struct ofw_pcib_gen_softc *sc;
   70         struct ofw_bus_iinfo *ii;
   71         struct ofw_pci_register reg;
   72         ofw_pci_intr_t pintr, mintr;
   73 
   74         sc = device_get_softc(bridge);
   75         ii = &sc->ops_iinfo;
   76         if (ii->opi_imapsz > 0) {
   77                 pintr = intpin;
   78                 if (ofw_bus_lookup_imap(ofw_bus_get_node(dev), ii, &reg,
   79                     sizeof(reg), &pintr, sizeof(pintr), &mintr, sizeof(mintr),
   80                     NULL)) {
   81                         /*
   82                          * If we've found a mapping, return it and don't map
   83                          * it again on higher levels - that causes problems
   84                          * in some cases, and never seems to be required.
   85                          */
   86                         return (mintr);
   87                 }
   88         } else if (intpin >= 1 && intpin <= 4) {
   89                 /*
   90                  * When an interrupt map is missing, we need to do the
   91                  * standard PCI swizzle and continue mapping at the parent.
   92                  */
   93                 return (pcib_route_interrupt(bridge, dev, intpin));
   94         }
   95         /* Try at the parent. */
   96         return (PCIB_ROUTE_INTERRUPT(device_get_parent(device_get_parent(
   97             bridge)), bridge, intpin));
   98 }
   99 
  100 phandle_t
  101 ofw_pcib_gen_get_node(device_t bridge, device_t dev)
  102 {
  103         struct ofw_pcib_gen_softc *sc;
  104 
  105         sc = device_get_softc(bridge);
  106         return (sc->ops_node);
  107 }

Cache object: a9df42890e0b67f23dfb46b696019f09


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.