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/isa/ofw_isa.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) 1999, 2000 Matthew R. Green
    3  * Copyright (c) 2001, 2003 Thomas Moestl <tmm@FreeBSD.org>
    4  * All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. The name of the author may not be used to endorse or promote products
   15  *    derived from this software without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   22  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
   24  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   25  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  *      from: NetBSD: ebus.c,v 1.26 2001/09/10 16:27:53 eeh Exp
   30  */
   31 
   32 #include <sys/cdefs.h>
   33 __FBSDID("$FreeBSD: releng/8.1/sys/sparc64/isa/ofw_isa.c 202234 2010-01-13 20:35:27Z marius $");
   34 
   35 /*
   36  * Helper functions which can be used in both ISA and EBus code.
   37  */
   38 
   39 #include <sys/param.h>
   40 #include <sys/systm.h>
   41 #include <sys/bus.h>
   42 
   43 #include <dev/ofw/ofw_bus_subr.h>
   44 #include <dev/ofw/openfirm.h>
   45 
   46 #include <machine/bus.h>
   47 #include <machine/resource.h>
   48 
   49 #include <sparc64/pci/ofw_pci.h>
   50 #include <sparc64/isa/ofw_isa.h>
   51 
   52 #include "pcib_if.h"
   53 
   54 int
   55 ofw_isa_range_restype(struct isa_ranges *range)
   56 {
   57         int ps = ISA_RANGE_PS(range);
   58 
   59         switch (ps) {
   60         case OFW_PCI_CS_IO:
   61                 return (SYS_RES_IOPORT);
   62         case OFW_PCI_CS_MEM32:
   63                 return (SYS_RES_MEMORY);
   64         default:
   65                 panic("ofw_isa_range_restype: illegal space %x", ps);
   66         }
   67 
   68 }
   69 
   70 /* XXX: this only supports PCI as parent bus right now. */
   71 int
   72 ofw_isa_range_map(struct isa_ranges *range, int nrange, u_long *start,
   73     u_long *end, int *which)
   74 {
   75         struct isa_ranges *r;
   76         uint64_t offs, cstart, cend;
   77         int i;
   78 
   79         for (i = 0; i < nrange; i++) {
   80                 r = &range[i];
   81                 cstart = ISA_RANGE_CHILD(r);
   82                 cend = cstart + r->size - 1;
   83                 if (*start < cstart || *start > cend)
   84                         continue;
   85                 if (*end < cstart || *end > cend) {
   86                         panic("ofw_isa_map_iorange: iorange crosses PCI "
   87                             "ranges (%#lx not in %#lx - %#lx)", *end, cstart,
   88                             cend);
   89                 }
   90                 offs = ISA_RANGE_PHYS(r);
   91                 *start = *start + offs - cstart;
   92                 *end  = *end + offs - cstart;
   93                 if (which != NULL)
   94                         *which = i;
   95                 return (ofw_isa_range_restype(r));
   96         }
   97         panic("ofw_isa_map_iorange: could not map range %#lx - %#lx",
   98             *start, *end);
   99 }
  100 
  101 ofw_pci_intr_t
  102 ofw_isa_route_intr(device_t bridge, phandle_t node, struct ofw_bus_iinfo *ii,
  103     ofw_isa_intr_t intr)
  104 {
  105         struct isa_regs reg;
  106         uint8_t maskbuf[sizeof(reg) + sizeof(intr)];
  107         device_t pbridge;
  108         ofw_isa_intr_t mintr;
  109 
  110         pbridge = device_get_parent(device_get_parent(bridge));
  111         /*
  112          * If we get a match from using the map, the resulting INO is
  113          * fully specified, so we may not continue to map.
  114          */
  115         if (!ofw_bus_lookup_imap(node, ii, &reg, sizeof(reg),
  116             &intr, sizeof(intr), &mintr, sizeof(mintr), maskbuf)) {
  117                 /* Try routing at the parent bridge. */
  118                 mintr = PCIB_ROUTE_INTERRUPT(pbridge, bridge, intr);
  119         }
  120         return (mintr);
  121 }

Cache object: c2f9dc4d410612540cb59a22c9bd40ba


[ 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.