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/dev/ed/if_ed_pci.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 Stefan Esser <se@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 immediately at the beginning of the file, without modification,
   10  *    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. Absolutely no warranty of function or purpose is made by the author
   15  *    Stefan Esser.
   16  * 4. Modifications may be freely made to this file if the above conditions
   17  *    are met.
   18  */
   19 
   20 #include <sys/cdefs.h>
   21 __FBSDID("$FreeBSD$");
   22 
   23 #include <sys/param.h>
   24 #include <sys/systm.h>
   25 #include <sys/socket.h>
   26 #include <sys/kernel.h>
   27 
   28 #include <sys/module.h>
   29 #include <sys/bus.h>
   30 
   31 #include <machine/bus.h>
   32 #include <sys/rman.h>
   33 #include <machine/resource.h>
   34 
   35 #include <net/if.h>
   36 #include <net/if_arp.h>
   37 #include <net/if_mib.h>
   38 
   39 #include <dev/pci/pcireg.h>
   40 #include <dev/pci/pcivar.h>
   41 
   42 #include <dev/ed/if_edvar.h>
   43 
   44 static struct _pcsid
   45 {
   46         uint32_t        type;
   47         const char      *desc;
   48 } pci_ids[] =
   49 {
   50         { 0x802910ec,   "NE2000 PCI Ethernet (RealTek 8029)"    },
   51         { 0x50004a14,   "NE2000 PCI Ethernet (NetVin 5000)"     },
   52         { 0x09401050,   "NE2000 PCI Ethernet (ProLAN)"          },
   53         { 0x140111f6,   "NE2000 PCI Ethernet (Compex)"          },
   54         { 0x30008e2e,   "NE2000 PCI Ethernet (KTI)"             },
   55         { 0x19808c4a,   "NE2000 PCI Ethernet (Winbond W89C940)" },
   56         { 0x0e3410bd,   "NE2000 PCI Ethernet (Surecom NE-34)"   },
   57         { 0x09261106,   "NE2000 PCI Ethernet (VIA VT86C926)"    },
   58         { 0x00000000,   NULL                                    }
   59 };
   60 
   61 static int      ed_pci_probe(device_t);
   62 static int      ed_pci_attach(device_t);
   63 
   64 static int
   65 ed_pci_probe(device_t dev)
   66 {
   67         uint32_t        type = pci_get_devid(dev);
   68         struct _pcsid   *ep =pci_ids;
   69 
   70         while (ep->type && ep->type != type)
   71                 ++ep;
   72         if (ep->desc) {
   73                 device_set_desc(dev, ep->desc);
   74                 return (0);
   75         }
   76         return (ENXIO);
   77 }
   78 
   79 static int
   80 ed_pci_attach(device_t dev)
   81 {
   82         struct  ed_softc *sc = device_get_softc(dev);
   83         int     flags = 0;
   84         int     error;
   85 
   86         error = ed_probe_Novell(dev, PCIR_BAR(0), flags);
   87         if (error)
   88                 return (error);
   89 
   90         error = ed_alloc_irq(dev, 0, RF_SHAREABLE);
   91         if (error) {
   92                 ed_release_resources(dev);
   93                 return (error);
   94         }
   95 
   96         error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
   97                                edintr, sc, &sc->irq_handle);
   98         if (error) {
   99                 ed_release_resources(dev);
  100                 return (error);
  101         }
  102 
  103         error = ed_attach(dev);
  104 
  105         return (error);
  106 }
  107 
  108 static device_method_t ed_pci_methods[] = {
  109         /* Device interface */
  110         DEVMETHOD(device_probe,         ed_pci_probe),
  111         DEVMETHOD(device_attach,        ed_pci_attach),
  112 
  113         { 0, 0 }
  114 };
  115 
  116 static driver_t ed_pci_driver = {
  117         "ed",
  118         ed_pci_methods,
  119         sizeof(struct ed_softc),
  120 };
  121 
  122 DRIVER_MODULE(ed, pci, ed_pci_driver, ed_devclass, 0, 0);
  123 MODULE_DEPEND(ed, pci, 1, 1, 1);
  124 MODULE_DEPEND(ed, ether, 1, 1, 1);

Cache object: e97eba89d8e1771037ce08cd66b9f026


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