This is Unofficial EPICS BASE Doxygen Site
ne2kpci.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2015 Brookhaven Science Associates, as Operator of
3 * Brookhaven National Laboratory.
4 * EPICS BASE is distributed subject to a Software License Agreement found
5 * in file LICENSE that is included with this distribution.
6 \*************************************************************************/
7 /*
8  * Wrapper around the ISA ne2000 driver to support detection of the PCI variant.
9  * Can be used with the ne2k_pci device provided by QEMU.
10  *
11  * eg. "qemu-system-i386 ... -net nic,model=ne2k_pci"
12  */
13 
14 #include <stdio.h>
15 #include <inttypes.h>
16 #include <bsp.h>
17 #include <rtems/pci.h>
18 #include <rtems/rtems_bsdnet.h>
19 
20 /* The plain ISA driver attach()
21  * which doesn't (can't?) do any test to see if
22  * the HW is really present
23  */
24 extern int
25 rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach);
26 
27 int
28 rtems_ne2kpci_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach)
29 {
30  uint8_t irq;
31  uint32_t bar0;
32  int B, D, F, ret;
33  printk("Probing for NE2000 on PCI (aka. Realtek 8029)\n");
34 
35  if(pci_find_device(PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8029, 0, &B, &D, &F))
36  {
37  printk("Not found\n");
38  return 0;
39  }
40 
41  printk("Found %d:%d.%d\n", B, D, F);
42 
43  ret = pci_read_config_dword(B, D, F, PCI_BASE_ADDRESS_0, &bar0);
44  ret|= pci_read_config_byte(B, D, F, PCI_INTERRUPT_LINE, &irq);
45 
46  if(ret || (bar0&PCI_BASE_ADDRESS_SPACE)!=PCI_BASE_ADDRESS_SPACE_IO)
47  {
48  printk("Failed reading card config\n");
49  return 0;
50  }
51 
52  config->irno = irq;
53  config->port = bar0&PCI_BASE_ADDRESS_IO_MASK;
54 
55  printk("Using port=0x%x irq=%u\n", (unsigned)config->port, config->irno);
56 
57  return rtems_ne_driver_attach(config, attach);
58 }
int rtems_ne2kpci_driver_attach(struct rtems_bsdnet_ifconfig *config, int attach)
Definition: ne2kpci.c:28
int rtems_ne_driver_attach(struct rtems_bsdnet_ifconfig *config, int attach)