summaryrefslogtreecommitdiffstats
path: root/bsps/powerpc/beatnik/net/porting
diff options
context:
space:
mode:
Diffstat (limited to 'bsps/powerpc/beatnik/net/porting')
-rw-r--r--bsps/powerpc/beatnik/net/porting/LICENSE51
-rw-r--r--bsps/powerpc/beatnik/net/porting/Makefile.template84
-rw-r--r--bsps/powerpc/beatnik/net/porting/README104
-rw-r--r--bsps/powerpc/beatnik/net/porting/if_xxx.modini.c34
-rw-r--r--bsps/powerpc/beatnik/net/porting/if_xxx_rtems.c500
-rw-r--r--bsps/powerpc/beatnik/net/porting/pcireg.h405
-rw-r--r--bsps/powerpc/beatnik/net/porting/rtemscompat.h456
-rw-r--r--bsps/powerpc/beatnik/net/porting/rtemscompat1.h219
-rw-r--r--bsps/powerpc/beatnik/net/porting/rtemscompat_defs.h.template97
9 files changed, 1950 insertions, 0 deletions
diff --git a/bsps/powerpc/beatnik/net/porting/LICENSE b/bsps/powerpc/beatnik/net/porting/LICENSE
new file mode 100644
index 0000000000..62b91ab03d
--- /dev/null
+++ b/bsps/powerpc/beatnik/net/porting/LICENSE
@@ -0,0 +1,51 @@
+/* NOTE: The terms described in this LICENSE file apply only to the
+ * files created by the author (see below). Consult individual
+ * file headers for more details. Some files were ported from
+ * netbsd and/or freebsd and are covered by the respective
+ * file header copyright notices.
+ */
+
+/*
+ * Authorship
+ * ----------
+ * This software ('RTEMS-portability wrappers for BSD network drivers') was
+ * created by Till Straumann <strauman@slac.stanford.edu>, 2005-2007,
+ * Stanford Linear Accelerator Center, Stanford University.
+ *
+ * Acknowledgement of sponsorship
+ * ------------------------------
+ * The 'RTEMS-portability wrappers for BSD network drivers' software was produced by
+ * the Stanford Linear Accelerator Center, Stanford University,
+ * under Contract DE-AC03-76SFO0515 with the Department of Energy.
+ *
+ * Government disclaimer of liability
+ * ----------------------------------
+ * Neither the United States nor the United States Department of Energy,
+ * nor any of their employees, makes any warranty, express or implied, or
+ * assumes any legal liability or responsibility for the accuracy,
+ * completeness, or usefulness of any data, apparatus, product, or process
+ * disclosed, or represents that its use would not infringe privately owned
+ * rights.
+ *
+ * Stanford disclaimer of liability
+ * --------------------------------
+ * Stanford University makes no representations or warranties, express or
+ * implied, nor assumes any liability for the use of this software.
+ *
+ * Stanford disclaimer of copyright
+ * --------------------------------
+ * Stanford University, owner of the copyright, hereby disclaims its
+ * copyright and all other rights in this software. Hence, anyone may
+ * freely use it for any purpose without restriction.
+ *
+ * Maintenance of notices
+ * ----------------------
+ * In the interest of clarity regarding the origin and status of this
+ * SLAC software, this and all the preceding Stanford University notices
+ * are to remain affixed to any copy or derivative of this software made
+ * or distributed by the recipient and are to be affixed to any copy of
+ * software made or distributed by the recipient that contains a copy or
+ * derivative of this software.
+ *
+ * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
+ */
diff --git a/bsps/powerpc/beatnik/net/porting/Makefile.template b/bsps/powerpc/beatnik/net/porting/Makefile.template
new file mode 100644
index 0000000000..3c5d6e3e33
--- /dev/null
+++ b/bsps/powerpc/beatnik/net/porting/Makefile.template
@@ -0,0 +1,84 @@
+#
+# Makefile.lib,v 1.5 2000/06/12 15:00:14 joel Exp
+#
+# Copyright: Till Straumann <strauman@slac.stanford.edu>, 2005;
+# License: see LICENSE file.
+#
+# Templates/Makefile.lib
+# Template library Makefile
+#
+
+LIBNAME=libif_XXX.a # XXX- your library names goes here
+LIB=${ARCH}/${LIBNAME}
+
+# C and C++ source names, if any, go here -- minus the .c or .cc
+C_PIECES=if_XXX if_XXX_rtems
+C_FILES=$(C_PIECES:%=%.c)
+C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
+
+CC_PIECES=
+CC_FILES=$(CC_PIECES:%=%.cc)
+CC_O_FILES=$(CC_PIECES:%=${ARCH}/%.o)
+
+H_FILES=
+
+# Assembly source names, if any, go here -- minus the .S
+S_PIECES=
+S_FILES=$(S_PIECES:%=%.S)
+S_O_FILES=$(S_FILES:%.S=${ARCH}/%.o)
+
+SRCS=$(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
+OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+
+include $(RTEMS_CUSTOM)
+include $(RTEMS_ROOT)/make/lib.cfg
+
+#
+# Add local stuff here using +=
+#
+
+#DEFINES += -DHAVE_LIBBSPEXT -DDEBUG_MODULAR
+CPPFLAGS += -I. -Ilibchip -Iporting
+# bsdnet newproc generated daemon is non-FP;
+# prevent optimizer from generating FP instructions
+CFLAGS += -Wno-unused-variable -msoft-float
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+all: ${ARCH} $(SRCS) $(LIB)
+
+$(LIB): ${OBJS}
+ $(make-library)
+
+ifndef RTEMS_SITE_INSTALLDIR
+RTEMS_SITE_INSTALLDIR = $(PROJECT_RELEASE)
+endif
+
+${RTEMS_SITE_INSTALLDIR}/include \
+${RTEMS_SITE_INSTALLDIR}/lib \
+${RTEMS_SITE_INSTALLDIR}/bin \
+${RTEMS_SITE_INSTALLDIR}/$(RTEMS_BSP)/include \
+${RTEMS_SITE_INSTALLDIR}/$(RTEMS_BSP)/lib \
+${RTEMS_SITE_INSTALLDIR}/$(RTEMS_BSP)/bin :
+ test -d $@ || mkdir -p $@
+
+# Install the library, appending _g or _p as appropriate.
+# for include files, just use $(INSTALL_CHANGE)
+#
+# NOTES:
+# - BSP specific libraries, headers etc. should be installed to
+# $RTEMS_SITE_INSTALLDIR)/$(RTEMS_BSP)/lib
+#
+
+install: all $(RTEMS_SITE_INSTALLDIR)/lib
+ $(INSTALL_VARIANT) -m 644 ${LIB} ${RTEMS_SITE_INSTALLDIR}/lib
diff --git a/bsps/powerpc/beatnik/net/porting/README b/bsps/powerpc/beatnik/net/porting/README
new file mode 100644
index 0000000000..b262d7797c
--- /dev/null
+++ b/bsps/powerpc/beatnik/net/porting/README
@@ -0,0 +1,104 @@
+Templates to help porting freebsd networking drivers
+to rtems (focus on i386 and powerpc) using a 'quick and dirty'
+approach.
+This is not an elegant piece of software -- be warned.
+
+/* Copyright: Till Straumann <strauman@slac.stanford.edu>, 2005;
+ * License: see LICENSE file.
+ */
+
+Usage:
+
+ A obtain the freebsd driver source. It usually is made
+ up of a
+ if_XXX.c -- core driver
+ if_XXXreg.h -- core header
+ if_XXXvar.h -- some have it, some don't
+ if_XXX_<bus>.c -- glue to integrate the core
+ driver with different environments
+ (such as pccard, pci, ...). There
+ are several of these.
+
+ Note that you might have to get an older version
+ as some structures and interfaces may have undergone
+ significant changes since the bsd/networking version that
+ was ported to rtems.
+
+ B Copy the Makefile and rtemscompat_defs.h templates to the
+ driver source dir and edit them.
+
+ C Edit if_XXXreg.h and comment all unneeded fields from the
+ 'softc' structure declaration with
+
+ #ifndef __rtems__
+ #endif
+
+ In particular, the bushandle field (as defined in rtemscompat_defs.h)
+ above, see comments in the template) must be re-declared:
+
+ #ifndef __rtems__
+ bus_space_handle_t XXX_bhandle;
+ #else
+ unsigned XXX_bhandle;
+ unsigned char irq_no;
+ unsigned char b,d,f; /* PCI tuple; needed for PCI only */
+ rtems_id tid; /* driver task id */
+ #endif
+
+ Later, the compilation attempts will help identifying
+ fields that need to be removed.
+
+ I like the #ifdef __rtems__ construct as it minimizes changes
+ to the source thus making merging updated driver versions easier.
+
+ D Edit if_XXX.c; at the very top, include the lines
+
+ #ifdef __rtems__
+ #include <rtemscompat.h>
+ #endif
+
+ use the #ifndef __rtems__ #endif construct to comment
+ unneeded / unsupported inclusion of headers and code pieces.
+
+ - inclusion of net/if_media.h must usually be mapped to
+ libchip/if_media.h
+
+ comment all vm, machine, bus, mii etc. related headers.
+
+ - replace inclusion of if_XXXreg.h by
+
+ #include "if_XXXreg.h"
+ #include <rtemscompat1.h>
+
+ - work through the if_XXX.c and if_XXXreg.h files commenting
+ stuff until if_XXX.c compiles. This might involve hacking
+ the helper headers.
+
+ - pay attention to endian issues; things may need to be fixed!
+
+ - at the top where the freebsd 'methods' and the like are
+ commented, add a definition of the driver methods for RTEMS:
+
+ #ifdef __rtems__
+ net_drv_tbl_t METHODS = {
+ n_probe : XXX_probe,
+ n_attach : XXX_attach,
+ n_detach : XXX_detach, /* optional; */
+ n_intr : XXX_intr, /* freebsd ISR; executed from daemon under RTEMS */
+ };
+ #endif
+
+ - make sure all the if_xxx methods are set; in particular,
+ set
+ sc->if_output = ether_output;
+
+ - on input:
+ you can use DO_ETHER_INPUT_SKIPPING_ETHER_HEADER() macro
+ -- if you don't MAKE SURE THE RECEIVING INTERFACE IS SET
+ in the mbuf packet header!!!
+
+ E create 'rtems_<chip>_setup()' to probe for devices and
+ set the softc struct's base address, interrupt line and
+ bus/dev/fun triple (PCI only).
+ For PCI devices, a generic setup routine already comes with
+ porting/if_xxx_rtems.c -> nothing needs to be written!
diff --git a/bsps/powerpc/beatnik/net/porting/if_xxx.modini.c b/bsps/powerpc/beatnik/net/porting/if_xxx.modini.c
new file mode 100644
index 0000000000..1abad7dc22
--- /dev/null
+++ b/bsps/powerpc/beatnik/net/porting/if_xxx.modini.c
@@ -0,0 +1,34 @@
+#include <rtems.h>
+#include <porting/rtemscompat.h>
+
+/* CEXP module initialization/finalization */
+
+/* Copyright: Till Straumann <strauman@slac.stanford.edu>, 2005;
+ * License: see LICENSE file.
+ */
+
+void
+_cexpModuleInitialize(void *unused)
+{
+extern void NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_bringup)(char *);
+ METHODSPTR = &METHODS;
+/*
+#ifdef DEBUG
+ NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_bringup)("192.168.2.13/255.255.255.0");
+#endif
+*/
+}
+
+int
+_cexpModuleFinalize(void *unused)
+{
+#ifdef DEBUG
+extern int NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_bringdown)();
+ if (NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_bringdown)())
+ return -1;
+ METHODSPTR = 0;
+ return 0;
+#else
+ return -1;
+#endif
+}
diff --git a/bsps/powerpc/beatnik/net/porting/if_xxx_rtems.c b/bsps/powerpc/beatnik/net/porting/if_xxx_rtems.c
new file mode 100644
index 0000000000..a0d459ff47
--- /dev/null
+++ b/bsps/powerpc/beatnik/net/porting/if_xxx_rtems.c
@@ -0,0 +1,500 @@
+#include "rtemscompat.h"
+
+/* Template for driver task, setup and attach routines. To be instantiated
+ * by defining the relevant symbols in header files.
+ */
+
+/* Copyright: Till Straumann <strauman@slac.stanford.edu>, 2005;
+ * License: see LICENSE file.
+ */
+
+#include <rtems/irq.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include <sys/cdefs.h>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+
+#include <net/if.h>
+#include <net/if_arp.h>
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+
+#include <net/if_media.h>
+
+#ifdef IF_REG_HEADER
+#include IF_REG_HEADER
+#endif
+#ifdef IF_VAR_HEADER
+#include IF_VAR_HEADER
+#endif
+
+#include "rtemscompat1.h"
+
+#define EX_EVENT RTEMS_EVENT_1
+#undef IRQ_AT_8259
+
+NETDEV_DECL = { /*[0]:*/{ /* softc: */ { /* arpcom: */{ /* ac_if: */ { 0 }}}}};
+
+static void net_daemon(void *arg);
+
+#ifdef HAVE_LIBBSPEXT
+#include <bsp/bspExt.h>
+static void the_net_isr(void *);
+#else
+static void noop(const rtems_irq_connect_data *unused) {}
+static int noop1(const rtems_irq_connect_data *unused) { return 0;}
+#if ISMINVERSION(4,6,99)
+static void the_net_isr(rtems_irq_hdl_param);
+#else
+static void the_net_isr();
+#if NETDRIVER_SLOTS > 1
+#error only one instance supported (stupid IRQ API)
+#else
+static struct NET_SOFTC *thesc;
+#endif
+#endif
+#endif
+
+#if defined(NETDRIVER_PCI)
+/* Public setup routine for PCI devices;
+ * TODO: currently doesn't work for subsystem vendor/id , i.e.
+ * devices behind a standard PCI interface...
+ */
+int
+NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_pci_setup)(int inst);
+#endif
+
+static unsigned
+NET_EMBEMB(,NETDRIVER_PREFIX,_net_driver_ticks_per_sec) = 0;
+
+/* other drivers may already have this created */
+extern unsigned net_driver_ticks_per_sec
+__attribute__((weak, alias(NET_STRSTR(NETDRIVER_PREFIX)"_net_driver_ticks_per_sec") ));
+
+#ifdef DEBUG_MODULAR
+net_drv_tbl_t * volatile METHODSPTR = 0;
+#endif
+
+
+int
+NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_attach)
+ (struct rtems_bsdnet_ifconfig *config, int attaching)
+{
+ int error = 0;
+ device_t dev = net_dev_get(config);
+ struct NET_SOFTC *sc;
+ struct ifnet *ifp;
+#ifndef HAVE_LIBBSPEXT
+ rtems_irq_connect_data irq_data = {
+ 0,
+ the_net_isr,
+#if ISMINVERSION(4,6,99)
+ 0,
+#endif
+ noop,
+ noop,
+ noop1 };
+#endif
+
+ if ( !dev )
+ return 1;
+
+ if ( !dev->d_softc.NET_SOFTC_BHANDLE_FIELD ) {
+#if defined(NETDRIVER_PCI)
+ device_printf(dev,NETDRIVER" unit not configured; executing setup...");
+ /* setup should really be performed prior to attaching.
+ * Wipe the device; setup and re-obtain the device...
+ */
+ memset(dev,0,sizeof(*dev));
+ error = NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_pci_setup)(-1);
+ /* re-obtain the device */
+ dev = net_dev_get(config);
+ if ( !dev ) {
+ printk("Unable to re-assign device structure???\n");
+ return 1;
+ }
+ if (error <= 0) {
+ device_printf(dev,NETDRIVER" FAILED; unable to attach interface, sorry\n");
+ return 1;
+ }
+ device_printf(dev,"success\n");
+#else
+ device_printf(dev,NETDRIVER" unit not configured; use 'rtems_"NETDRIVER"_setup()'\n");
+ return 1;
+#endif
+ }
+
+ if ( !net_driver_ticks_per_sec )
+ net_driver_ticks_per_sec = rtems_clock_get_ticks_per_second();
+
+ sc = device_get_softc( dev );
+ ifp = &sc->arpcom.ac_if;
+
+#ifdef DEBUG_MODULAR
+ if (!METHODSPTR) {
+ device_printf(dev,NETDRIVER": method pointer not set\n");
+ return -1;
+ }
+#endif
+
+ if ( attaching ) {
+ if ( ifp->if_init ) {
+ device_printf(dev,NETDRIVER" Driver already attached.\n");
+ return -1;
+ }
+ if ( config->hardware_address ) {
+ /* use configured MAC address */
+ memcpy(sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN);
+ } else {
+#ifdef NET_READ_MAC_ADDR
+ NET_READ_MAC_ADDR(sc);
+#endif
+ }
+ if ( METHODSPTR->n_attach(dev) ) {
+ device_printf(dev,NETDRIVER"_attach() failed\n");
+ return -1;
+ }
+ } else {
+ if ( !ifp->if_init ) {
+ device_printf(dev,NETDRIVER" Driver not attached.\n");
+ return -1;
+ }
+ if ( METHODSPTR->n_detach ) {
+ if ( METHODSPTR->n_detach(dev) ) {
+ device_printf(dev,NETDRIVER"_detach() failed\n");
+ return -1;
+ }
+ } else {
+ device_printf(dev,NETDRIVER"_detach() not implemented\n");
+ return -1;
+ }
+ }
+
+
+ if ( !sc->tid )
+ sc->tid = rtems_bsdnet_newproc(NETDRIVER"d", 4096, net_daemon, sc);
+
+ if (attaching) {
+#ifdef DEBUG
+ printf("Installing IRQ # %i\n",sc->irq_no);
+#endif
+#ifdef HAVE_LIBBSPEXT
+ if ( bspExtInstallSharedISR(sc->irq_no, the_net_isr, sc, 0) )
+#else
+ /* BSP dependent :-( */
+ irq_data.name = sc->irq_no;
+#if ISMINVERSION(4,6,99)
+ irq_data.handle = (rtems_irq_hdl_param)sc;
+#else
+ thesc = sc;
+#endif
+ if ( ! BSP_install_rtems_irq_handler( &irq_data ) )
+#endif
+ {
+ fprintf(stderr,NETDRIVER": unable to install ISR\n");
+ error = -1;
+ }
+ } else {
+ if ( sc->irq_no ) {
+#ifdef DEBUG
+ printf("Removing IRQ # %i\n",sc->irq_no);
+#endif
+#ifdef HAVE_LIBBSPEXT
+ if (bspExtRemoveSharedISR(sc->irq_no, the_net_isr, sc))
+#else
+ /* BSP dependent :-( */
+ irq_data.name = sc->irq_no;
+#if ISMINVERSION(4,6,99)
+ irq_data.handle = (rtems_irq_hdl_param)sc;
+#endif
+ if ( ! BSP_remove_rtems_irq_handler( &irq_data ) )
+#endif
+ {
+ fprintf(stderr,NETDRIVER": unable to uninstall ISR\n");
+ error = -1;
+ }
+ }
+ }
+ return error;
+}
+
+static void
+the_net_isr(
+#ifdef HAVE_LIBBSPEXT
+void *thesc
+#elif ISMINVERSION(4,6,99)
+rtems_irq_hdl_param thesc
+#endif
+)
+{
+struct NET_SOFTC *sc = thesc;
+
+ /* disable interrupts */
+ NET_DISABLE_IRQS(sc);
+
+ rtems_bsdnet_event_send( sc->tid, EX_EVENT );
+}
+
+static void net_daemon(void *arg)
+{
+struct NET_SOFTC *sc = arg;
+rtems_event_set evs;
+
+ for (;;) {
+ rtems_bsdnet_event_receive(
+ EX_EVENT,
+ RTEMS_WAIT | RTEMS_EVENT_ANY,
+ RTEMS_NO_TIMEOUT,
+ &evs);
+
+ METHODSPTR->n_intr(sc);
+
+ /* re-enable interrupts */
+ NET_ENABLE_IRQS(sc);
+ }
+}
+
+static struct NET_SOFTC *
+net_drv_check_unit(int unit)
+{
+ unit--;
+ if ( unit < 0 || unit >= NETDRIVER_SLOTS ) {
+ fprintf(stderr,"Invalid unit # %i (not in %i..%i)\n", unit+1, 1, NETDRIVER_SLOTS);
+ return 0;
+ }
+
+ if ( THEDEVS[unit].d_name ) {
+ fprintf(stderr,"Unit %i already set up\n", unit+1);
+ return 0;
+ }
+
+ memset( &THEDEVS[unit], 0, sizeof(THEDEVS[0]) );
+
+ return &THEDEVS[unit].d_softc;
+}
+
+struct rtems_bsdnet_ifconfig NET_EMBEMB(NETDRIVER_PREFIX,_dbg,_config) = {
+ NETDRIVER"1",
+ NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_attach),
+ 0
+};
+
+#ifdef DEBUG
+void
+NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_bringup)(char *ipaddr)
+{
+short flags;
+struct sockaddr_in addr;
+char *mask;
+
+
+ if (!ipaddr) {
+ printf("Need an ip[/mask] argument (dot notation)\n");
+ return;
+ }
+
+ ipaddr = strdup(ipaddr);
+
+ if ( (mask = strchr(ipaddr,'/')) ) {
+ *mask++=0;
+ } else {
+ mask = "255.255.255.0";
+ }
+
+#if defined(NETDRIVER_PCI)
+ /* this fails if already setup */
+ NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_pci_setup)(-1);
+#endif
+ rtems_bsdnet_attach(&NET_EMBEMB(NETDRIVER_PREFIX,_dbg,_config));
+
+ flags = IFF_UP /*| IFF_PROMISC*/;
+ if ( rtems_bsdnet_ifconfig(NETDRIVER"1",SIOCSIFFLAGS,&flags) < 0 ) {
+ printf("Can't bring '"NETDRIVER"1' up\n");
+ goto cleanup;
+ }
+ memset(&addr,0,sizeof(addr));
+ addr.sin_len = sizeof(addr);
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = inet_addr(mask);
+ if ( rtems_bsdnet_ifconfig(NETDRIVER"1",SIOCSIFNETMASK,&addr) < 0 ) {
+ printf("Unable to set netmask on '"NETDRIVER"1'\n");
+ goto cleanup;
+ }
+ addr.sin_addr.s_addr = inet_addr(ipaddr);
+ if ( rtems_bsdnet_ifconfig(NETDRIVER"1",SIOCSIFADDR,&addr) < 0 ) {
+ printf("Unable to set address on '"NETDRIVER"1'\n");
+ goto cleanup;
+ }
+cleanup:
+ the_real_free (ipaddr);
+}
+
+int
+NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_bringdown)()
+{
+short flags;
+ flags = 0;
+ if ( rtems_bsdnet_ifconfig(NETDRIVER"1",SIOCSIFFLAGS,&flags) < 0 ) {
+ printf("Can't bring '"NETDRIVER"1' down\n");
+ return -1;
+ }
+
+ rtems_bsdnet_detach(&NET_EMBEMB(NETDRIVER_PREFIX,_dbg,_config));
+ return 0;
+}
+#endif
+
+
+#if defined(NETDRIVER_PCI) && !defined(NETDRIVER_OWN_SETUP)
+/* Public setup routine for PCI devices;
+ * TODO: currently doesn't work for subsystem vendor/id , i.e.
+ * devices behind a standard PCI interface...
+ * passing 'inst' > only sets-up the 'inst'th card; passing
+ * 'inst' == 0 sets-up all matching cards.
+ */
+int
+NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_pci_setup)(int inst)
+{
+unsigned b,d,f,i,isio,unit;
+rtemscompat_32_t base;
+unsigned short cmd,id;
+unsigned char h;
+struct NET_SOFTC *sc;
+unsigned try[] = { PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_1, 0 };
+
+#ifdef DEBUG_MODULAR
+ if ( !METHODSPTR ) {
+ fprintf(stderr,NETDRIVER": Methods pointer not set\n");
+ return -1;
+ }
+#endif
+
+ /* 0 can be reached when looking for the desired instance */
+ if ( 0 == inst )
+ inst = -1;
+
+#ifdef HAVE_LIBBSPEXT
+ /* make sure it's initialized */
+ bspExtInit();
+#endif
+
+ /* scan PCI for supported devices */
+ for ( b=0, sc=0, unit=0; b<pci_bus_count(); b++ ) {
+ for ( d=0; d<PCI_MAX_DEVICES; d++ ) {
+ pci_read_config_word(b,d,0,PCI_VENDOR_ID,&id);
+ if ( 0xffff == id )
+ continue; /* empty slot */
+
+ pci_read_config_byte(b,d,0,PCI_HEADER_TYPE,&h);
+ h = h&0x80 ? PCI_MAX_FUNCTIONS : 1; /* multifunction device ? */
+
+ for ( f=0; f<h; f++ ) {
+ if ( !sc && !(sc=net_drv_check_unit(unit+1))) {
+ fprintf(stderr,"Not enough driver slots; stop looking for more devices...\n");
+ return unit;
+ }
+ pci_read_config_word(b,d,f,PCI_VENDOR_ID,&id);
+ if ( 0xffff == id )
+ continue; /* empty slot */
+
+ pci_read_config_word(b,d,f,PCI_CLASS_DEVICE,&id);
+ if ( PCI_CLASS_NETWORK_ETHERNET != id )
+ continue; /* only look at ethernet devices */
+
+ sc->b = b;
+ sc->d = d;
+ sc->f = f;
+
+ for ( i=0, base=0, isio=0; try[i]; i++ ) {
+ pci_read_config_dword(b,d,f,try[i],&base);
+ if ( base ) {
+ if ( (isio = (PCI_BASE_ADDRESS_SPACE_IO == (base & PCI_BASE_ADDRESS_SPACE )) ) ) {
+#ifdef NET_CHIP_PORT_IO
+ base &= PCI_BASE_ADDRESS_IO_MASK;
+ sc->NET_SOFTC_BHANDLE_FIELD = PCI_IO_2LOCAL(base,b);
+#ifdef DEBUG
+ printf("Found PCI I/O Base 0x%08x\n", (unsigned)base);
+#endif
+#else
+ base = 0;
+ continue;
+#endif
+ } else {
+#ifdef NET_CHIP_MEM_IO
+ base &= PCI_BASE_ADDRESS_MEM_MASK;
+ sc->NET_SOFTC_BHANDLE_FIELD = PCI2LOCAL(base,b);
+#ifdef DEBUG
+ printf("Found PCI MEM Base 0x%08x\n", (unsigned)base);
+#endif
+#else
+ base = 0;
+ continue;
+#endif
+ }
+ break;
+ }
+ }
+ if ( !base ) {
+#ifdef DEBUG
+ fprintf(stderr, NETDRIVER": (warning) Neither PCI base address 0 nor 1 are configured; skipping bus %i, slot %i, fn %i...\n",b,d,f);
+#endif
+ continue;
+ }
+
+ if ( 0 == METHODSPTR->n_probe(&THEDEVS[unit]) && (inst < 0 || !--inst) ) {
+ pci_read_config_word(b,d,f,PCI_COMMAND,&cmd);
+ pci_write_config_word(b,d,f,PCI_COMMAND,
+ cmd | (isio ? PCI_COMMAND_IO : PCI_COMMAND_MEMORY) | PCI_COMMAND_MASTER );
+ pci_read_config_byte(b,d,f,PCI_INTERRUPT_LINE,&sc->irq_no);
+ printf(NETDRIVER": card found @PCI[%s] 0x%08x (local 0x%08x), IRQ %i\n",
+ (isio ? "io" : "mem"), (unsigned)base, sc->NET_SOFTC_BHANDLE_FIELD, sc->irq_no);
+
+ sc = 0; /* need to allocate a new slot */
+ unit++;
+
+ if ( 0 == inst ) {
+ /* found desired instance */
+ goto terminated;
+ }
+ }
+ }
+ }
+ }
+
+terminated:
+ return unit;
+}
+#else
+
+/* simple skeleton
+int
+NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_setup)(
+ int unit,
+ void *base_addr,
+ int irq_no)
+{
+struct NET_SOFTC *sc;
+ if ( !(sc=net_drv_check_unit(unit)) ) {
+ fprintf(stderr,"Bad unit number -- (not enought driver slots?)\n");
+ return 0;
+ }
+ sc->NET_SOFTC_BHANDLE_FIELD = base_addr;
+ if ( 0 == METHODSPTR->n_probe(&THEDEVS[unit-1]) ) {
+ sc->irq_no = irq_no;
+ printf(NETDRIVER": Unit %i set up\n", unit);
+ return unit;
+ }
+ return 0;
+}
+*/
+
+#endif
diff --git a/bsps/powerpc/beatnik/net/porting/pcireg.h b/bsps/powerpc/beatnik/net/porting/pcireg.h
new file mode 100644
index 0000000000..8487f5b8f6
--- /dev/null
+++ b/bsps/powerpc/beatnik/net/porting/pcireg.h
@@ -0,0 +1,405 @@
+/*-
+ * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: /repoman/r/ncvs/src/sys/dev/pci/pcireg.h,v 1.39.4.3 2005/04/02 05:03:34 jmg Exp $
+ *
+ */
+
+/*
+ * PCIM_xxx: mask to locate subfield in register
+ * PCIR_xxx: config register offset
+ * PCIC_xxx: device class
+ * PCIS_xxx: device subclass
+ * PCIP_xxx: device programming interface
+ * PCIV_xxx: PCI vendor ID (only required to fixup ancient devices)
+ * PCID_xxx: device ID
+ * PCIY_xxx: capability identification number
+ */
+
+/* some PCI bus constants */
+
+#define PCI_BUSMAX 255
+#define PCI_SLOTMAX 31
+#define PCI_FUNCMAX 7
+#define PCI_REGMAX 255
+#define PCI_MAXHDRTYPE 2
+
+/* PCI config header registers for all devices */
+
+#define PCIR_DEVVENDOR 0x00
+#define PCIR_VENDOR 0x00
+#define PCIR_DEVICE 0x02
+#define PCIR_COMMAND 0x04
+#define PCIM_CMD_PORTEN 0x0001
+#define PCIM_CMD_MEMEN 0x0002
+#define PCIM_CMD_BUSMASTEREN 0x0004
+#define PCIM_CMD_SPECIALEN 0x0008
+#define PCIM_CMD_MWRICEN 0x0010
+#define PCIM_CMD_PERRESPEN 0x0040
+#define PCIM_CMD_SERRESPEN 0x0100
+#define PCIM_CMD_BACKTOBACK 0x0200
+#define PCIR_STATUS 0x06
+#define PCIM_STATUS_CAPPRESENT 0x0010
+#define PCIM_STATUS_66CAPABLE 0x0020
+#define PCIM_STATUS_BACKTOBACK 0x0080
+#define PCIM_STATUS_PERRREPORT 0x0100
+#define PCIM_STATUS_SEL_FAST 0x0000
+#define PCIM_STATUS_SEL_MEDIMUM 0x0200
+#define PCIM_STATUS_SEL_SLOW 0x0400
+#define PCIM_STATUS_SEL_MASK 0x0600
+#define PCIM_STATUS_STABORT 0x0800
+#define PCIM_STATUS_RTABORT 0x1000
+#define PCIM_STATUS_RMABORT 0x2000
+#define PCIM_STATUS_SERR 0x4000
+#define PCIM_STATUS_PERR 0x8000
+#define PCIR_REVID 0x08
+#define PCIR_PROGIF 0x09
+#define PCIR_SUBCLASS 0x0a
+#define PCIR_CLASS 0x0b
+#define PCIR_CACHELNSZ 0x0c
+#define PCIR_LATTIMER 0x0d
+#define PCIR_HDRTYPE 0x0e
+#ifndef BURN_BRIDGES
+#define PCIR_HEADERTYPE PCIR_HDRTYPE
+#endif
+#define PCIM_HDRTYPE 0x7f
+#define PCIM_HDRTYPE_NORMAL 0x00
+#define PCIM_HDRTYPE_BRIDGE 0x01
+#define PCIM_HDRTYPE_CARDBUS 0x02
+#define PCIM_MFDEV 0x80
+#define PCIR_BIST 0x0f
+
+/* Capability Identification Numbers */
+
+#define PCIY_PMG 0x01 /* PCI Power Management */
+#define PCIY_AGP 0x02 /* AGP */
+#define PCIY_VPD 0x03 /* Vital Product Data */
+#define PCIY_SLOTID 0x04 /* Slot Identification */
+#define PCIY_MSI 0x05 /* Message Signaled Interrupts */
+#define PCIY_CHSWP 0x06 /* CompactPCI Hot Swap */
+#define PCIY_PCIX 0x07 /* PCI-X */
+#define PCIY_HT 0x08 /* HyperTransport */
+#define PCIY_VENDOR 0x09 /* Vendor Unique */
+#define PCIY_DEBUG 0x0a /* Debug port */
+#define PCIY_CRES 0x0b /* CompactPCI central resource control */
+#define PCIY_HOTPLUG 0x0c /* PCI Hot-Plug */
+#define PCIY_AGP8X 0x0e /* AGP 8x */
+#define PCIY_SECDEV 0x0f /* Secure Device */
+#define PCIY_EXPRESS 0x10 /* PCI Express */
+#define PCIY_MSIX 0x11 /* MSI-X */
+
+/* config registers for header type 0 devices */
+
+#define PCIR_BARS 0x10
+#define PCIR_BAR(x) (PCIR_BARS + (x) * 4)
+#ifndef BURN_BRIDGES
+#define PCIR_MAPS PCIR_BARS
+#endif
+#define PCIR_CARDBUSCIS 0x28
+#define PCIR_SUBVEND_0 0x2c
+#define PCIR_SUBDEV_0 0x2e
+#define PCIR_BIOS 0x30
+#define PCIM_BIOS_ENABLE 0x01
+#define PCIR_CAP_PTR 0x34
+#define PCIR_INTLINE 0x3c
+#define PCIR_INTPIN 0x3d
+#define PCIR_MINGNT 0x3e
+#define PCIR_MAXLAT 0x3f
+
+/* config registers for header type 1 (PCI-to-PCI bridge) devices */
+
+#define PCIR_SECSTAT_1 0x1e
+
+#define PCIR_PRIBUS_1 0x18
+#define PCIR_SECBUS_1 0x19
+#define PCIR_SUBBUS_1 0x1a
+#define PCIR_SECLAT_1 0x1b
+
+#define PCIR_IOBASEL_1 0x1c
+#define PCIR_IOLIMITL_1 0x1d
+#define PCIR_IOBASEH_1 0x30
+#define PCIR_IOLIMITH_1 0x32
+#define PCIM_BRIO_16 0x0
+#define PCIM_BRIO_32 0x1
+#define PCIM_BRIO_MASK 0xf
+
+#define PCIR_MEMBASE_1 0x20
+#define PCIR_MEMLIMIT_1 0x22
+
+#define PCIR_PMBASEL_1 0x24
+#define PCIR_PMLIMITL_1 0x26
+#define PCIR_PMBASEH_1 0x28
+#define PCIR_PMLIMITH_1 0x2c
+
+#define PCIR_BRIDGECTL_1 0x3e
+
+#define PCIR_SUBVEND_1 0x34
+#define PCIR_SUBDEV_1 0x36
+
+/* config registers for header type 2 (CardBus) devices */
+
+#define PCIR_SECSTAT_2 0x16
+
+#define PCIR_PRIBUS_2 0x18
+#define PCIR_SECBUS_2 0x19
+#define PCIR_SUBBUS_2 0x1a
+#define PCIR_SECLAT_2 0x1b
+
+#define PCIR_MEMBASE0_2 0x1c
+#define PCIR_MEMLIMIT0_2 0x20
+#define PCIR_MEMBASE1_2 0x24
+#define PCIR_MEMLIMIT1_2 0x28
+#define PCIR_IOBASE0_2 0x2c
+#define PCIR_IOLIMIT0_2 0x30
+#define PCIR_IOBASE1_2 0x34
+#define PCIR_IOLIMIT1_2 0x38
+
+#define PCIR_BRIDGECTL_2 0x3e
+
+#define PCIR_SUBVEND_2 0x40
+#define PCIR_SUBDEV_2 0x42
+
+#define PCIR_PCCARDIF_2 0x44
+
+/* PCI device class, subclass and programming interface definitions */
+
+#define PCIC_OLD 0x00
+#define PCIS_OLD_NONVGA 0x00
+#define PCIS_OLD_VGA 0x01
+
+#define PCIC_STORAGE 0x01
+#define PCIS_STORAGE_SCSI 0x00
+#define PCIS_STORAGE_IDE 0x01
+#define PCIP_STORAGE_IDE_MODEPRIM 0x01
+#define PCIP_STORAGE_IDE_PROGINDPRIM 0x02
+#define PCIP_STORAGE_IDE_MODESEC 0x04
+#define PCIP_STORAGE_IDE_PROGINDSEC 0x08
+#define PCIP_STORAGE_IDE_MASTERDEV 0x80
+#define PCIS_STORAGE_FLOPPY 0x02
+#define PCIS_STORAGE_IPI 0x03
+#define PCIS_STORAGE_RAID 0x04
+#define PCIS_STORAGE_OTHER 0x80
+
+#define PCIC_NETWORK 0x02
+#define PCIS_NETWORK_ETHERNET 0x00
+#define PCIS_NETWORK_TOKENRING 0x01
+#define PCIS_NETWORK_FDDI 0x02
+#define PCIS_NETWORK_ATM 0x03
+#define PCIS_NETWORK_ISDN 0x04
+#define PCIS_NETWORK_OTHER 0x80
+
+#define PCIC_DISPLAY 0x03
+#define PCIS_DISPLAY_VGA 0x00
+#define PCIS_DISPLAY_XGA 0x01
+#define PCIS_DISPLAY_3D 0x02
+#define PCIS_DISPLAY_OTHER 0x80
+
+#define PCIC_MULTIMEDIA 0x04
+#define PCIS_MULTIMEDIA_VIDEO 0x00
+#define PCIS_MULTIMEDIA_AUDIO 0x01
+#define PCIS_MULTIMEDIA_TELE 0x02
+#define PCIS_MULTIMEDIA_OTHER 0x80
+
+#define PCIC_MEMORY 0x05
+#define PCIS_MEMORY_RAM 0x00
+#define PCIS_MEMORY_FLASH 0x01
+#define PCIS_MEMORY_OTHER 0x80
+
+#define PCIC_BRIDGE 0x06
+#define PCIS_BRIDGE_HOST 0x00
+#define PCIS_BRIDGE_ISA 0x01
+#define PCIS_BRIDGE_EISA 0x02
+#define PCIS_BRIDGE_MCA 0x03
+#define PCIS_BRIDGE_PCI 0x04
+#define PCIS_BRIDGE_PCMCIA 0x05
+#define PCIS_BRIDGE_NUBUS 0x06
+#define PCIS_BRIDGE_CARDBUS 0x07
+#define PCIS_BRIDGE_RACEWAY 0x08
+#define PCIS_BRIDGE_OTHER 0x80
+
+#define PCIC_SIMPLECOMM 0x07
+#define PCIS_SIMPLECOMM_UART 0x00
+#define PCIP_SIMPLECOMM_UART_16550A 0x02
+#define PCIS_SIMPLECOMM_PAR 0x01
+#define PCIS_SIMPLECOMM_MULSER 0x02
+#define PCIS_SIMPLECOMM_MODEM 0x03
+#define PCIS_SIMPLECOMM_OTHER 0x80
+
+#define PCIC_BASEPERIPH 0x08
+#define PCIS_BASEPERIPH_PIC 0x00
+#define PCIS_BASEPERIPH_DMA 0x01
+#define PCIS_BASEPERIPH_TIMER 0x02
+#define PCIS_BASEPERIPH_RTC 0x03
+#define PCIS_BASEPERIPH_PCIHOT 0x04
+#define PCIS_BASEPERIPH_OTHER 0x80
+
+#define PCIC_INPUTDEV 0x09
+#define PCIS_INPUTDEV_KEYBOARD 0x00
+#define PCIS_INPUTDEV_DIGITIZER 0x01
+#define PCIS_INPUTDEV_MOUSE 0x02
+#define PCIS_INPUTDEV_SCANNER 0x03
+#define PCIS_INPUTDEV_GAMEPORT 0x04
+#define PCIS_INPUTDEV_OTHER 0x80
+
+#define PCIC_DOCKING 0x0a
+#define PCIS_DOCKING_GENERIC 0x00
+#define PCIS_DOCKING_OTHER 0x80
+
+#define PCIC_PROCESSOR 0x0b
+#define PCIS_PROCESSOR_386 0x00
+#define PCIS_PROCESSOR_486 0x01
+#define PCIS_PROCESSOR_PENTIUM 0x02
+#define PCIS_PROCESSOR_ALPHA 0x10
+#define PCIS_PROCESSOR_POWERPC 0x20
+#define PCIS_PROCESSOR_MIPS 0x30
+#define PCIS_PROCESSOR_COPROC 0x40
+
+#define PCIC_SERIALBUS 0x0c
+#define PCIS_SERIALBUS_FW 0x00
+#define PCIS_SERIALBUS_ACCESS 0x01
+#define PCIS_SERIALBUS_SSA 0x02
+#define PCIS_SERIALBUS_USB 0x03
+#define PCIP_SERIALBUS_USB_UHCI 0x00
+#define PCIP_SERIALBUS_USB_OHCI 0x10
+#define PCIP_SERIALBUS_USB_EHCI 0x20
+#define PCIS_SERIALBUS_FC 0x04
+#define PCIS_SERIALBUS_SMBUS 0x05
+
+#define PCIC_WIRELESS 0x0d
+#define PCIS_WIRELESS_IRDA 0x00
+#define PCIS_WIRELESS_IR 0x01
+#define PCIS_WIRELESS_RF 0x10
+#define PCIS_WIRELESS_OTHER 0x80
+
+#define PCIC_INTELLIIO 0x0e
+#define PCIS_INTELLIIO_I2O 0x00
+
+#define PCIC_SATCOM 0x0f
+#define PCIS_SATCOM_TV 0x01
+#define PCIS_SATCOM_AUDIO 0x02
+#define PCIS_SATCOM_VOICE 0x03
+#define PCIS_SATCOM_DATA 0x04
+
+#define PCIC_CRYPTO 0x10
+#define PCIS_CRYPTO_NETCOMP 0x00
+#define PCIS_CRYPTO_ENTERTAIN 0x10
+#define PCIS_CRYPTO_OTHER 0x80
+
+#define PCIC_DASP 0x11
+#define PCIS_DASP_DPIO 0x00
+#define PCIS_DASP_OTHER 0x80
+
+#define PCIC_OTHER 0xff
+
+/* PCI power manangement */
+
+#define PCIR_POWER_CAP 0x2
+#define PCIM_PCAP_SPEC 0x0007
+#define PCIM_PCAP_PMEREQCLK 0x0008
+#define PCIM_PCAP_PMEREQPWR 0x0010
+#define PCIM_PCAP_DEVSPECINIT 0x0020
+#define PCIM_PCAP_DYNCLOCK 0x0040
+#define PCIM_PCAP_SECCLOCK 0x00c0
+#define PCIM_PCAP_CLOCKMASK 0x00c0
+#define PCIM_PCAP_REQFULLCLOCK 0x0100
+#define PCIM_PCAP_D1SUPP 0x0200
+#define PCIM_PCAP_D2SUPP 0x0400
+#define PCIM_PCAP_D0PME 0x1000
+#define PCIM_PCAP_D1PME 0x2000
+#define PCIM_PCAP_D2PME 0x4000
+
+#define PCIR_POWER_STATUS 0x4
+#define PCIM_PSTAT_D0 0x0000
+#define PCIM_PSTAT_D1 0x0001
+#define PCIM_PSTAT_D2 0x0002
+#define PCIM_PSTAT_D3 0x0003
+#define PCIM_PSTAT_DMASK 0x0003
+#define PCIM_PSTAT_REPENABLE 0x0010
+#define PCIM_PSTAT_PMEENABLE 0x0100
+#define PCIM_PSTAT_D0POWER 0x0000
+#define PCIM_PSTAT_D1POWER 0x0200
+#define PCIM_PSTAT_D2POWER 0x0400
+#define PCIM_PSTAT_D3POWER 0x0600
+#define PCIM_PSTAT_D0HEAT 0x0800
+#define PCIM_PSTAT_D1HEAT 0x1000
+#define PCIM_PSTAT_D2HEAT 0x1200
+#define PCIM_PSTAT_D3HEAT 0x1400
+#define PCIM_PSTAT_DATAUNKN 0x0000
+#define PCIM_PSTAT_DATADIV10 0x2000
+#define PCIM_PSTAT_DATADIV100 0x4000
+#define PCIM_PSTAT_DATADIV1000 0x6000
+#define PCIM_PSTAT_DATADIVMASK 0x6000
+#define PCIM_PSTAT_PME 0x8000
+
+#define PCIR_POWER_PMCSR 0x6
+#define PCIM_PMCSR_DCLOCK 0x10
+#define PCIM_PMCSR_B2SUPP 0x20
+#define PCIM_BMCSR_B3SUPP 0x40
+#define PCIM_BMCSR_BPCE 0x80
+
+#define PCIR_POWER_DATA 0x7
+
+/* PCI Message Signalled Interrupts (MSI) */
+#define PCIR_MSI_CTRL 0x2
+#define PCIM_MSICTRL_VECTOR 0x0100
+#define PCIM_MSICTRL_64BIT 0x0080
+#define PCIM_MSICTRL_MME_MASK 0x0070
+#define PCIM_MSICTRL_MME_1 0x0000
+#define PCIM_MSICTRL_MME_2 0x0010
+#define PCIM_MSICTRL_MME_4 0x0020
+#define PCIM_MSICTRL_MME_8 0x0030
+#define PCIM_MSICTRL_MME_16 0x0040
+#define PCIM_MSICTRL_MME_32 0x0050
+#define PCIM_MSICTRL_MMC_MASK 0x000E
+#define PCIM_MSICTRL_MMC_1 0x0000
+#define PCIM_MSICTRL_MMC_2 0x0002
+#define PCIM_MSICTRL_MMC_4 0x0004
+#define PCIM_MSICTRL_MMC_8 0x0006
+#define PCIM_MSICTRL_MMC_16 0x0008
+#define PCIM_MSICTRL_MMC_32 0x000A
+#define PCIM_MSICTRL_MSI_ENABLE 0x0001
+#define PCIR_MSI_ADDR 0x4
+#define PCIR_MSI_ADDR_HIGH 0x8
+#define PCIR_MSI_DATA 0x8
+#define PCIR_MSI_DATA_64BIT 0xc
+#define PCIR_MSI_MASK 0x10
+#define PCIR_MSI_PENDING 0x14
+
+/* PCI-X definitions */
+#define PCIXR_COMMAND 0x96
+#define PCIXR_DEVADDR 0x98
+#define PCIXM_DEVADDR_FNUM 0x0003 /* Function Number */
+#define PCIXM_DEVADDR_DNUM 0x00F8 /* Device Number */
+#define PCIXM_DEVADDR_BNUM 0xFF00 /* Bus Number */
+#define PCIXR_STATUS 0x9A
+#define PCIXM_STATUS_64BIT 0x0001 /* Active 64bit connection to device. */
+#define PCIXM_STATUS_133CAP 0x0002 /* Device is 133MHz capable */
+#define PCIXM_STATUS_SCDISC 0x0004 /* Split Completion Discarded */
+#define PCIXM_STATUS_UNEXPSC 0x0008 /* Unexpected Split Completion */
+#define PCIXM_STATUS_CMPLEXDEV 0x0010 /* Device Complexity (set == bridge) */
+#define PCIXM_STATUS_MAXMRDBC 0x0060 /* Maximum Burst Read Count */
+#define PCIXM_STATUS_MAXSPLITS 0x0380 /* Maximum Split Transactions */
+#define PCIXM_STATUS_MAXCRDS 0x1C00 /* Maximum Cumulative Read Size */
+#define PCIXM_STATUS_RCVDSCEM 0x2000 /* Received a Split Comp w/Error msg */
diff --git a/bsps/powerpc/beatnik/net/porting/rtemscompat.h b/bsps/powerpc/beatnik/net/porting/rtemscompat.h
new file mode 100644
index 0000000000..62821eb9ff
--- /dev/null
+++ b/bsps/powerpc/beatnik/net/porting/rtemscompat.h
@@ -0,0 +1,456 @@
+#ifndef RTEMS_COMPAT_BSD_NET_H
+#define RTEMS_COMPAT_BSD_NET_H
+
+/* BSD -> rtems wrappers; stuff that must be defined
+ * prior to including most BSD headers
+ */
+
+/* Copyright: Till Straumann <strauman@slac.stanford.edu>, 2005;
+ * License: see LICENSE file.
+ */
+
+#include <rtems.h>
+#include <sys/errno.h>
+#include <sys/types.h>
+
+#include <stdlib.h>
+
+/* Check for RTEMS version; true if >= ma.mi.re */
+#define ISMINVERSION(ma,mi,re) \
+ ( __RTEMS_MAJOR__ > (ma) \
+ || (__RTEMS_MAJOR__ == (ma) && __RTEMS_MINOR__ > (mi)) \
+ || (__RTEMS_MAJOR__ == (ma) && __RTEMS_MINOR__ == (mi) && __RTEMS_REVISION__ >= (re)) \
+ )
+
+/* 'align' ARG is evaluated more than once */
+#define _DO_ALIGN(addr, align) (((uint32_t)(addr) + (align) - 1) & ~((align)-1))
+
+
+/* malloc/free are redefined :-( */
+static inline void *the_real_malloc(size_t n)
+{
+ return malloc(n);
+}
+
+static inline void the_real_free(void *p)
+{
+ return free(p);
+}
+
+#define __INSIDE_RTEMS_BSD_TCPIP_STACK__
+#include <rtems/rtems_bsdnet.h>
+#include <rtems/rtems_bsdnet_internal.h>
+#ifdef __i386__
+#include <libcpu/cpu.h>
+#elif defined(__PPC__)
+#include <libcpu/io.h>
+#else
+#error "dunno what IO ops to use on this architecture"
+#endif
+#include <rtems/bspIo.h>
+
+#define NET_EMB(x,y,z) x ## y ## z
+#define NET_EMBEMB(x,y,z) NET_EMB(x,y,z)
+
+#define NET_STR(arg) #arg
+#define NET_STRSTR(arg) NET_STR(arg)
+
+#define NET_SOFTC NET_EMBEMB(,NETDRIVER_PREFIX,_softc)
+
+#define METHODS NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_methods)
+extern struct _net_drv_tbl METHODS;
+
+#ifdef DEBUG_MODULAR
+#define METHODSPTR NET_EMBEMB(rtems_,NETDRIVER_PREFIX,_methods_p)
+extern struct _net_drv_tbl *volatile METHODSPTR;
+#else
+#define METHODSPTR (&METHODS)
+#endif
+
+#if defined(__LITTLE_ENDIAN__) || (__i386__)
+static inline uint16_t htole16(uint16_t v) { return v; }
+static inline uint32_t htole32(uint32_t v) { return v; }
+static inline uint64_t htole64(uint64_t v) { return v; }
+static inline uint16_t le16toh(uint16_t v) { return v; }
+static inline uint32_t le32toh(uint32_t v) { return v; }
+static inline uint64_t le64toh(uint64_t v) { return v; }
+#elif defined(__BIG_ENDIAN__)
+#ifdef __PPC__
+#include <libcpu/byteorder.h>
+
+/* Different RTEMS versions use different types
+ * for 32-bit (unsigned vs. unsigned long which
+ * always cause gcc warnings and possible alias
+ * violations, sigh).
+ */
+
+#if ISMINVERSION(4,8,0)
+typedef uint32_t rtemscompat_32_t;
+#else
+typedef unsigned rtemscompat_32_t;
+#endif
+
+static inline uint16_t
+htole16(uint16_t v)
+{
+uint16_t rval;
+ st_le16(&rval,v);
+ return rval;
+}
+
+static inline uint16_t
+le16toh(uint16_t v)
+{
+ return ld_le16((unsigned short*)&v);
+}
+
+static inline uint32_t
+htole32(uint32_t v)
+{
+rtemscompat_32_t rval;
+ st_le32(&rval,v);
+ return rval;
+}
+
+static inline uint32_t
+le32toh(uint32_t v)
+{
+rtemscompat_32_t vv = v;
+ return ld_le32(&vv);
+}
+
+/* Compiler generated floating point instructions for this
+ * and rtems_bsdnet_newproc()-generated tasks are non-FP
+ * :-(
+ */
+static inline uint64_t
+htole64(uint64_t v)
+{
+union {
+ rtemscompat_32_t tmp[2];
+ uint64_t rval;
+} u;
+
+ st_le32( &u.tmp[0], (unsigned)(v&0xffffffff) );
+ st_le32( &u.tmp[1], (unsigned)((v>>32)&0xffffffff) );
+
+ return u.rval;
+}
+
+#else
+#error "need htoleXX() implementation for this CPU arch"
+#endif
+
+#else
+#error "Unknown CPU endianness"
+#endif
+
+
+
+#ifdef __PPC__
+#define _out_byte(a,v) out_8((volatile uint8_t*)(a),(v))
+#define _inp_byte(a) in_8((volatile uint8_t*)(a))
+#ifdef NET_CHIP_LE
+#define _out_word(a,v) out_le16((volatile uint16_t*)(a),(v))
+#define _out_long(a,v) out_le32((volatile uint32_t *)(a),(v))
+#define _inp_word(a) in_le16((volatile uint16_t*)(a))
+#define _inp_long(a) in_le32((volatile uint32_t *)(a))
+#elif defined(NET_CHIP_BE)
+#define _out_word(a,v) out_be16((volatile uint16_t*)(a),(v))
+#define _out_long(a,v) out_be32((volatile uint32_t *)(a),(v))
+#define _inp_word(a) in_be16((volatile uint16_t*)(a))
+#define _inp_long(a) in_be32((volatile uint32_t *)(a))
+#else
+#error rtemscompat_defs.h must define either NET_CHIP_LE or NET_CHIP_BE
+#endif
+static inline void wrle32(unsigned *a, unsigned v)
+{
+ asm volatile("stwbrx %1,0,%2":"=m"(*a):"r"(v),"r"(a));
+}
+static inline unsigned rdle32(unsigned *a)
+{
+ asm volatile("lwbrx %0,0,%0":"=r"(a):"0"(a),"m"(*a));
+ return (unsigned)a;
+}
+static inline void orle32(unsigned *a,unsigned v) { wrle32(a, rdle32(a) | v); }
+static inline void anle32(unsigned *a,unsigned v) { wrle32(a, rdle32(a) & v); }
+
+static inline void wrle16(unsigned short *a, unsigned short v)
+{
+ asm volatile("sthbrx %1,0,%2":"=m"(*a):"r"(v),"r"(a));
+}
+static inline unsigned short rdle16(unsigned short *a)
+{
+ asm volatile("lhbrx %0,0,%0":"=r"(a):"0"(a),"m"(*a));
+ return (unsigned short)(unsigned)a;
+}
+static inline void orle16(unsigned short *a,unsigned short v) { wrle16(a, rdle16(a) | v); }
+static inline void anle16(unsigned short *a,unsigned short v) { wrle16(a, rdle16(a) & v); }
+#endif
+
+#ifdef __i386__
+#ifdef NET_CHIP_BE
+#error dunno how to output BE data
+#endif
+
+static inline void wrle32(volatile unsigned *p, unsigned v) { *p = v; }
+static inline void orle32(volatile unsigned *p, unsigned v) { *p |= v; }
+static inline void anle32(volatile unsigned *p, unsigned v) { *p &= v; }
+static inline unsigned rdle32(volatile unsigned *p) { return *p; }
+
+static inline void wrle16(volatile unsigned short *p, unsigned short v) { *p = v; }
+static inline void orle16(volatile unsigned short *p, unsigned short v) { *p |= v; }
+static inline void anle16(volatile unsigned short *p, unsigned short v) { *p &= v; }
+static inline unsigned short rdle16(volatile unsigned short *p) { return *p; }
+
+#ifdef NET_CHIP_MEM_IO
+
+#ifdef __i386__
+static inline void _out_byte(unsigned a, unsigned char v) { *(volatile unsigned char*)a = v; }
+static inline unsigned char _inp_byte(unsigned a) { return *(volatile unsigned char*)a; }
+#ifdef NET_CHIP_LE
+static inline void _out_word(unsigned a, unsigned short v) { *(volatile unsigned short*)a = v; }
+static inline unsigned short _inp_word(unsigned a) { return *(volatile unsigned short*)a; }
+static inline void _out_long(unsigned a, unsigned v) { *(volatile unsigned *)a = v; }
+static inline unsigned _inp_long(unsigned a) { return *(volatile unsigned *)a; }
+#elif defined(NET_CHIP_BE)
+#error "BE memory IO not implemented for i386 yet"
+#else
+#error rtemscompat_defs.h must define either NET_CHIP_LE or NET_CHIP_BE
+#endif
+#else
+
+#error "Memory IO not implemented for this CPU architecture yet"
+
+#endif
+#elif defined(NET_CHIP_PORT_IO)
+#define _out_byte(addr,val) outport_byte((addr),(val))
+#define _out_word(addr,val) outport_word((addr),(val))
+#define _out_long(addr,val) outport_long((addr),(val))
+
+static inline u_int8_t _inp_byte(volatile unsigned char *a)
+{
+register u_int8_t rval;
+ inport_byte((unsigned short)(unsigned)a,rval);
+ return rval;
+}
+static inline u_int16_t _inp_word(volatile unsigned short *a)
+{
+register u_int16_t rval;
+ inport_word((unsigned short)(unsigned)a,rval);
+ return rval;
+}
+static inline u_int32_t _inp_long(volatile unsigned *a)
+{
+register u_int32_t rval;
+ inport_long((unsigned short)(unsigned)a,rval);
+ return rval;
+}
+#else
+#error either NET_CHIP_MEM_IO or NET_CHIP_PORT_IO must be defined
+#endif
+#endif
+
+#ifndef __FBSDID
+#define __FBSDID(arg)
+#endif
+
+#define _KERNEL
+
+#define device_printf(device,format,args...) printk(format,## args)
+
+static inline u_int8_t bus_space_do_read_1(u_long handle, unsigned reg)
+{
+ return _inp_byte((volatile unsigned char*)((handle)+(reg)));
+}
+
+static inline u_int16_t bus_space_do_read_2(u_long handle, unsigned reg)
+{
+ return _inp_word((volatile unsigned short*)((handle)+(reg)));
+}
+
+static inline u_int32_t bus_space_do_read_4(u_long handle, unsigned reg)
+{
+ return _inp_long((volatile unsigned *)((handle)+(reg)));
+}
+
+#define bus_space_read_1(tag,handle,reg) bus_space_do_read_1((handle),(reg))
+#define bus_space_read_2(tag,handle,reg) bus_space_do_read_2((handle),(reg))
+#define bus_space_read_4(tag,handle,reg) bus_space_do_read_4((handle),(reg))
+
+static inline void bus_space_do_write_multi_1(u_long handle, unsigned reg, unsigned char *addr, int cnt)
+{
+ int i; for (i=0; i<cnt; i++) _out_byte( (handle) + (reg), (addr)[i]);
+}
+
+static inline void bus_space_do_write_multi_2(u_long handle, unsigned reg, unsigned short *addr, int cnt)
+{
+ int i; for (i=0; i<cnt; i++) _out_word( (handle) + (reg), (addr)[i]);
+}
+
+static inline void bus_space_do_write_multi_4(u_long handle, unsigned reg, unsigned long *addr, int cnt)
+{
+ int i; for (i=0; i<cnt; i++) _out_long( (handle) + (reg), (addr)[i]);
+}
+
+
+#define bus_space_write_multi_1(tag, handle, reg, addr, cnt) \
+ bus_space_do_write_multi_1(handle, reg, addr, cnt)
+#define bus_space_write_multi_2(tag, handle, reg, addr, cnt) \
+ bus_space_do_write_multi_2(handle, reg, addr, cnt)
+#define bus_space_write_multi_4(tag, handle, reg, addr, cnt) \
+ bus_space_do_write_multi_4(handle, reg, addr, cnt)
+
+static inline void bus_space_do_read_multi_1(u_long handle, unsigned reg, unsigned char *addr, int cnt)
+{
+ int i; for (i=0; i<cnt; i++)
+ (addr)[i] = _inp_byte((volatile unsigned char*)((handle)+(reg)));
+}
+
+static inline void bus_space_do_read_multi_2(u_long handle, unsigned reg, unsigned short *addr, int cnt)
+{
+ int i; for (i=0; i<cnt; i++)
+ (addr)[i] = _inp_word((volatile unsigned short*)((handle)+(reg)));
+}
+
+static inline void bus_space_do_read_multi_4(u_long handle, unsigned reg, unsigned long *addr, int cnt)
+{
+ int i; for (i=0; i<cnt; i++)
+ (addr)[i] = _inp_long((volatile unsigned *)((handle)+(reg)));
+}
+
+#define bus_space_read_multi_1(tag, handle, reg, addr, cnt) \
+ bus_space_do_read_multi_1(handle, reg, addr, cnt)
+#define bus_space_read_multi_2(tag, handle, reg, addr, cnt) \
+ bus_space_do_read_multi_2(handle, reg, addr, cnt)
+#define bus_space_read_multi_4(tag, handle, reg, addr, cnt) \
+ bus_space_do_read_multi_4(handle, reg, addr, cnt)
+
+
+
+#define bus_space_write_1(tag, handle, reg, val) \
+ do { _out_byte( (handle) + (reg), (val)); } while (0)
+
+#define bus_space_write_2(tag, handle, reg, val) \
+ do { _out_word( (handle) + (reg), (val)); } while (0)
+
+#define bus_space_write_4(tag, handle, reg, val) \
+ do { _out_long( (handle) + (reg), (val)); } while (0)
+
+#define BPF_MTAP(a,b) do { } while (0)
+
+extern unsigned net_driver_ticks_per_sec;
+
+#ifdef __PPC__
+/* PPC has a timebase - based delay */
+#define DELAY(n) do { \
+ if ( (n) > 10000 ) \
+ rtems_task_wake_after((((n)*net_driver_ticks_per_sec)/1000000) + 1); \
+ else \
+ rtems_bsp_delay(n); \
+ } while (0)
+#else
+#warning "Have no good usec delay implementation"
+#define DELAY(n) do { \
+ rtems_task_wake_after((((n)*net_driver_ticks_per_sec)/1000000) + 1); \
+ } while (0)
+#endif
+
+
+#define IRQ_LOCKED(code) \
+ do { unsigned long _xtre_irq_flags; \
+ rtems_interrupt_disable(_xtre_irq_flags); \
+ do { code } while(0); \
+ rtems_interrupt_enable(_xtre_irq_flags); \
+ } while (0)
+
+typedef void (driver_intr_t)(void *);
+
+#define if_xname if_name
+
+/* need to replace those with LOCAL2PCI() and make sure the bus handle is initialized
+ * (on most BSPs we get away with PCI_DRAM_OFFSET [no bus handle needed at all]
+ */
+#ifndef PCI_DRAM_OFFSET
+#define PCI_DRAM_OFFSET 0
+#endif
+
+#ifndef PCI_MEM_BASE
+#define PCI_MEM_BASE 0
+#endif
+
+#define kvtop(a) ((unsigned long)(a) + PCI_DRAM_OFFSET)
+#define vtophys(a) ((unsigned long)(a) + PCI_DRAM_OFFSET)
+
+#define PCI2LOCAL(a,bus) ((unsigned long)(a) + PCI_MEM_BASE)
+
+#ifdef PCI0_IO_BASE /* special mvme5500 hack :-( */
+#define PCI_IO_2LOCAL(a,bus) ((unsigned long)(a) + PCI0_IO_BASE)
+#elif defined(PCI_IO_BASE)
+#define PCI_IO_2LOCAL(a,bus) ((unsigned long)(a) + PCI_IO_BASE)
+#elif defined(_IO_BASE)
+#define PCI_IO_2LOCAL(a,bus) ((unsigned long)(a) + _IO_BASE)
+#else
+#warning "Unable to determine base address of PCI IO space; using ZERO"
+#define PCI_IO_2LOCAL(a,bus) ((unsigned long)(a))
+#endif
+
+#define if_printf(if,fmt,args...) printf("%s:"fmt,(if)->if_name,args)
+
+#ifndef BUS_PROBE_DEFAULT
+#define BUS_PROBE_DEFAULT 0
+#endif
+
+static inline void *
+contigmalloc(
+ unsigned long size,
+ int type,
+ int flags,
+ unsigned long lo,
+ unsigned long hi,
+ unsigned long align,
+ unsigned long bound)
+{
+void *ptr = rtems_bsdnet_malloc(size + sizeof(ptr) + align-1, type, flags);
+char *rval = 0;
+ if ( ptr ) {
+ unsigned tmp = (unsigned)ptr + align - 1;
+ tmp -= tmp % align;
+ rval = (char*)tmp;
+ /* save backlink */
+ *(void**)(rval+size) = ptr;
+ }
+ return rval;
+}
+
+static inline void
+contigfree(void *ptr, size_t size, int type)
+{
+ rtems_bsdnet_free( *(void**)((unsigned)ptr + size), type);
+}
+
+/* callout stuff */
+#define callout_init(args...) do {} while (0);
+#define callout_reset(args...) do {} while (0);
+#define callout_stop(args...) do {} while (0);
+
+#define IFQ_DRV_IS_EMPTY(q) (0 == (q)->ifq_head)
+#define IFQ_DRV_DEQUEUE(q,m) IF_DEQUEUE((q),(m))
+#define IFQ_DRV_PREPEND(q,m) IF_PREPEND((q),(m))
+
+#define DO_ETHER_INPUT_SKIPPING_ETHER_HEADER(ifp,m) \
+ { struct ether_header *eh; \
+ eh = mtod(m, struct ether_header*); \
+ m->m_data += sizeof(struct ether_header); \
+ m->m_len -= sizeof(struct ether_header); \
+ m->m_pkthdr.len -= sizeof(struct ether_header); \
+ m->m_pkthdr.rcvif = ifp; \
+ ether_input(ifp, eh, m); \
+ } while (0)
+
+
+#ifndef __KERNEL_RCSID
+#define __KERNEL_RCSID(arg...)
+#endif
+
+#endif
diff --git a/bsps/powerpc/beatnik/net/porting/rtemscompat1.h b/bsps/powerpc/beatnik/net/porting/rtemscompat1.h
new file mode 100644
index 0000000000..cee16522cc
--- /dev/null
+++ b/bsps/powerpc/beatnik/net/porting/rtemscompat1.h
@@ -0,0 +1,219 @@
+#ifndef RTEMS_COMPAT1_BSD_NET_H
+#define RTEMS_COMPAT1_BSD_NET_H
+
+/* BSD -> RTEMS conversion wrappers; stuff that must be defined
+ * after most BSD headers are included.
+ */
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+
+/* Copyright: Till Straumann <strauman@slac.stanford.edu>, 2005;
+ * License: see LICENSE file.
+ */
+
+typedef struct device {
+ struct NET_SOFTC d_softc; /* MUST BE FIRST FIELD */
+ char *d_name;
+ char *d_desc;
+ int d_unit;
+ int flags;
+ /* pointer to ifconfig only valid during excution of
+ * the n_attach/n_detach methods (see below)
+ */
+ struct rtems_bsdnet_ifconfig *d_ifconfig;
+} netdev_t;
+
+#define THEDEVS NET_EMBEMB(the_,NETDRIVER_PREFIX,_devs)
+#define NETDEV_DECL netdev_t THEDEVS[NETDRIVER_SLOTS]
+
+extern NETDEV_DECL;
+
+typedef struct _net_drv_tbl {
+ int (*n_probe)(device_t);
+ int (*n_attach)(device_t);
+ int (*n_detach)(device_t);
+ void (*n_intr)(void *);
+} net_drv_tbl_t;
+
+static inline netdev_t *
+net_dev_get(struct rtems_bsdnet_ifconfig *config)
+{
+ int unitNo;
+ char *unitName;
+
+ unitNo = rtems_bsdnet_parse_driver_name(config, &unitName);
+ if ( unitNo < 0 )
+ return 0;
+
+ if ( unitNo <=0 || unitNo > NETDRIVER_SLOTS ) {
+ device_printf(dev, "Bad "NETDRIVER" unit number.\n");
+ return 0;
+ }
+
+ if ( THEDEVS[unitNo-1].d_unit && THEDEVS[unitNo-1].d_unit != unitNo ) {
+ device_printf(dev, "Unit # mismatch !!??\n");
+ return 0;
+ }
+
+ THEDEVS[unitNo-1].d_unit = unitNo;
+ THEDEVS[unitNo-1].d_name = unitName;
+ THEDEVS[unitNo-1].d_ifconfig = config;
+
+ return &THEDEVS[unitNo - 1];
+}
+
+/* kludge; that's why softc needs to be first */
+static inline netdev_t *
+softc_get_device(struct NET_SOFTC *sc)
+{
+ return (netdev_t *)sc;
+}
+
+static inline struct NET_SOFTC *
+device_get_softc(netdev_t *dev)
+{ return &dev->d_softc; }
+
+static inline int
+device_get_unit(netdev_t *dev)
+{ return dev->d_unit; }
+
+static inline char *
+device_get_name(netdev_t *dev)
+{ return dev->d_name; }
+
+static inline void
+if_initname(struct ifnet *ifp, char *name, int unit)
+{
+ ifp->if_name = name;
+ ifp->if_unit = unit;
+}
+
+static inline void
+device_set_desc(netdev_t *dev, char *str)
+{
+ dev->d_desc = str;
+}
+
+static inline void
+device_set_desc_copy(netdev_t *dev, char *str)
+{
+ dev->d_desc = strdup(str);
+}
+
+
+static inline int
+device_is_attached(netdev_t *dev)
+{
+ return dev->d_softc.arpcom.ac_if.if_addrlist && dev->d_softc.arpcom.ac_if.if_init;
+}
+
+#ifdef NETDRIVER_PCI
+#include NETDRIVER_PCI
+#include "pcireg.h"
+
+static inline unsigned
+pci_read_config(device_t dev, unsigned addr, unsigned width)
+{
+rtemscompat_32_t d;
+unsigned short s;
+unsigned char b;
+struct NET_SOFTC *sc = device_get_softc(dev);
+ switch (width) {
+ case 1: pci_read_config_byte(sc->b, sc->d, sc->f, addr, &b);
+ return b;
+ case 2: pci_read_config_word(sc->b, sc->d, sc->f, addr, &s);
+ return s;
+ case 4: pci_read_config_dword(sc->b, sc->d, sc->f, addr, &d);
+ return d;
+ default:
+ break;
+ }
+ return 0xdeadbeef;
+}
+
+static inline void
+pci_write_config(device_t dev, unsigned addr, unsigned width, unsigned val)
+{
+struct NET_SOFTC *sc = device_get_softc(dev);
+ switch (width) {
+ case 1: pci_write_config_byte(sc->b, sc->d, sc->f, addr, val);
+ return ;
+ case 2: pci_write_config_word(sc->b, sc->d, sc->f, addr, val);
+ return ;
+ case 4: pci_write_config_dword(sc->b, sc->d, sc->f, addr, val);
+ return ;
+ default:
+ break;
+ }
+}
+
+
+static inline unsigned short
+pci_get_vendor(device_t dev)
+{
+ return pci_read_config(dev, PCIR_VENDOR, 2);
+}
+
+static inline unsigned short
+pci_get_device(device_t dev)
+{
+ return pci_read_config(dev, PCIR_DEVICE, 2);
+}
+
+static inline unsigned short
+pci_get_subvendor(device_t dev)
+{
+ return pci_read_config(dev, PCIR_SUBVEND_0, 2);
+}
+
+static inline unsigned short
+pci_get_subdevice(device_t dev)
+{
+ return pci_read_config(dev, PCIR_SUBDEV_0, 2);
+}
+
+
+static inline void
+pci_enable_busmaster(device_t dev)
+{
+ pci_write_config(
+ dev,
+ PCIR_COMMAND,
+ 2,
+ pci_read_config(dev, PCIR_COMMAND, 2)
+ | PCIM_CMD_BUSMASTEREN);
+}
+
+#define mtx_init(a,b,c,d) do {} while(0)
+#define mtx_initialized(ma) (1)
+#define mtx_destroy(ma) do {} while(0)
+#define mtx_lock(a) do {} while(0)
+#define mtx_unlock(a) do {} while(0)
+#define mtx_assert(a,b) do {} while(0)
+
+#define callout_handle_init(x) do {} while (0)
+#define untimeout(a...) do {} while (0)
+
+#if !ISMINVERSION(4,6,99)
+#define pci_bus_count BusCountPCI
+#endif
+
+#endif
+
+/* Ugly hack to allow unloading/reloading the driver core.
+ * Needed because rtems' bsdnet release doesn't implement
+ * if_detach(). Therefore, we bring the interface down but
+ * keep the device record alive...
+ */
+static inline void
+__ether_ifdetach(struct ifnet *ifp)
+{
+ ifp->if_flags = 0;
+ ifp->if_ioctl = 0;
+ ifp->if_start = 0;
+ ifp->if_watchdog = 0;
+ ifp->if_init = 0;
+}
+
+#endif
diff --git a/bsps/powerpc/beatnik/net/porting/rtemscompat_defs.h.template b/bsps/powerpc/beatnik/net/porting/rtemscompat_defs.h.template
new file mode 100644
index 0000000000..5dc8d1efff
--- /dev/null
+++ b/bsps/powerpc/beatnik/net/porting/rtemscompat_defs.h.template
@@ -0,0 +1,97 @@
+#ifndef RTEMS_COMPAT_DEFS_H
+#define RTEMS_COMPAT_DEFS_H
+
+/* Symbol definitions for a particular driver */
+
+/* Copyright: Till Straumann <strauman@slac.stanford.edu>, 2005;
+ * License: see LICENSE file.
+ */
+
+/* Number of device instances the driver should support
+ * - may be limited to 1 depending on IRQ API
+ * (braindamaged PC586 and powerpc)
+ */
+#define NETDRIVER_SLOTS 1
+/* String name to print with error messages */
+#define NETDRIVER "PCN"
+/* Name snippet used to make global symbols unique to this driver */
+#define NETDRIVER_PREFIX pcn
+
+/* Define according to endianness of the *ethernet*chip*
+ * (not the CPU - most probably are LE)
+ * This must be either NET_CHIP_LE or NET_CHIP_BE
+ */
+
+#define NET_CHIP_LE
+#undef NET_CHIP_BE
+
+/* Define either NET_CHIP_MEM_IO or NET_CHIP_PORT_IO,
+ * depending whether the CPU sees it in memory address space
+ * or (e.g. x86) uses special I/O instructions.
+ */
+#define NET_CHIP_MEM_IO
+#undef NET_CHIP_PORT_IO
+
+/* The name of the hijacked 'bus handle' field in the softc
+ * structure. We use this field to store the chip's base address.
+ */
+#define NET_SOFTC_BHANDLE_FIELD pcn_bhandle
+
+/* define the names of the 'if_XXXreg.h' and 'if_XXXvar.h' headers
+ * (only if present, i.e., if the BSDNET driver has no respective
+ * header, leave this undefined).
+ *
+ */
+#undef IF_REG_HEADER <if_XXXreg.h>
+#undef IF_VAR_HEADER <if_XXXvar.h>
+
+/* define if a pci device */
+#define NETDRIVER_PCI <bsp/pci.h>
+
+/* Macros to disable and enable interrupts, respectively.
+ * The 'disable' macro is expanded in the ISR, the 'enable'
+ * macro is expanded in the driver task.
+ * The global network semaphore usually provides mutex
+ * protection of the device registers.
+ * Special care must be taken when coding the 'disable' macro,
+ * however to MAKE SURE THERE ARE NO OTHER SIDE EFFECTS such
+ * as:
+ * - macro must not clear any status flags
+ * - macro must save/restore any context information
+ * (e.g., a address register pointer or a bank switch register)
+ *
+ * ARGUMENT: the macro arg is a pointer to the driver's 'softc' structure
+ */
+
+/* Here EXAMPLES for the pcnet chip which addresses registers indirectly
+ * through a 'address-pointer' (RAP) and 'data-port' (RDP) register pair:
+#define NET_DISABLE_IRQS(sc) do { \
+ unsigned rap = CSR_READ_4((sc),PCN_IO32_RAP); \
+ unsigned val; \
+ CSR_WRITE_4((sc),PCN_IO32_RAP,PCN_CSR_CSR); \
+ val = CSR_READ_4((sc),PCN_IO32_RDP); \
+ CSR_WRITE_4((sc), PCN_IO32_RDP, val & ~(CSR0_INT_STATUS_MASK | PCN_CSR_INTEN)); \
+ CSR_WRITE_4((sc), PCN_IO32_RAP, rap); \
+ } while (0)
+
+#define NET_ENABLE_IRQS(sc) do { \
+ unsigned flags,val; \
+ rtems_interrupt_disable(flags); \
+ CSR_WRITE_4((sc),PCN_IO32_RAP,PCN_CSR_CSR); \
+ val = CSR_READ_4((sc),PCN_IO32_RDP); \
+ CSR_WRITE_4((sc), PCN_IO32_RDP, (val & ~CSR0_INT_STATUS_MASK) | PCN_CSR_INTEN); \
+ rtems_interrupt_enable(flags); \
+ } while (0)
+*/
+
+/* Driver may provide a macro/function to copy the hardware address
+ * from the device into 'softc.arpcom'.
+ * If this is undefined, the driver must to the copy itself.
+ * Preferrably, it should check soft.arpcom.ac_enaddr for all
+ * zeros and leave it alone if it is nonzero, i.e., write it
+ * to the hardware.
+#define NET_READ_MAC_ADDR(sc)
+ */
+
+#define KASSERT(a...) do {} while (0)
+#endif