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_lnc_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  *
    3  * Copyright (c) 1996 Stefan Esser <se@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 immediately at the beginning of the file, without modification,
   11  *    this list of conditions, and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. Absolutely no warranty of function or purpose is made by the author
   16  *    Stefan Esser.
   17  * 4. Modifications may be freely made to this file if the above conditions
   18  *    are met.
   19  *
   20  * $FreeBSD$
   21  */
   22 
   23 #include "pci.h"
   24 #if NPCI > 0
   25 
   26 #include <sys/param.h>
   27 #include <sys/systm.h>
   28 #include <sys/malloc.h>
   29 #include <sys/kernel.h>
   30 #include <pci/pcireg.h>
   31 #include <pci/pcivar.h>
   32 
   33 #include "lnc.h"
   34 
   35 #define PCI_DEVICE_ID_PCNet_PCI         0x20001022
   36 #define PCI_DEVICE_ID_PCHome_PCI        0x20011022
   37 
   38 extern void *lnc_attach_ne2100_pci __P((int unit, unsigned iobase));
   39 
   40 static const char* lnc_pci_probe __P((pcici_t tag, pcidi_t type));
   41 static void lnc_pci_attach __P((pcici_t config_id, int unit));
   42 
   43 static u_long lnc_pci_count = NLNC;
   44 
   45 static struct pci_device lnc_pci_driver = {
   46         "lnc",
   47         lnc_pci_probe,
   48         lnc_pci_attach,
   49         &lnc_pci_count,
   50         NULL
   51 };
   52 
   53 DATA_SET (pcidevice_set, lnc_pci_driver);
   54 
   55 static const char*
   56 lnc_pci_probe (pcici_t tag, pcidi_t type)
   57 {
   58         switch(type) {
   59         case PCI_DEVICE_ID_PCNet_PCI:
   60                 return ("PCNet/PCI Ethernet adapter");
   61                 break;
   62         case PCI_DEVICE_ID_PCHome_PCI:
   63                 return ("PCHome/PCI Ethernet adapter");
   64                 break;
   65         default:
   66                 break;
   67         }
   68         return (0);
   69 }
   70 
   71 void lncintr_sc (void*);
   72 
   73 static void
   74 lnc_pci_attach(config_id, unit)
   75         pcici_t config_id;
   76         int     unit;
   77 {
   78         unsigned iobase;
   79         unsigned data;  /* scratch to make this device a bus master*/
   80         void *lnc; /* device specific data for interrupt handler ... */
   81 
   82         if ( !pci_map_port(config_id,PCI_MAP_REG_START,(u_short *)&iobase) )
   83             printf("lnc%d: pci_port_map_attach failed?!\n",unit);
   84 
   85 
   86         /* Make this device a bus master.  This was implictly done by 
   87            pci_map_port under 2.2.x -- tvf */
   88 
   89         data = pci_cfgread(config_id, PCIR_COMMAND, 4);
   90         data |= PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN;
   91         pci_cfgwrite(config_id, PCIR_COMMAND, data, 4);
   92 
   93         lnc = lnc_attach_ne2100_pci(unit, iobase);
   94 
   95         if (!lnc)
   96                 return;
   97         if(!(pci_map_int(config_id, lncintr_sc, (void *)lnc, &net_imask))) {
   98                 free (lnc, M_DEVBUF);
   99                 return;
  100         }
  101 
  102         return;
  103 }
  104 
  105 #endif /* NPCI > 0 */
  106 

Cache object: e5ac4f8a0b8ba82b241feb3491bd9b91


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