This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
davicom dm9000 driver
- From: Mark Salter <msalter at redhat dot com>
- To: ecos-patches at sources dot redhat dot com
- Date: Mon, 6 Sep 2004 08:59:28 -0400 (EDT)
- Subject: davicom dm9000 driver
Lacks irq support, so RedBoot-only for now.
--Mark
Index: packages/ecos.db
===================================================================
RCS file: /cvs/ecos/ecos/packages/ecos.db,v
retrieving revision 1.130
diff -u -p -5 -r1.130 ecos.db
--- packages/ecos.db 5 Sep 2004 20:56:08 -0000 1.130
+++ packages/ecos.db 6 Sep 2004 12:52:50 -0000
@@ -1416,10 +1416,18 @@ package CYGPKG_DEVS_ETH_AMD_LANCEPCI {
directory devs/eth/amd/lancepci
script amd_lancepci_eth_drivers.cdl
description "Ethernet driver for AMD Lance PCI controller (vmWare)."
}
+package CYGPKG_DEVS_ETH_DAVICOM_DM9000 {
+ alias { "Davicom DM9000 ethernet driver" dm9000_eth_driver }
+ hardware
+ directory devs/eth/davicom/dm9000
+ script davicom_dm9000_eth_drivers.cdl
+ description "Ethernet driver for Davicom DM9000 controller."
+}
+
package CYGPKG_DEVS_ETH_MIPS_MIPS32_MALTA {
alias { "MIPS Malta board ethernet driver" malta_eth_driver }
hardware
directory devs/eth/mips/malta
script mips_mips32_malta_eth_drivers.cdl
@@ -3785,10 +3793,20 @@ package CYGPKG_DEVS_ETH_FRV_PDK403 {
script pdk403_eth_drivers.cdl
description "Ethernet driver for Fujitsu MB93093-PD00 Portable
Demonstration Kit with AXL88796 Ethernet device"
}
+package CYGPKG_DEVS_ETH_FRV_CB70 {
+ alias { "Fujitsu FR-V 405 with DM9000 ethernet driver"
+ devs_eth_frv_cb70 cb70_eth_driver }
+ hardware
+ directory devs/eth/frv/cb70
+ script cb70_eth_driver.cdl
+ description "Ethernet driver for Fujitsu FR-V 405 CB70 CPU card with
+ Davicom DM9000 ethernet interface."
+}
+
# --------------------------------------------------------------------------
# ==========================================================================
# --------------------------------------------------------------------------
Index: packages/devs/eth/davicom/dm9000/current/ChangeLog
===================================================================
RCS file: packages/devs/eth/davicom/dm9000/current/ChangeLog
diff -N packages/devs/eth/davicom/dm9000/current/ChangeLog
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ packages/devs/eth/davicom/dm9000/current/ChangeLog 6 Sep 2004 12:52:50 -0000
@@ -0,0 +1,38 @@
+2004-09-05 Mark Salter <msalter@redhat.com>
+
+ Initial Checkin of DM9000 Ethernet driver (RedBoot only for now).
+
+//===========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//===========================================================================
Index: packages/devs/eth/davicom/dm9000/current/cdl/davicom_dm9000_eth_drivers.cdl
===================================================================
RCS file: packages/devs/eth/davicom/dm9000/current/cdl/davicom_dm9000_eth_drivers.cdl
diff -N packages/devs/eth/davicom/dm9000/current/cdl/davicom_dm9000_eth_drivers.cdl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ packages/devs/eth/davicom/dm9000/current/cdl/davicom_dm9000_eth_drivers.cdl 6 Sep 2004 12:52:50 -0000
@@ -0,0 +1,94 @@
+# ====================================================================
+#
+# davicom_dm9000_eth_drivers.cdl
+#
+# Davicom dm9000 ethernet driver
+#
+# ====================================================================
+#####ECOSGPLCOPYRIGHTBEGIN####
+## -------------------------------------------
+## This file is part of eCos, the Embedded Configurable Operating System.
+## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
+##
+## eCos is free software; you can redistribute it and/or modify it under
+## the terms of the GNU General Public License as published by the Free
+## Software Foundation; either version 2 or (at your option) any later version.
+##
+## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+## WARRANTY; without even the implied warranty of MERCHANTABILITY or
+## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+## for more details.
+##
+## You should have received a copy of the GNU General Public License along
+## with eCos; if not, write to the Free Software Foundation, Inc.,
+## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+##
+## As a special exception, if other files instantiate templates or use macros
+## or inline functions from this file, or you compile this file and link it
+## with other works to produce a work based on this file, this file does not
+## by itself cause the resulting work to be covered by the GNU General Public
+## License. However the source code for this file must still be made available
+## in accordance with section (3) of the GNU General Public License.
+##
+## This exception does not invalidate any other reasons why a work based on
+## this file might be covered by the GNU General Public License.
+##
+## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+## at http://sources.redhat.com/ecos/ecos-license/
+## -------------------------------------------
+#####ECOSGPLCOPYRIGHTEND####
+# ====================================================================
+######DESCRIPTIONBEGIN####
+#
+# Author(s): msalter
+# Original data:
+# Contributors:
+# Date: 2004-3-18
+#
+#####DESCRIPTIONEND####
+#
+# ====================================================================
+
+cdl_package CYGPKG_DEVS_ETH_DAVICOM_DM9000 {
+ display "Davicom DM9000 ethernet driver"
+ description "Ethernet driver for Davicom DM9000 NIC."
+
+ parent CYGPKG_IO_ETH_DRIVERS
+ active_if CYGPKG_IO_ETH_DRIVERS
+
+ active_if CYGINT_DEVS_ETH_DAVICOM_DM9000_REQUIRED
+
+ define_proc {
+ puts $::cdl_header "#include CYGDAT_DEVS_ETH_DAVICOM_DM9000_CFG";
+ }
+
+ compile -library=libextras.a if_dm9000.c
+
+ cdl_option CYGNUM_DEVS_ETH_DAVICOM_DM9000_DEV_COUNT {
+ display "Number of supported interfaces."
+ calculated { CYGINT_DEVS_ETH_DAVICOM_DM9000_REQUIRED }
+ flavor data
+ description "
+ This option selects the number of PCMCIA cards to
+ be supported by the driver."
+ }
+
+ cdl_component CYGPKG_DEVS_ETH_DAVICOM_DM9000_OPTIONS {
+ display "Davicom dm9000 ethernet driver build options"
+ flavor none
+ no_define
+
+ cdl_option CYGPKG_DEVS_ETH_DAVICOM_DM9000_CFLAGS_ADD {
+ display "Additional compiler flags"
+ flavor data
+ no_define
+ default_value { "" }
+ description "
+ This option modifies the set of compiler flags for
+ building the Davicom DM9000 ethernet driver package.
+ These flags are used in addition to the set of
+ global flags."
+ }
+ }
+}
+# EOF davicom_dm9000_eth_drivers.cdl
Index: packages/devs/eth/davicom/dm9000/current/include/dm9000_info.h
===================================================================
RCS file: packages/devs/eth/davicom/dm9000/current/include/dm9000_info.h
diff -N packages/devs/eth/davicom/dm9000/current/include/dm9000_info.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ packages/devs/eth/davicom/dm9000/current/include/dm9000_info.h 6 Sep 2004 12:52:50 -0000
@@ -0,0 +1,73 @@
+#ifndef CYGONCE_DEVS_ETH_DAVICOM_DM9000_INFO_H
+#define CYGONCE_DEVS_ETH_DAVICOM_DM9000_INFO_H
+/*==========================================================================
+//
+// dm9000_info.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): msalter
+// Contributors:
+// Date: 2004-03-18
+// Description:
+//
+//####DESCRIPTIONEND####
+*/
+
+#include <pkgconf/devs_eth_davicom_dm9000.h>
+
+struct dm9000 {
+ struct eth_drv_sc *sc;
+ cyg_uint8 active; // interface is active
+ cyg_uint8 reset_pending;
+ cyg_uint8 txbusy;
+ cyg_uint8 mac_address[6];
+ cyg_uint16 rxlen;
+ unsigned long txkey;
+ volatile unsigned char *io_addr; // addr register
+ volatile unsigned char *io_data; // data register
+ int (*read_data)(struct dm9000 *p, cyg_uint8 *dest);
+ int (*write_data)(struct dm9000 *p, cyg_uint8 *src);
+ int buswidth;
+};
+
+#define CYGDAT_DEVS_ETH_DESCRIPTION "Davicom DM9000 Ethernet"
+
+#endif
+
+/* EOF dm9000_info.h */
Index: packages/devs/eth/davicom/dm9000/current/src/if_dm9000.c
===================================================================
RCS file: packages/devs/eth/davicom/dm9000/current/src/if_dm9000.c
diff -N packages/devs/eth/davicom/dm9000/current/src/if_dm9000.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ packages/devs/eth/davicom/dm9000/current/src/if_dm9000.c 6 Sep 2004 12:52:50 -0000
@@ -0,0 +1,867 @@
+//==========================================================================
+//
+// if_dm9000.c
+//
+// Davicom DM9000 ethernet driver
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2003, 2004 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): msalter
+// Contributors: msalter
+// Date: 2004-03-18
+// Purpose:
+// Description: hardware driver for Davicom DM9000 NIC
+// Notes:
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/system.h>
+#include <pkgconf/io_eth_drivers.h>
+#include <pkgconf/devs_eth_davicom_dm9000.h>
+#include <cyg/infra/cyg_type.h>
+#include <cyg/infra/cyg_ass.h>
+#include <cyg/hal/hal_arch.h>
+#include <cyg/hal/hal_cache.h>
+#include <cyg/hal/hal_intr.h>
+#include <cyg/hal/hal_endian.h>
+#include <cyg/infra/diag.h>
+#include <cyg/hal/hal_if.h>
+#include <cyg/hal/drv_api.h>
+#include <cyg/io/eth/netdev.h>
+#include <cyg/io/eth/eth_drv.h>
+
+#include <dm9000_info.h>
+
+#ifdef CYGPKG_REDBOOT
+#include <pkgconf/redboot.h>
+#include <redboot.h>
+#include <flash_config.h>
+#endif
+
+#include CYGDAT_DEVS_ETH_DAVICOM_DM9000_INL
+
+#define DM9000_PKT_MAX 1536
+
+//
+// Control and Status register offsets
+//
+#define DM_NCR 0x00
+#define DM_NSR 0x01
+#define DM_TCR 0x02
+#define DM_TSRI 0x03
+#define DM_TSRII 0x04
+#define DM_RCR 0x05
+#define DM_RSR 0x06
+#define DM_ROCR 0x07
+#define DM_BPTR 0x08
+#define DM_FCTR 0x09
+#define DM_FCR 0x0a
+#define DM_EPCR 0x0b
+#define DM_EPAR 0x0c
+#define DM_EPDRL 0x0d
+#define DM_EPDRH 0x0e
+#define DM_WCR 0x0f
+#define DM_PAR 0x10
+#define DM_MAR 0x16
+#define DM_GPCR 0x1e
+#define DM_GPR 0x1f
+#define DM_TRPAL 0x22
+#define DM_TRPAH 0x23
+#define DM_RWPAL 0x24
+#define DM_RWPAH 0x25
+#define DM_VIDL 0x28
+#define DM_VIDH 0x29
+#define DM_PIDL 0x2a
+#define DM_PIDH 0x2b
+#define DM_CHIPR 0x2c
+#define DM_SMCR 0x2f
+#define DM_MRCMDX 0xf0
+#define DM_MRCMD 0xf2
+#define DM_MDRAL 0xf4
+#define DM_MDRAH 0xf5
+#define DM_MWCMDX 0xf6
+#define DM_MWCMD 0xf8
+#define DM_MDWAL 0xfa
+#define DM_MDWAH 0xfb
+#define DM_TXPLL 0xfc
+#define DM_TXPLH 0xfd
+#define DM_ISR 0xfe
+#define DM_IMR 0xff
+
+// NCR (Network Control Register)
+#define NCR_EXT_PHY (1 << 7) // 1 ==> external PHY, 0 ==> internal
+#define NCR_WAKEEN (1 << 6) // enable wakeup events
+#define NCR_FCOL (1 << 4) // force collision mode (test)
+#define NCR_FDX (1 << 3) // full duplex (read-only for internal phy)
+#define NCR_LBK_NOR (0 << 1) // loopback off
+#define NCR_LBK_MAC (1 << 1) // MAC loopback
+#define NCR_LBK_PHY (2 << 1) // PHY loopback
+#define NCR_RST (1 << 0) // Reset (auto-clears after 10us)
+
+// NSR (Network Status Register)
+#define NSR_SPEED (1 << 7) // 0 = 100Mbps, 1 = 10Mbps
+#define NSR_LINKST (1 << 6) // link status (1 = okay)
+#define NSR_WAKEST (1 << 5) // wake status (clear by read)
+#define NSR_TX2END (1 << 3) // TX packet 2 complete
+#define NSR_TX1END (1 << 2) // TX packet 1 complete
+#define NSR_RXOV (1 << 1) // RX overflow
+
+// TCR (TX Control Register)
+#define TCR_TJDIS (1 << 6) // TX jabber disable
+#define TCR_EXCECM (1 << 5) // 0 = abort after 15 collisions
+#define TCR_PAD_DIS2 (1 << 4)
+#define TCR_CRC_DIS2 (1 << 3)
+#define TCR_PAD_DIS1 (1 << 2)
+#define TCR_CRC_DIS1 (1 << 1)
+#define TCR_TXREQ (1 << 0)
+
+// TSR (TX Status Register)
+#define TSR_TJTO (1 << 7)
+#define TSR_LC (1 << 6)
+#define TSR_NC (1 << 5)
+#define TSR_LCOL (1 << 4)
+#define TSR_COL (1 << 3)
+#define TSR_EC (1 << 2)
+
+// RCR (RX Control Register)
+#define RCR_WTDIS (1 << 6)
+#define RCR_DIS_LONG (1 << 5)
+#define RCR_DIS_CRC (1 << 4)
+#define RCR_ALL (1 << 3)
+#define RCR_RUNT (1 << 2)
+#define RCR_PRMSC (1 << 1)
+#define RCR_RXEN (1 << 0)
+
+// RSR (RX Status Register)
+#define RSR_RF (1 << 7)
+#define RSR_MF (1 << 6)
+#define RSR_LCS (1 << 5)
+#define RSR_RWTO (1 << 4)
+#define RSR_PLE (1 << 3)
+#define RSR_AE (1 << 2)
+#define RSR_CE (1 << 1)
+#define RSR_FOE (1 << 0)
+
+// FCR (Flow Control Register)
+#define FCR_TXPO (1 << 7)
+#define FCR_TXPF (1 << 6)
+#define FCR_TXPEN (1 << 5)
+#define FCR_BKPA (1 << 4)
+#define FCR_BKPM (1 << 3)
+#define FCR_RXPS (1 << 2)
+#define FCR_RXPCS (1 << 1)
+#define FCR_FLCE (1 << 0)
+
+// EPCR (EEPROM & PHY Control Register)
+#define EPCR_REEP (1 << 5)
+#define EPCR_WEP (1 << 4)
+#define EPCR_EPOS (1 << 3)
+#define EPCR_ERPRR (1 << 2)
+#define EPCR_ERPRW (1 << 1)
+#define EPCR_ERRE (1 << 0)
+
+// WCR (Wakeup Control Register)
+#define WCR_LINKEN (1 << 5)
+#define WCR_SAMPLEEN (1 << 4)
+#define WCR_MAGICEN (1 << 3)
+#define WCR_LINKST (1 << 2)
+#define WCR_SAMPLEST (1 << 1)
+#define WCR_MAGIGST (1 << 0)
+
+// SMCR (Special Mode Control Register)
+#define SMCR_SM_EN (1 << 7)
+#define SMCR_FLC (1 << 2)
+#define SMCR_FB1 (1 << 1)
+#define SMCR_FB0 (1 << 0)
+
+// ISR (Interrupt Status Register)
+#define ISR_IOMODE_16 (0 << 6)
+#define ISR_IOMODE_32 (1 << 6)
+#define ISR_IOMODE_8 (2 << 6)
+#define ISR_ROOS (1 << 3)
+#define ISR_ROS (1 << 2)
+#define ISR_PTS (1 << 1)
+#define ISR_PRS (1 << 0)
+
+// IMR (Interrupt Mask Register)
+#define IMR_PAR (1 << 7)
+#define IMR_ROOM (1 << 3)
+#define IMR_ROM (1 << 2)
+#define IMR_PTM (1 << 1)
+#define IMR_PRM (1 << 0)
+
+
+// Read one datum from 8-bit bus
+static int read_data_8(struct dm9000 *p, cyg_uint8 *dest)
+{
+ HAL_READ_UINT8(p->io_data, *dest);
+ return 1;
+}
+
+// Read one datum from 16-bit bus
+static int read_data_16(struct dm9000 *p, cyg_uint8 *dest)
+{
+ cyg_uint16 val;
+
+ HAL_READ_UINT16(p->io_data, val);
+ memcpy(dest, &val, 2);
+ return 2;
+}
+
+// Read one datum from 32-bit bus
+static int read_data_32(struct dm9000 *p, cyg_uint8 *dest)
+{
+ cyg_uint32 val;
+
+ HAL_READ_UINT32(p->io_data, val);
+ memcpy(dest, &val, 4);
+ return 4;
+}
+
+
+// Write one datum to 8-bit bus
+static int write_data_8(struct dm9000 *p, cyg_uint8 *src)
+{
+ HAL_WRITE_UINT8(p->io_data, *src);
+ return 1;
+}
+
+// Write one datum to 16-bit bus
+static int write_data_16(struct dm9000 *p, cyg_uint8 *src)
+{
+ cyg_uint16 val;
+
+ memcpy(&val, src, 2);
+ HAL_WRITE_UINT16(p->io_data, val);
+ return 2;
+}
+
+// Write one datum to 32-bit bus
+static int write_data_32(struct dm9000 *p, cyg_uint8 *src)
+{
+ cyg_uint32 val;
+
+ memcpy(&val, src, 4);
+ HAL_WRITE_UINT32(p->io_data, val);
+ return 4;
+}
+
+
+
+// Return one byte from DM9000 register
+static cyg_uint8 getreg(struct dm9000 *p, cyg_uint8 reg)
+{
+ cyg_uint8 val;
+ HAL_WRITE_UINT8(p->io_addr, reg);
+ HAL_READ_UINT8(p->io_data, val);
+ return val;
+}
+
+// Write one byte to DM9000 register
+static void putreg(struct dm9000 *p, cyg_uint8 reg, cyg_uint8 val)
+{
+ HAL_WRITE_UINT8(p->io_addr, reg);
+ HAL_WRITE_UINT8(p->io_data, val);
+}
+
+// Read a word from EEPROM
+static cyg_uint16 eeprom_read(struct dm9000 *p, int offset)
+{
+ putreg(p, DM_EPAR, offset);
+ putreg(p, DM_EPCR, EPCR_ERPRR);
+ while (getreg(p, DM_EPCR) & EPCR_ERRE)
+ ;
+ CYGACC_CALL_IF_DELAY_US(200);
+ putreg(p, DM_EPCR, 0);
+ return getreg(p, DM_EPDRL) | (getreg(p, DM_EPDRH) << 8);
+}
+
+// Write a word to EEPROM
+static void eeprom_write(struct dm9000 *p, int offset, cyg_uint16 val)
+{
+ putreg(p, DM_EPAR, offset);
+ putreg(p, DM_EPDRH, val >> 8);
+ putreg(p, DM_EPDRL, val);
+ putreg(p, DM_EPCR, EPCR_WEP | EPCR_ERPRW);
+ while (getreg(p, DM_EPCR) & EPCR_ERRE)
+ ;
+ CYGACC_CALL_IF_DELAY_US(200);
+ putreg(p, DM_EPCR, 0);
+}
+
+// Reload info from EEPROM
+static void eeprom_reload(struct dm9000 *p)
+{
+ putreg(p, DM_EPCR, EPCR_REEP);
+ while (getreg(p, DM_EPCR) & EPCR_ERRE)
+ ;
+ CYGACC_CALL_IF_DELAY_US(200);
+ putreg(p, DM_EPCR, 0);
+}
+
+
+// Read a word from PHY
+static cyg_uint16 phy_read(struct dm9000 *p, int offset)
+{
+ putreg(p, DM_EPAR, 0x40 + offset);
+ putreg(p, DM_EPCR, EPCR_EPOS | EPCR_ERPRR);
+ CYGACC_CALL_IF_DELAY_US(200);
+ putreg(p, DM_EPCR, 0);
+ return getreg(p, DM_EPDRL) | (getreg(p, DM_EPDRH) << 8);
+}
+
+// Write a word to PHY
+static void phy_write(struct dm9000 *p, int offset, cyg_uint16 val)
+{
+ putreg(p, DM_EPAR, 0x40 + offset);
+ putreg(p, DM_EPDRL, val);
+ putreg(p, DM_EPDRH, val >> 8);
+ putreg(p, DM_EPCR, EPCR_EPOS | EPCR_ERPRW);
+ CYGACC_CALL_IF_DELAY_US(500);
+ putreg(p, DM_EPCR, 0);
+}
+
+
+static void init_phy(struct dm9000 *p)
+{
+ phy_write(p, 4, 0x1e1); // Advertise 10/100 half/full duplex w/CSMA
+ phy_write(p, 0, 0x1200); // enable autoneg
+
+ // release reset
+ putreg(p, DM_GPCR, 1);
+ putreg(p, DM_GPR, 0);
+}
+
+
+static inline void dm9000_reset(struct dm9000 *p)
+{
+ putreg(p, DM_NCR, NCR_RST);
+ CYGACC_CALL_IF_DELAY_US(100);
+}
+
+static int initialize_nic(struct dm9000 *priv)
+{
+ int i;
+
+ dm9000_reset(priv);
+
+ switch (getreg(priv, DM_ISR) >> 6) {
+ case 0:
+ priv->read_data = read_data_16;
+ priv->write_data = write_data_16;
+ priv->buswidth = 2;
+ break;
+ case 1:
+ priv->read_data = read_data_32;
+ priv->write_data = write_data_32;
+ priv->buswidth = 4;
+ break;
+ case 2:
+ priv->read_data = read_data_8;
+ priv->write_data = write_data_8;
+ priv->buswidth = 1;
+ break;
+ default:
+ diag_printf("Unknown DM9000 bus i/f.\n");
+ return 0;
+ }
+
+ init_phy(priv);
+
+ putreg(priv, DM_TCR, 0);
+ putreg(priv, DM_BPTR, 0x3f);
+ putreg(priv, DM_FCTR, 0x38);
+ putreg(priv, DM_FCR, 0xff);
+ putreg(priv, DM_SMCR, 0);
+ putreg(priv, DM_NSR, NSR_WAKEST | NSR_TX1END | NSR_TX2END);
+ putreg(priv, DM_ISR, ISR_ROOS | ISR_ROS | ISR_PTS | ISR_PRS);
+
+ // set MAC address
+ for (i = 0; i < 6; i++)
+ putreg(priv, DM_PAR + i, priv->mac_address[i]);
+
+ // clear multicast table except for broadcast address
+ for (i = 0; i < 6; i++)
+ putreg(priv, DM_MAR + i, 0x00);
+ putreg(priv, DM_MAR + 6, 0x00);
+ putreg(priv, DM_MAR + 7, 0x80);
+
+ return 1;
+}
+
+
+// ------------------------------------------------------------------------
+//
+// API Function : dm9000_init
+//
+// ------------------------------------------------------------------------
+static bool
+dm9000_init(struct cyg_netdevtab_entry * ndp)
+{
+ struct eth_drv_sc *sc;
+ struct dm9000 *priv;
+ int i;
+ unsigned id;
+ unsigned short u16tab[64];
+
+ sc = (struct eth_drv_sc *)ndp->device_instance;
+ priv = (struct dm9000 *)sc->driver_private;
+
+ priv->sc = sc;
+
+#ifdef CYG_HAL_DM9000_PRESENT
+ if (!CYG_HAL_DM9000_PRESENT())
+ return 0;
+#endif
+
+ id = getreg(priv, DM_VIDL);
+ id |= getreg(priv, DM_VIDH) << 8;
+ id |= getreg(priv, DM_PIDL) << 16;
+ id |= getreg(priv, DM_PIDH) << 24;
+
+ if (id != 0x90000A46)
+ return 0;
+
+ for (i = 0; i < 64; i++)
+ u16tab[i] = eeprom_read(priv, i);
+
+ u16tab[3] &= ~0xc;
+ u16tab[3] |= 4;
+ u16tab[6] &= 0xfe00;
+ u16tab[6] |= 6;
+
+#if 0
+ eeprom_write(priv, 6, u16tab[6]);
+ eeprom_write(priv, 3, u16tab[3]);
+#endif
+
+ eeprom_reload(priv);
+
+ do {
+ for (i = 0; i < 64; i++)
+ u16tab[i] = eeprom_read(priv, i);
+ } while ((u16tab[0] | u16tab[1] | u16tab[2]) == 0);
+
+ priv->mac_address[0] = u16tab[0];
+ priv->mac_address[1] = u16tab[0] >> 8;
+ priv->mac_address[2] = u16tab[1];
+ priv->mac_address[3] = u16tab[1] >> 8;
+ priv->mac_address[4] = u16tab[2];
+ priv->mac_address[5] = u16tab[2] >> 8;
+
+ if (!initialize_nic(priv))
+ return 0;
+
+ // Initialize upper level driver
+ (sc->funs->eth_drv->init)(sc, &(priv->mac_address[0]) );
+ return 1;
+}
+
+// ------------------------------------------------------------------------
+//
+// API Function : dm9000_start
+//
+// ------------------------------------------------------------------------
+static void
+dm9000_start( struct eth_drv_sc *sc, unsigned char *enaddr, int flags )
+{
+ struct dm9000 *priv = (struct dm9000 *)sc->driver_private;
+
+ // turn on receiver
+ putreg(priv, DM_RCR, RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN);
+
+ // unmask interrupt
+ putreg(priv, DM_IMR, IMR_PAR | IMR_PTM | IMR_PRM);
+
+ priv->active = 1;
+}
+
+// ------------------------------------------------------------------------
+//
+// API Function : dm9000_stop
+//
+// ------------------------------------------------------------------------
+static void
+dm9000_stop( struct eth_drv_sc *sc )
+{
+ struct dm9000 *priv = (struct dm9000 *)sc->driver_private;
+
+ // turn on receiver
+ putreg(priv, DM_RCR, 0);
+
+ // mask interrupts
+ putreg(priv, DM_IMR, IMR_PAR);
+
+ priv->active = 0;
+}
+
+
+// ------------------------------------------------------------------------
+//
+// API Function : dm9000_recv
+//
+// ------------------------------------------------------------------------
+static void
+dm9000_recv( struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len )
+{
+ struct dm9000 *priv = (struct dm9000 *)sc->driver_private;
+ struct eth_drv_sg *sg = sg_list;
+ cyg_uint8 tmpbuf[4];
+ char *p;
+ int len, total_len, nread, n, leftover;
+
+ total_len = priv->rxlen;
+ nread = leftover = 0;
+
+// diag_printf("dm9000_recv: total_len=%d\n", total_len);
+
+ do {
+ p = (char *)sg->buf;
+ len = sg->len;
+
+// diag_printf("recv: buf=%p len=%d to_read=%d, leftover=%d\n", p, len, total_len - nread, leftover);
+
+ if ((nread + len) > total_len)
+ len = total_len - nread;
+
+ if (leftover) {
+ if (leftover <= len) {
+ memcpy(p, tmpbuf + (sizeof(tmpbuf) - leftover), leftover);
+ p += leftover;
+ len -= leftover;
+ nread += leftover;
+ leftover = 0;
+ } else {
+ memcpy(p, tmpbuf + (sizeof(tmpbuf) - leftover), len);
+ leftover -= len;
+ p += len;
+ nread += len;
+ len = 0;
+ }
+ }
+
+ while (len >= sizeof(tmpbuf)) {
+ n = priv->read_data(priv, p);
+ nread += n;
+ len -= n;
+ p += n;
+ }
+
+ while (len > 0) {
+ n = priv->read_data(priv, tmpbuf);
+ if (n <= len) {
+ memcpy(p, tmpbuf, n);
+ len -= n;
+ nread += n;
+ p += n;
+ } else {
+ memcpy(p, tmpbuf, len);
+ nread += len;
+ leftover = n - len;
+ len = 0;
+ }
+ }
+
+ ++sg;
+ } while (nread < total_len);
+
+#if 0
+ // dump packet
+ for (sg = sg_list; sg < (sg_list + sg_len); sg++) {
+ diag_printf("\n");
+ diag_dump_buf(sg->buf, sg->len);
+ }
+#endif
+}
+
+// ------------------------------------------------------------------------
+//
+// API Function : dm9000_can_send
+//
+// ------------------------------------------------------------------------
+static int
+dm9000_can_send(struct eth_drv_sc *sc)
+{
+ struct dm9000 *priv = (struct dm9000 *)sc->driver_private;
+
+ if (!priv->active || priv->txbusy || priv->reset_pending)
+ return 0;
+
+ return 1;
+}
+
+
+// ------------------------------------------------------------------------
+//
+// API Function : dm9000_send
+//
+// ------------------------------------------------------------------------
+static void
+dm9000_send(struct eth_drv_sc *sc,
+ struct eth_drv_sg *sg_list, int sg_len,
+ int total_len, unsigned long key)
+{
+ struct dm9000 *priv = (struct dm9000 *)sc->driver_private;
+ struct eth_drv_sg *sg = sg_list;
+ cyg_uint8 tmpbuf[4];
+ int i, len, extra, n, save_len;
+ char *p;
+
+ if (0) {
+ diag_printf("dm9000_send: NCR[%02x] NSR[%02x] TPL[%02x]\n",
+ getreg(priv, DM_NCR), getreg(priv, DM_NSR),
+ getreg(priv, DM_TRPAL) | (getreg(priv, DM_TRPAH) << 8)
+ );
+ }
+
+ priv->txbusy = 1;
+
+ save_len = total_len;
+ extra = 0;
+
+ HAL_WRITE_UINT8(priv->io_addr, DM_MWCMD);
+
+ while (total_len > 0) {
+ len = sg->len;
+ if (len > total_len)
+ len = total_len;
+ p = (char *)sg->buf;
+
+ if (extra) {
+ n = sizeof(tmpbuf) - extra;
+ memcpy(tmpbuf + extra, p, n);
+ p += n;
+ len -= n;
+ for (i = 0; i < sizeof(tmpbuf) && total_len > 0; i += n) {
+ n = priv->write_data(priv, tmpbuf + i);
+ total_len -= n;
+ }
+ extra = 0;
+ }
+
+ while (len >= sizeof(tmpbuf) && total_len > 0) {
+ n = priv->write_data(priv, p);
+ len -= n;
+ total_len -= n;
+ p += n;
+ }
+
+ if (len > 0 && total_len > 0) {
+ extra = len;
+ memcpy(tmpbuf, p, extra);
+
+ if ((total_len - extra) <= 0) {
+ // go ahead and write it now
+ for (i = 0; total_len > 0; i += n, total_len -= n) {
+ n = priv->write_data(priv, tmpbuf + i);
+ total_len = 0;
+ }
+ break;
+ }
+ }
+ sg++;
+ }
+
+ priv->txkey = key;
+
+ putreg(priv, DM_TXPLL, save_len);
+ putreg(priv, DM_TXPLH, save_len >> 8);
+
+ putreg(priv, DM_TCR, TCR_TXREQ);
+
+ return;
+}
+
+// ------------------------------------------------------------------------
+//
+// API Function : dm9000_poll
+//
+// ------------------------------------------------------------------------
+static void
+dm9000_poll(struct eth_drv_sc *sc)
+{
+ struct dm9000 *priv = (struct dm9000 *)sc->driver_private;
+ cyg_uint8 status, rxstat, rx1;
+ cyg_uint16 pkt_stat, pkt_len;
+ int i;
+
+ // mask interrupts
+ putreg(priv, DM_IMR, IMR_PAR);
+
+ // get and clear staus
+ status = getreg(priv, DM_ISR);
+ putreg(priv, DM_ISR, status);
+
+ // check for rx done
+ if (1 /*status & ISR_PRS*/) {
+
+ rx1 = getreg(priv, DM_MRCMDX);
+ HAL_READ_UINT8(priv->io_data, rxstat);
+
+ // check for packet ready
+ if (rxstat == 1) {
+ cyg_uint16 u16[2];
+ cyg_uint8 *cp;
+
+ HAL_WRITE_UINT8(priv->io_addr, DM_MRCMD);
+ for (i = 0, cp = (cyg_uint8 *)u16; i < 4; )
+ i += priv->read_data(priv, cp + i);
+
+ u16[0] = CYG_LE16_TO_CPU(u16[0]);
+ u16[1] = CYG_LE16_TO_CPU(u16[1]);
+
+#if (CYG_BYTEORDER == CYG_MSBFIRST)
+ pkt_stat = u16[0];
+ pkt_len = u16[1];
+#else
+ pkt_stat = u16[1];
+ pkt_len = u16[0];
+#endif
+
+#ifdef DEBUG
+ diag_printf("pkt_stat=%04x pkt_len=%04x\n", pkt_stat, pkt_len);
+#endif
+
+ if (pkt_len < 0x40) {
+ diag_printf("packet too short: %d (0x%04x)\n", pkt_len, pkt_len);
+ i = 0;
+ while (i < pkt_len)
+ i += priv->read_data(priv, cp);
+ } else if (pkt_len > 1536) {
+ priv->reset_pending = 1;
+ diag_printf("packet too long: %d (0x%04x)\n", pkt_len, pkt_len);
+ } else if (pkt_stat & 0xbf00) {
+ diag_printf("bad packet status: 0x%04x\n", pkt_stat);
+ i = 0;
+ while (i < pkt_len)
+ i += priv->read_data(priv, cp);
+ } else {
+ // receive packet
+ priv->rxlen = pkt_len;
+ (sc->funs->eth_drv->recv)(sc, pkt_len);
+ }
+
+ } else if (rxstat > 1) {
+ // this should never happen.
+ diag_printf("unknown rxstat byte: %d\n", rxstat);
+ priv->reset_pending = 1;
+ }
+ }
+
+
+ // check transmit status
+ if (status & ISR_PTS) {
+ cyg_uint8 txstat;
+
+ txstat = getreg(priv, DM_NSR);
+
+ if (txstat & (NSR_TX1END | NSR_TX2END)) {
+ if (txstat & NSR_TX1END)
+ txstat = getreg(priv, DM_TSRI);
+ else
+ txstat = getreg(priv, DM_TSRII);
+
+ if (txstat & TSR_COL) {
+ // collision
+ }
+
+ if (getreg(priv, DM_TRPAL) & 3) {
+ // NIC bug detected. Need to reset.
+ priv->reset_pending = 1;
+ diag_printf("NIC collision bug detected!\n");
+ }
+
+ (sc->funs->eth_drv->tx_done)(sc, priv->txkey, 0);
+ priv->txbusy = 0;
+ }
+ }
+
+ if (priv->reset_pending && !priv->txbusy) {
+ initialize_nic(priv);
+
+ // turn on receiver
+ putreg(priv, DM_RCR, RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN);
+
+ priv->reset_pending = 0;
+ }
+
+ // unmask interrupts
+ putreg(priv, DM_IMR, IMR_PAR | IMR_PTM | IMR_PRM);
+}
+
+
+// ------------------------------------------------------------------------
+//
+// API Function : dm9000_deliver
+//
+// ------------------------------------------------------------------------
+static void
+dm9000_deliver(struct eth_drv_sc *sc)
+{
+ dm9000_poll(sc);
+}
+
+// ------------------------------------------------------------------------
+//
+// API Function : dm9000_int_vector
+//
+// ------------------------------------------------------------------------
+static int
+dm9000_int_vector(struct eth_drv_sc *sc)
+{
+ struct dm9000 *priv;
+ priv = (struct dm9000 *)sc->driver_private;
+
+ return -1;
+}
+
+
+// ------------------------------------------------------------------------
+//
+// API Function : dm9000_ioctl
+//
+// ------------------------------------------------------------------------
+static int
+dm9000_ioctl(struct eth_drv_sc *sc, unsigned long key,
+ void *data, int data_length)
+{
+ return -1;
+}
+
+// ------------------------------------------------------------------------
+// EOF if_dm9000.c
Index: packages/devs/eth/frv/cb70/current/ChangeLog
===================================================================
RCS file: packages/devs/eth/frv/cb70/current/ChangeLog
diff -N packages/devs/eth/frv/cb70/current/ChangeLog
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ packages/devs/eth/frv/cb70/current/ChangeLog 6 Sep 2004 12:52:50 -0000
@@ -0,0 +1,38 @@
+2004-09-05 Mark Salter <msalter@redhat.com>
+
+ * Initial checkin.
+
+//===========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2003, 2004 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//===========================================================================
Index: packages/devs/eth/frv/cb70/current/cdl/cb70_eth_driver.cdl
===================================================================
RCS file: packages/devs/eth/frv/cb70/current/cdl/cb70_eth_driver.cdl
diff -N packages/devs/eth/frv/cb70/current/cdl/cb70_eth_driver.cdl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ packages/devs/eth/frv/cb70/current/cdl/cb70_eth_driver.cdl 6 Sep 2004 12:52:50 -0000
@@ -0,0 +1,148 @@
+# ====================================================================
+#
+# cb70_eth_driver.cdl
+#
+# Ethernet driver
+# CB70 w/DM9000 platform specific support
+#
+# ====================================================================
+#####ECOSGPLCOPYRIGHTBEGIN####
+## -------------------------------------------
+## This file is part of eCos, the Embedded Configurable Operating System.
+## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+##
+## eCos is free software; you can redistribute it and/or modify it under
+## the terms of the GNU General Public License as published by the Free
+## Software Foundation; either version 2 or (at your option) any later version.
+##
+## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+## WARRANTY; without even the implied warranty of MERCHANTABILITY or
+## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+## for more details.
+##
+## You should have received a copy of the GNU General Public License along
+## with eCos; if not, write to the Free Software Foundation, Inc.,
+## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+##
+## As a special exception, if other files instantiate templates or use macros
+## or inline functions from this file, or you compile this file and link it
+## with other works to produce a work based on this file, this file does not
+## by itself cause the resulting work to be covered by the GNU General Public
+## License. However the source code for this file must still be made available
+## in accordance with section (3) of the GNU General Public License.
+##
+## This exception does not invalidate any other reasons why a work based on
+## this file might be covered by the GNU General Public License.
+##
+## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+## at http://sources.redhat.com/ecos/ecos-license/
+## -------------------------------------------
+#####ECOSGPLCOPYRIGHTEND####
+# ====================================================================
+######DESCRIPTIONBEGIN####
+#
+# Author(s):
+# Original data: msalter
+# Contributors:
+# Date: 2004-03-22
+#
+#####DESCRIPTIONEND####
+#
+# ====================================================================
+
+cdl_package CYGPKG_DEVS_ETH_FRV_CB70 {
+ display "cb70 CPU board with Davicom DM9000 ethernet driver"
+ parent CYGPKG_IO_ETH_DRIVERS
+ active_if CYGPKG_IO_ETH_DRIVERS
+ active_if CYGPKG_HAL_FRV_MB93091
+
+ include_dir cyg/io
+
+ # FIXME: This really belongs in the DM9000 package
+ cdl_interface CYGINT_DEVS_ETH_DAVICOM_DM9000_REQUIRED {
+ display "Davicom DM9000 ethernet driver required"
+ }
+
+ define_proc {
+ puts $::cdl_system_header "/***** ethernet driver proc output start *****/"
+ puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_DAVICOM_DM9000_INL <cyg/io/cb70_eth_driver.inl>"
+
+ puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_DAVICOM_DM9000_CFG <pkgconf/devs_eth_frv_cb70.h>"
+
+ puts $::cdl_system_header "/***** ethernet driver proc output end *****/"
+ }
+
+
+ cdl_component CYGPKG_DEVS_ETH_FRV_CB70_ETH0 {
+ display "cb70 ethernet port driver for builtin Davicom DM9000"
+ flavor bool
+ default_value 1
+ description "
+ This option includes the Davicom DM9000 ethernet device driver for a
+ CB70 CPU board."
+
+ implements CYGHWR_NET_DRIVERS
+ implements CYGHWR_NET_DRIVER_ETH0
+ implements CYGINT_DEVS_ETH_DAVICOM_DM9000_REQUIRED
+
+ cdl_option CYGDAT_DEVS_ETH_FRV_CB70_ETH0_NAME {
+ display "Device name for the ETH0 ethernet port driver"
+ flavor data
+ default_value {"\"eth0\""}
+ description "
+ This option sets the name of the ethernet device for a
+ DM9000-based CB70 CPU card."
+ }
+ }
+
+
+ cdl_component CYGPKG_DEVS_ETH_DM9000_ETH_REDBOOT_HOLDS_ESA {
+ display "RedBoot manages ESA initialization data"
+ flavor bool
+ default_value 0
+
+ active_if CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
+
+ description "Enabling this option will allow the ethernet
+ station address to be acquired from RedBoot's configuration data,
+ stored in flash memory. It can be overridden individually by the
+ 'Set the ethernet station address' option for each interface."
+
+ cdl_component CYGPKG_DEVS_ETH_DM9000_ETH_REDBOOT_HOLDS_ESA_VARS {
+ display "Build-in flash config fields for ESAs"
+ flavor bool
+ default_value 0
+
+ active_if CYGPKG_REDBOOT
+ active_if CYGPKG_REDBOOT_FLASH
+ active_if CYGSEM_REDBOOT_FLASH_CONFIG
+ active_if CYGPKG_REDBOOT_NETWORKING
+
+ description "
+ This option controls the presence of RedBoot flash
+ configuration fields for the ESAs of the interfaces when you
+ are building RedBoot. It is independent of whether RedBoot
+ itself uses the network or any particular interface; this
+ support is more for the application to use than for RedBoot
+ itself, though the application gets at the data by vector
+ calls; this option cannot be enabled outside of building
+ RedBoot."
+
+ cdl_option CYGVAR_ETH_DM9000_REDBOOT_HOLDS_ESA_ETH0 {
+ display "RedBoot manages ESA for eth0"
+ flavor bool
+ default_value 0
+ }
+
+ cdl_option CYGDAT_DEVS_ETH_FRV_CB70_ETH0_DEFAULT_ESA {
+ display "The ethernet station address"
+ flavor data
+ default_value {"{0x00, 0x03, 0x47, 0xdf, 0x32, 0xa8}"}
+ description "The default ethernet station address. This is the
+ address used as the default value in the RedBoot
+ flash configuration field."
+ }
+ }
+ }
+}
+
Index: packages/devs/eth/frv/cb70/current/include/cb70_eth_driver.inl
===================================================================
RCS file: packages/devs/eth/frv/cb70/current/include/cb70_eth_driver.inl
diff -N packages/devs/eth/frv/cb70/current/include/cb70_eth_driver.inl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ packages/devs/eth/frv/cb70/current/include/cb70_eth_driver.inl 6 Sep 2004 12:52:50 -0000
@@ -0,0 +1,158 @@
+//==========================================================================
+//
+// cb70_eth_drivers.inl
+//
+// cb70's DM9000 ethernet I/O definitions.
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):
+// Contributors:msalter
+// Date: 2004-03-22
+// Purpose: dm9000 ethernet definitions
+//####DESCRIPTIONEND####
+//==========================================================================
+
+#include <cyg/hal/hal_intr.h> // CYGNUM_HAL_INTERRUPT_ETHERNET
+#include <cyg/hal/hal_cache.h> // HAL_DCACHE_LINE_SIZE
+#include <cyg/hal/plf_io.h> // CYGARC_UNCACHED_ADDRESS
+
+extern int cyg_hal_dm9000_present(void);
+
+#define CYG_HAL_DM9000_PRESENT() cyg_hal_dm9000_present()
+
+#ifdef CYGPKG_DEVS_ETH_FRV_CB70_ETH0
+
+static struct dm9000 dm9000_eth0_priv_data = {
+#if defined(CYGPKG_REDBOOT) && defined(CYGVAR_ETH_DM9000_REDBOOT_HOLDS_ESA_ETH0)
+ mac_address: CYGDAT_DEVS_ETH_FRV_CB70_ETH0_DEFAULT_ESA,
+#endif
+ io_addr: (volatile unsigned char *)0xf0600300,
+ io_data: (volatile unsigned char *)0xf0600304
+};
+
+ETH_DRV_SC(dm9000_sc0,
+ &dm9000_eth0_priv_data, // Driver specific data
+ CYGDAT_DEVS_ETH_FRV_CB70_ETH0_NAME, // Name for device
+ dm9000_start,
+ dm9000_stop,
+ dm9000_ioctl,
+ dm9000_can_send,
+ dm9000_send,
+ dm9000_recv,
+ dm9000_deliver,
+ dm9000_poll,
+ dm9000_int_vector
+ );
+
+NETDEVTAB_ENTRY(dm9000_netdev0,
+ "dm9000_" CYGDAT_DEVS_ETH_FRV_CB70_ETH0_NAME,
+ dm9000_init,
+ &dm9000_sc0);
+#endif // CYGPKG_DEVS_ETH_FRV_CB70_ETH0
+
+
+// These arrays are used for sanity checking of pointers
+struct dm9000 *
+dm9000_priv_array[CYGNUM_DEVS_ETH_DAVICOM_DM9000_DEV_COUNT] = {
+#ifdef CYGPKG_DEVS_ETH_FRV_CB70_ETH0
+ &dm9000_eth0_priv_data,
+#endif
+};
+
+#ifdef CYGDBG_USE_ASSERTS
+// These are only used when assertions are enabled
+cyg_netdevtab_entry_t *
+dm9000_netdev_array[CYGNUM_DEVS_ETH_DAVICOM_DM9000_DEV_COUNT] = {
+#ifdef CYGPKG_DEVS_ETH_FRV_CB70_ETH0
+ &dm9000_netdev0,
+#endif
+};
+
+struct eth_drv_sc *
+dm9000_sc_array[CYGNUM_DEVS_ETH_DAVICOM_DM9000_DEV_COUNT] = {
+#ifdef CYGPKG_DEVS_ETH_FRV_CB70_ETH0
+ &dm9000_sc0,
+#endif
+};
+#endif // CYGDBG_USE_ASSERTS
+
+// --------------------------------------------------------------
+// RedBoot configuration options for managing ESAs for us
+
+// Decide whether to have redboot config vars for it...
+#ifdef CYGPKG_REDBOOT
+#include <pkgconf/redboot.h>
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+#ifdef CYGPKG_REDBOOT_NETWORKING
+#include <redboot.h>
+#include <flash_config.h>
+
+#ifdef CYGVAR_DEVS_ETH_DM9000_REDBOOT_HOLDS_ESA_ETH0
+RedBoot_config_option("Network hardware address [MAC] for eth0",
+ eth0_esa,
+ ALWAYS_ENABLED, true,
+ CONFIG_ESA, dm9000_eth0_priv_data.mac_address
+ );
+#endif
+
+#endif // CYGPKG_REDBOOT_NETWORKING
+#endif // CYGSEM_REDBOOT_FLASH_CONFIG
+#endif // CYGPKG_REDBOOT
+
+// and initialization code to read them
+// - independent of whether we are building RedBoot right now:
+#ifdef CYGPKG_DEVS_ETH_DM9000_ETH_REDBOOT_HOLDS_ESA
+
+#include <cyg/hal/hal_if.h>
+
+#ifndef CONFIG_ESA
+#define CONFIG_ESA (6)
+#endif
+
+#define CYGHWR_DEVS_ETH_DAVICOM_DM9000_GET_ESA( p_dm9000, mac_address, ok ) \
+CYG_MACRO_START \
+ ok = false; \
+ if ( 0 == p_dm9000->index ) \
+ ok = CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET, \
+ "eth0_esa", mac_address, CONFIG_ESA); \
+ else if ( 1 == p_dm9000->index ) \
+ ok = CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET, \
+ "eth1_esa", mac_address, CONFIG_ESA); \
+CYG_MACRO_END
+
+#endif // CYGPKG_DEVS_ETH_DM9000_ETH_REDBOOT_HOLDS_ESA