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/pci/if_sr_p.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) 1996 John Hay.
    3  * Copyright (c) 1996 SDL Communications, Inc.
    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. Neither the name of the author nor the names of any co-contributors
   15  *    may be used to endorse or promote products derived from this software
   16  *    without specific prior written permission.
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   28  * SUCH DAMAGE.
   29  *
   30  * $FreeBSD$
   31  */
   32 
   33 #include "pci.h"
   34 #if NPCI > 0
   35 
   36 #include "sr.h"
   37 
   38 #include <sys/param.h>
   39 #include <sys/systm.h>
   40 #include <sys/kernel.h>
   41 #include <sys/malloc.h>
   42 
   43 #include <pci/pcivar.h>
   44 
   45 #ifndef BUGGY
   46 #define BUGGY           0
   47 #endif
   48 
   49 /*
   50  * The must match with the real functions in if_sr.c
   51  */
   52 extern void *srattach_pci(int unit,
   53                           vm_offset_t plx_vaddr,
   54                           vm_offset_t sca_vaddr);
   55 extern void srintr_hc(void *hc);
   56 
   57 static const char *sr_pci_probe(pcici_t tag, pcidi_t type);
   58 static void sr_pci_attach(pcici_t config_id, int unit);
   59 
   60 static u_long src_count = NSR;
   61 
   62 static struct pci_device sr_pci_driver =
   63 {
   64         "src",
   65         sr_pci_probe,
   66         sr_pci_attach,
   67         &src_count,
   68         NULL};
   69 
   70 DATA_SET (pcidevice_set, sr_pci_driver);
   71 
   72 static const char *
   73 sr_pci_probe(pcici_t tag, pcidi_t type)
   74 {
   75         switch(type) {
   76         case 0x556812aa:
   77                 return ("RISCom/N2pci");
   78                 break;
   79         case 0x55684778:
   80         case 0x55684877:
   81                 /*
   82                  * XXX This can probably be removed sometime.
   83                  */
   84                 return ("RISCom/N2pci (old id)");
   85                 break;
   86         default:
   87                 break;
   88         }
   89         return (0);
   90 }
   91 
   92 static void
   93 sr_pci_attach(pcici_t config_id, int unit)
   94 {
   95         void *hc;
   96 #if BUGGY > 0
   97         u_int *fecr;
   98 #endif
   99         vm_offset_t plx_vaddr, plx_paddr, sca_vaddr, sca_paddr;
  100 
  101 #if BUGGY > 0
  102         printf("srp: ID %x\n", pci_conf_read(config_id, 0));
  103         printf("srp: BADR0 %x\n", pci_conf_read(config_id, 0x10));
  104         printf("srp: BADR1 %x\n", pci_conf_read(config_id, 0x18));
  105 #endif
  106         if(!pci_map_mem(config_id, 0x10, &plx_vaddr, &plx_paddr)) {
  107                 printf("srp: map failed.\n");
  108                 return;
  109         }
  110 #if BUGGY > 0
  111         printf("srp: vaddr %x, paddr %x\n", plx_vaddr, plx_paddr);
  112 #endif
  113         if(!pci_map_mem(config_id, 0x18, &sca_vaddr, &sca_paddr)) {
  114                 printf("srp: map failed.\n");
  115                 return;
  116         }
  117 #if BUGGY > 0
  118         printf("srp: vaddr %x, paddr %x\n", sca_vaddr, sca_paddr);
  119         fecr = (u_int *)(sca_vaddr + 0x200);
  120         printf("srp: FECR  %x\n", *fecr);
  121 #endif
  122 
  123         hc = srattach_pci(unit, plx_vaddr, sca_vaddr);
  124         if(!hc)
  125                 return;
  126 
  127         if(!pci_map_int(config_id, srintr_hc, (void *)hc, &net_imask)) {
  128                 free(hc, M_DEVBUF);
  129                 return;
  130         }
  131 }
  132 
  133 #endif /* NPCI > 0 */

Cache object: b533a6a4b093140f2c3ac3720ab8a5d6


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