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 *
| 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: head/sys/dev/ed/if_ed_pci.c 50477 1999-08-28 01:08:13Z peter $
| 20 * $FreeBSD: head/sys/dev/ed/if_ed_pci.c 50852 1999-09-03 19:10:56Z peter $
|
21 */ 22 23#include <sys/param.h> 24#include <sys/systm.h>
| 21 */ 22 23#include <sys/param.h> 24#include <sys/systm.h>
|
25#include <sys/malloc.h>
| 25#include <sys/socket.h>
|
26#include <sys/kernel.h>
| 26#include <sys/kernel.h>
|
| 27#include <sys/module.h> 28#include <sys/bus.h> 29#include <machine/bus.h> 30
|
27#include <pci/pcireg.h> 28#include <pci/pcivar.h> 29
| 31#include <pci/pcireg.h> 32#include <pci/pcivar.h> 33
|
30#include "ed.h"
| 34#include <net/if.h> 35#include <net/if_arp.h> 36#include <net/if_mib.h>
|
31
| 37
|
| 38#include <i386/isa/if_edvar.h> 39
|
32static struct _pcsid 33{
| 40static struct _pcsid 41{
|
34 pcidi_t type; 35 char *desc;
| 42 u_int32_t type; 43 const char *desc;
|
36} pci_ids[] = 37{ 38 { 0x802910ec, "NE2000 PCI Ethernet (RealTek 8029)" }, 39 { 0x50004a14, "NE2000 PCI Ethernet (NetVin 5000)" }, 40 { 0x09401050, "NE2000 PCI Ethernet (ProLAN)" }, 41 { 0x140111f6, "NE2000 PCI Ethernet (Compex)" }, 42 { 0x30008e2e, "NE2000 PCI Ethernet (KTI)" }, 43 { 0x19808c4a, "NE2000 PCI Ethernet (Winbond W89C940)" }, 44 { 0x0e3410bd, "NE2000 PCI Ethernet (Surecom NE-34)" }, 45 { 0x09261106, "NE2000 PCI Ethernet (VIA VT86C926)" }, 46 { 0x00000000, NULL } 47}; 48
| 44} pci_ids[] = 45{ 46 { 0x802910ec, "NE2000 PCI Ethernet (RealTek 8029)" }, 47 { 0x50004a14, "NE2000 PCI Ethernet (NetVin 5000)" }, 48 { 0x09401050, "NE2000 PCI Ethernet (ProLAN)" }, 49 { 0x140111f6, "NE2000 PCI Ethernet (Compex)" }, 50 { 0x30008e2e, "NE2000 PCI Ethernet (KTI)" }, 51 { 0x19808c4a, "NE2000 PCI Ethernet (Winbond W89C940)" }, 52 { 0x0e3410bd, "NE2000 PCI Ethernet (Surecom NE-34)" }, 53 { 0x09261106, "NE2000 PCI Ethernet (VIA VT86C926)" }, 54 { 0x00000000, NULL } 55}; 56
|
49extern void *ed_attach_NE2000_pci __P((int, int));
| 57extern int ed_attach_NE2000_pci __P((device_t dev, int));
|
50
| 58
|
51static const char* ed_pci_probe __P((pcici_t tag, pcidi_t type)); 52static void ed_pci_attach __P((pcici_t config_id, int unit));
| 59static int ed_pci_probe __P((device_t)); 60static int ed_pci_attach __P((device_t));
|
53
| 61
|
54static u_long ed_pci_count = NED; 55 56static struct pci_device ed_pci_driver = { 57 "ed", 58 ed_pci_probe, 59 ed_pci_attach, 60 &ed_pci_count, 61 NULL 62}; 63 64COMPAT_PCI_DRIVER (ed_pci, ed_pci_driver); 65 66static const char* 67ed_pci_probe (pcici_t tag, pcidi_t type)
| 62static int 63ed_pci_probe (device_t dev)
|
68{
| 64{
|
| 65 u_int32_t type = pci_get_devid(dev);
|
69 struct _pcsid *ep =pci_ids; 70 71 while (ep->type && ep->type != type) 72 ++ep;
| 66 struct _pcsid *ep =pci_ids; 67 68 while (ep->type && ep->type != type) 69 ++ep;
|
73 return (ep->desc);
| 70 if (ep->desc) { 71 device_set_desc(dev, ep->desc); 72 return 0; 73 } else { 74 return ENXIO; 75 }
|
74} 75
| 76} 77
|
76void edintr_sc (void*); 77 78static void 79ed_pci_attach(config_id, unit) 80 pcici_t config_id; 81 int unit;
| 78static int 79ed_pci_attach(device_t dev)
|
82{
| 80{
|
83 int io_port; 84 void *ed; /* device specific data ... */
| 81 return ed_attach_NE2000_pci(dev, PCIR_MAPS); 82}
|
85
| 83
|
86 io_port = pci_conf_read(config_id, PCI_MAP_REG_START) & ~PCI_MAP_IO;
| 84static device_method_t ed_pci_methods[] = { 85 /* Device interface */ 86 DEVMETHOD(device_probe, ed_pci_probe), 87 DEVMETHOD(device_attach, ed_pci_attach),
|
87
| 88
|
88 ed = ed_attach_NE2000_pci(unit, io_port); 89 if (!ed) 90 return;
| 89 { 0, 0 } 90};
|
91
| 91
|
92 if(!(pci_map_int(config_id, edintr_sc, (void *)ed, &net_imask))) { 93 free (ed, M_DEVBUF); 94 return; 95 }
| 92static driver_t ed_pci_driver = { 93 "ed", 94 ed_pci_methods, 95 sizeof(struct ed_softc), 96};
|
96
| 97
|
97 return; 98}
| 98static devclass_t ed_devclass; 99 100DRIVER_MODULE(ed, pci, ed_pci_driver, ed_devclass, 0, 0);
|
| |