RTEMS: probe for PCI varient of NE2000 NIC

Provided by QEMU
This commit is contained in:
Michael Davidsaver
2015-06-20 09:05:28 -04:00
committed by Michael Davidsaver
parent c8b60e0f1b
commit aace975de1
3 changed files with 71 additions and 1 deletions

View File

@@ -21,6 +21,10 @@ rtemsCom_SRCS += epicsRtemsInitHookPre.c
rtemsCom_SRCS += epicsRtemsInitHookPost.c
rtemsCom_SRCS += epicsMemFs.c
ifeq ($(T_A),RTEMS-pc386)
rtemsCom_SRCS += ne2kpci.c
endif
LIBRARY_RTEMS = rtemsCom
include $(TOP)/configure/RULES

View File

@@ -0,0 +1,58 @@
/*************************************************************************\
* Copyright (c) 2015 Brookhaven Science Associates, as Operator of
* Brookhaven National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*
* Wrapper around the ISA ne2000 driver to support detection of the PCI variant.
* Can be used with the ne2k_pci device provided by QEMU.
*
* eg. "qemu-system-i386 ... -net nic,model=ne2k_pci"
*/
#include <stdio.h>
#include <inttypes.h>
#include <bsp.h>
#include <rtems/pci.h>
#include <rtems/rtems_bsdnet.h>
/* The plain ISA driver attach()
* which doesn't (can't?) do any test to see if
* the HW is really present
*/
extern int
rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach);
int
rtems_ne2kpci_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach)
{
uint8_t irq;
uint32_t bar0;
int B, D, F, ret;
printk("Probing for NE2000 on PCI (aka. Realtek 8029)\n");
if(pci_find_device(PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8029, 0, &B, &D, &F))
{
printk("Not found\n");
return 0;
}
printk("Found %d:%d.%d\n", B, D, F);
ret = pci_read_config_dword(B, D, F, PCI_BASE_ADDRESS_0, &bar0);
ret|= pci_read_config_byte(B, D, F, PCI_INTERRUPT_LINE, &irq);
if(ret || (bar0&PCI_BASE_ADDRESS_SPACE)!=PCI_BASE_ADDRESS_SPACE_IO)
{
printk("Failed reading card config\n");
return 0;
}
config->irno = irq;
config->port = bar0&PCI_BASE_ADDRESS_IO_MASK;
printk("Using port=0x%x irq=%u\n", (unsigned)config->port, config->irno);
return rtems_ne_driver_attach(config, attach);
}

View File

@@ -36,11 +36,19 @@ static struct rtems_bsdnet_ifconfig loopback_config = {
* application directory and make the appropriate changes.
*/
#if defined(__i386__)
extern int
rtems_ne2kpci_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach);
static struct rtems_bsdnet_ifconfig ne2k_driver_config = {
"ne2", /* name */
rtems_ne2kpci_driver_attach, /* attach function */
&loopback_config, /* link to next interface */
};
extern int rtems_fxp_attach (struct rtems_bsdnet_ifconfig *, int);
static struct rtems_bsdnet_ifconfig fxp_driver_config = {
"fxp1", /* name */
rtems_fxp_attach, /* attach function */
&loopback_config, /* link to next interface */
&ne2k_driver_config, /* link to next interface */
};
extern int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *, int);
static struct rtems_bsdnet_ifconfig e3c509_driver_config = {