This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Updates to ks32c5000 eth driver


Chris Garry wrote:
The attached patch allows the ks32c5000 eth driver to use a MAC address
stored in RedBoot's configuration data in FLASH.

Also included is a patch previously submitted on 13-May-2003 to allow the
lwIP stack to be supported by this driver.

Thanks! I've applied this now, but with a few minor changes. I've attached what I actually applied.


Jifl
--
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/devs/eth/arm/ks32c5000/current/ChangeLog,v
retrieving revision 1.13
diff -u -5 -p -r1.13 ChangeLog
--- ChangeLog	9 Apr 2003 20:23:22 -0000	1.13
+++ ChangeLog	24 Jun 2003 04:52:03 -0000
@@ -1,5 +1,20 @@
+2003-06-24  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* src/ks5000_ether.c: Some tidies of the previous changes.
+	* cdl/ks32c5000_eth.cdl: Clarify option description and rename
+	CYGVAR_DEVS_ETH_ARM_KS32C5000_REDBOOT_HOLDS_ESA_ETH0 to
+	CYGSEM_DEVS_ETH_ARM_KS32C5000_REDBOOT_HOLDS_ESA_ETH0.
+
+2003-05-26  Chris Garry  <cgarry@sweeneydesign.co.uk>
+	
+	* cdl/ks32c5000_eth.cdl: Added support for MAC address to be used
+	from RedBoot's FLASH configuration data.
+	* src/ks5000_ether.c: Updated driver to work with LWIP stack as
+	well as the BSD stack. Added support for MAC address to be used
+	from RedBoot's FLASH configuration data.
+
 2003-04-08  Michael Checky  <Michael_Checky@Thermoking.com>
 
 	* cdl/ks32c5000_eth.cdl: CYGINT_DEVS_ETH_ARM_KS32C5000_PHY can now
 	be zero or one to allow for no PHY station management control.
 	* src/ks5000_ether.c: Changed '#if HavePHY' to
Index: cdl/ks32c5000_eth.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/devs/eth/arm/ks32c5000/current/cdl/ks32c5000_eth.cdl,v
retrieving revision 1.8
diff -u -5 -p -r1.8 ks32c5000_eth.cdl
--- cdl/ks32c5000_eth.cdl	9 Apr 2003 20:23:22 -0000	1.8
+++ cdl/ks32c5000_eth.cdl	24 Jun 2003 04:52:03 -0000
@@ -153,14 +153,53 @@ cdl_package CYGPKG_DEVS_ETH_ARM_KS32C500
             legal_values 0 to 31
             default_value 1
             description   "This option specifies the MII address of the PHY"
         }
 
+        cdl_component CYGPKG_DEVS_ETH_ARM_KS32C5000_REDBOOT_HOLDS_ESA {
+        display         "RedBoot manages ESA initialization data"
+        flavor          bool
+        default_value   0
+    
+        active_if     CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
+        active_if     (CYGPKG_REDBOOT || CYGSEM_HAL_USE_ROM_MONITOR)
+
+        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_ARM_KS32C5000_REDBOOT_HOLDS_ESA_VARS {
+                display        "Export RedBoot command to set ESA in FLASH config"
+                flavor         none
+                no_define
+    
+                description "
+                This component contains options which, when enabled, allow
+                RedBoot to support the setting of the ESA in the FLASH
+                configuration. This can then subsequently be accessed by
+                applications using virtual vector calls if those applications
+                are also built with
+                CYGPKG_DEVS_ETH_ARM_KS32C5000_REDBOOT_HOLDS_ESA enabled."
+    
+                cdl_option CYGSEM_DEVS_ETH_ARM_KS32C5000_REDBOOT_HOLDS_ESA_ETH0 {
+                    display         "RedBoot manages ESA for eth0"
+                    flavor          bool
+                    default_value   1
+                    active_if       CYGSEM_REDBOOT_FLASH_CONFIG
+                    active_if       CYGPKG_REDBOOT_NETWORKING
+                }
+            }
+        }
+
         cdl_option CYGPKG_DEVS_ETH_ARM_KS32C5000_MACADDR {
-            display "Ethernet address for eth0"
+            display "Ethernet station (MAC) address for eth0"
             flavor  data
             default_value {"0x08, 0x88, 0x12, 0x34, 0x56, 0x78"}
+            description   "The default ethernet station address. This is the
+                           MAC address used when no value is found in the
+                           RedBoot FLASH configuration field."
         }
 
         cdl_option  CYGPKG_DEVS_ETH_ARM_KS32C5000_CFLAGS_ADD {
             display "Additional compiler flags"
             flavor  data
Index: src/ks5000_ether.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/devs/eth/arm/ks32c5000/current/src/ks5000_ether.c,v
retrieving revision 1.12
diff -u -5 -p -r1.12 ks5000_ether.c
--- src/ks5000_ether.c	9 Apr 2003 20:23:22 -0000	1.12
+++ src/ks5000_ether.c	24 Jun 2003 04:52:04 -0000
@@ -53,18 +53,22 @@
 
 #include <pkgconf/system.h>
 #include <pkgconf/devs_eth_arm_ks32c5000.h>
 #include <pkgconf/io_eth_drivers.h>
 
+#include <errno.h>
 #if defined(CYGPKG_IO)
 #include <pkgconf/io.h>
 #include <cyg/io/io.h>
 #include <cyg/io/devtab.h>
-#else
-// need to provide fake values for errno
-#define EIO 1
-#define EINVAL 2
+#endif
+// need to provide fake values for errno?
+#ifndef EIO
+# define EIO 1
+#endif
+#ifndef EINVAL
+# define EINVAL 2
 #endif
 
 #include <cyg/infra/cyg_type.h>  // Common type definitions and support
                                  // including endian-ness
 #include <cyg/infra/diag.h>
@@ -75,11 +79,11 @@
 
 #if defined(CYGPKG_REDBOOT)
 #include <pkgconf/redboot.h>
 #endif
 
-#if !defined(CYGPKG_NET)
+#ifndef CYGINT_IO_ETH_INT_SUPPORT_REQUIRED
 #define cyg_drv_interrupt_unmask(v) /* noop */
 #define cyg_drv_interrupt_mask(v)   /* noop */
 #define cyg_drv_isr_lock()          /* noop */
 #define cyg_drv_isr_unlock()        /* noop */
 #define cyg_drv_mutex_init(m)       /* noop */
@@ -121,10 +125,46 @@
 #include <cyg/crc/crc.h>
 #else
 #define SoftwareCRC 0
 #endif
 
+// --------------------------------------------------------------
+// RedBoot configuration options for managing ESAs for us
+
+// Decide whether to have redboot config vars for it...
+#if defined(CYGSEM_REDBOOT_FLASH_CONFIG) && defined(CYGPKG_REDBOOT_NETWORKING)
+#include <redboot.h>
+#include <flash_config.h>
+
+#ifdef CYGSEM_DEVS_ETH_ARM_KS32C5000_REDBOOT_HOLDS_ESA_ETH0
+RedBoot_config_option("Network hardware address [MAC] for eth0",
+                      eth0_esa_data,
+                      ALWAYS_ENABLED, true,
+                      CONFIG_ESA, 0);
+#endif
+
+#endif  // CYGPKG_REDBOOT_NETWORKING && CYGSEM_REDBOOT_FLASH_CONFIG
+
+// and initialization code to read them
+// - independent of whether we are building RedBoot right now:
+#ifdef CYGPKG_DEVS_ETH_ARM_KS32C5000_REDBOOT_HOLDS_ESA
+
+#include <cyg/hal/hal_if.h>
+
+#ifndef CONFIG_ESA
+#define CONFIG_ESA (6)
+#endif
+
+#define CYGHWR_DEVS_ETH_ARM_KS32C5000_GET_ESA( mac_address, ok )                 \
+CYG_MACRO_START                                                                  \
+    ok = CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET,              \
+                                      "eth0_esa_data", mac_address, CONFIG_ESA); \
+CYG_MACRO_END
+
+#endif // CYGPKG_DEVS_ETH_I82559_ETH_REDBOOT_HOLDS_ESA
+
+
 #if CYGINT_DEVS_ETH_ARM_KS32C5000_PHY
 // functions to read/write Phy chip registers via MII interface
 // on 32c5000.  These need to be non-static since they're used
 // by PHY-specific routines in a different file.
 #define PHYREGWRITE	0x0400
@@ -180,14 +220,17 @@ typedef struct
   U8 LengthOrType[2];
   U8 LLCData[1506];
 } MAC_FRAME;
 
 #if defined(CYGPKG_NET)
-static cyg_drv_mutex_t txMutex;
 struct ether_drv_stats ifStats;
 #endif
 
+#if defined(CYGINT_IO_ETH_INT_SUPPORT_REQUIRED)
+static cyg_drv_mutex_t txMutex;
+#endif
+
 typedef struct
 {
   LWORD BTxNLErr;
   LWORD BTxNOErr;
   LWORD BTxEmptyErr;
@@ -475,11 +518,11 @@ static void initFreeList(void)
 //
 // returns true if buffer was queued.
 
 static int ks32c5000_eth_buffer_send(tEthBuffer *buf)
 {
-#if defined(CYGPKG_NET)  
+#if defined(CYGINT_IO_ETH_INT_SUPPORT_REQUIRED)
   while (!configDone)
     cyg_thread_delay(10);
 #endif
 
   if (txWritePointer->FrameDataPtr & FRM_OWNERSHIP_BDMA)
@@ -657,11 +700,10 @@ static int EthInit(U08* mac_address)
   MACCON = MACConfigVar;
 	 
   CAMCON = CAMConfigVar;
   
   // set up our MAC address
-
   if (mac_address)
     {
       *((volatile U32*)CAM_BaseAddr) = 
         (mac_address[0]<<24) |
         (mac_address[1]<<16) |
@@ -1122,15 +1164,22 @@ ks32c5000_priv_data_t ks32c5000_priv_dat
 
 #define eth_drv_tx_done(sc,key,retval) (sc)->funs->eth_drv->tx_done(sc,key,retval)
 #define eth_drv_init(sc,enaddr)  ((sc)->funs->eth_drv->init)(sc, enaddr)
 #define eth_drv_recv(sc,len)  ((sc)->funs->eth_drv->recv)(sc, len)
 
-static unsigned char myMacAddr[6] = { CYGPKG_DEVS_ETH_ARM_KS32C5000_MACADDR };
-
 static bool ks32c5000_eth_init(struct cyg_netdevtab_entry *tab)
 {
+  unsigned char myMacAddr[6] = { CYGPKG_DEVS_ETH_ARM_KS32C5000_MACADDR };
   struct eth_drv_sc *sc = (struct eth_drv_sc *)tab->device_instance;
+  bool ok;
+
+#ifdef CYGHWR_DEVS_ETH_ARM_KS32C5000_GET_ESA
+  // Get MAC address from RedBoot configuration variables
+  CYGHWR_DEVS_ETH_ARM_KS32C5000_GET_ESA(&myMacAddr[0], ok);
+  // If this call fails myMacAddr is unchanged and MAC address from CDL is used
+#endif
+
   debug1_printf("ks32c5000_eth_init()\n");
   debug1_printf("  MAC address %02x:%02x:%02x:%02x:%02x:%02x\n",myMacAddr[0],myMacAddr[1],myMacAddr[2],myMacAddr[3],myMacAddr[4],myMacAddr[5]);
 #if defined(CYGPKG_NET)  
   ifStats.duplex = 1;      //unknown
   ifStats.operational = 1; //unknown
@@ -1381,5 +1430,7 @@ ETH_DRV_SC(ks32c5000_sc,
 
 NETDEVTAB_ENTRY(ks32c5000_netdev, 
                 "ks32c5000", 
                 ks32c5000_eth_init, 
                 &ks32c5000_sc);
+
+// EOF ks5000_ether.c

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]