This is the mail archive of the ecos-patches@sourceware.org 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]

Use RedBoot flash config to initialize eth0


Hi,

This patch adds CYGHWR_NET_DRIVER_ETH0_REDBOOT option which allows to
use redboot flash configuration to initialize 'eth0'. It's useful when
ecos application has the same network configuration as redboot.

Best regards
Alexey Shusharin

diff -bur /opt/ecos-repo/cvs/ecos/packages/net/common/current/cdl/net.cdl ./net/common/current/cdl/net.cdl
--- /opt/ecos-repo/cvs/ecos/packages/net/common/current/cdl/net.cdl	2008-03-12 11:00:40.000000000 +0600
+++ ./net/common/current/cdl/net.cdl	2008-03-12 16:50:23.000000000 +0600
@@ -595,6 +595,25 @@
                 appropriate bootp record you have constructed yourself."
         }
 
+        cdl_component CYGHWR_NET_DRIVER_ETH0_REDBOOT {
+            display "Use RedBoot flash configuration to initialize 'eth0'?"
+            default_value 0
+            implements CYGHWR_NET_DRIVER_ETH0_SETUP
+            active_if CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
+            
+            description "
+                If this option is selected, init_all_network_interfaces()
+                will use RedBoot flash configuration to acquire initialization
+                data for this interface, and then set it up accordingly."
+
+            cdl_option CYGHWR_NET_DRIVER_ETH0_REDBOOT_DHCP {
+                display "Use DHCP rather than BOOTP for 'eth0'?"
+                flavor  bool
+                default_value 1
+                active_if CYGPKG_NET_DHCP
+            }
+        }
+
         cdl_component CYGHWR_NET_DRIVER_ETH0_BOOTP {
             display "Use BOOTP/DHCP to initialize 'eth0'?"
             default_value 1
diff -bur /opt/ecos-repo/cvs/ecos/packages/net/common/current/ChangeLog ./net/common/current/ChangeLog
--- /opt/ecos-repo/cvs/ecos/packages/net/common/current/ChangeLog	2008-03-12 11:00:40.000000000 +0600
+++ ./net/common/current/ChangeLog	2008-03-12 17:01:01.000000000 +0600
@@ -1,3 +1,10 @@
+2008-03-12  Alexey Shusharin <mrfinch@mail.ru>
+	
+	* cdl/net.cdl:
+	* src/network_support.c:
+	Add new initialization option for 'eth0': CYGHWR_NET_DRIVER_ETH0_REDBOOT.
+	This option allows to use RedBoot flash configuration to initialize 'eth0'
+	
 2007-12-21  Oyvind Harboe <oyvind.harboe@zylin.com>
 
 	* src/tftp_client.c, include/arpa/tftp.h, cdl/net.cdl: tftp
diff -bur /opt/ecos-repo/cvs/ecos/packages/net/common/current/src/network_support.c ./net/common/current/src/network_support.c
--- /opt/ecos-repo/cvs/ecos/packages/net/common/current/src/network_support.c	2004-04-13 21:36:27.000000000 +0700
+++ ./net/common/current/src/network_support.c	2008-03-12 17:28:13.000000000 +0600
@@ -89,6 +89,10 @@
 #include <pkgconf/ns_dns.h>
 #endif
 
+#ifdef CYGHWR_NET_DRIVER_ETH0_REDBOOT
+#include <cyg/hal/hal_if.h>
+#endif /*CYGHWR_NET_DRIVER_ETH0_REDBOOT*/
+
 #ifdef CYGHWR_NET_DRIVER_ETH0
 struct bootp eth0_bootp_data;
 cyg_bool_t   eth0_up = false;
@@ -290,6 +294,11 @@
 #ifdef CYGOPT_NET_IPV6_ROUTING_THREAD
     int rs_wait = 40;
 #endif
+#ifdef CYGHWR_NET_DRIVER_ETH0_REDBOOT
+    cyg_bool set_bootp;
+    struct in_addr ipaddr, ipmask;
+    char ipstr[5][sizeof("255.255.255.255")];
+#endif /*CYGHWR_NET_DRIVER_ETH0_REDBOOT*/
 
     cyg_scheduler_lock();
     while ( in_init_all_network_interfaces ) {
@@ -339,6 +348,71 @@
             diag_printf("BOOTP/DHCP failed on eth0\n");
             eth0_up = false;
         }
+#elif defined(CYGHWR_NET_DRIVER_ETH0_REDBOOT)
+        eth0_up = true;
+        
+        // Get bootp value from ROM-monitor
+        if(CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET, "bootp",
+                &set_bootp, CYGNUM_FLASH_CFG_TYPE_CONFIG_BOOL) && set_bootp)
+        {
+#ifdef CYGHWR_NET_DRIVER_ETH0_REDBOOT_DHCP
+            eth0_dhcpstate = 0; // Says that initialization is external to dhcp
+            if(do_dhcp(eth0_name, &eth0_bootp_data, &eth0_dhcpstate, &eth0_lease)) 
+#else
+#ifdef CYGPKG_NET_DHCP
+            eth0_dhcpstate = DHCPSTATE_BOOTP_FALLBACK;
+            // so the dhcp machine does no harm if called
+#endif
+            if(do_bootp(eth0_name, &eth0_bootp_data)) 
+#endif
+            {
+                show_bootp(eth0_name, &eth0_bootp_data);
+            }
+            else
+            {
+                diag_printf("BOOTP/DHCP failed on eth0\n");
+                eth0_up = false;
+            }
+        }
+        // Get bootp_my_ip value from ROM-monitor
+        else if(CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET,
+                "bootp_my_ip", &ipaddr, CYGNUM_FLASH_CFG_TYPE_CONFIG_IP))
+        {
+            inet_ntop(AF_INET, (void*) &ipaddr, ipstr[0], sizeof(ipstr[0]));
+            
+            // Get bootp_my_ip_mask parameter value from ROM-monitor
+            if(!CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET,
+                    "bootp_my_ip_mask", &ipmask, CYGNUM_FLASH_CFG_TYPE_CONFIG_IP))
+                ipmask.s_addr = INADDR_ANY;
+            inet_ntop(AF_INET, (void*) &ipmask, ipstr[1], sizeof(ipstr[1]));
+            
+            // Calc broadcast ip
+            ipaddr.s_addr = (ipaddr.s_addr & ipmask.s_addr) | (~ipmask.s_addr);
+            inet_ntop(AF_INET, (void*) &ipaddr, ipstr[2], sizeof(ipstr[2]));
+            
+            // Get bootp_my_gateway_ip parameter value from ROM-monitor
+            if(!CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET,
+                    "bootp_my_gateway_ip", &ipaddr, CYGNUM_FLASH_CFG_TYPE_CONFIG_IP))
+                ipaddr.s_addr = INADDR_ANY;
+            inet_ntop(AF_INET, (void*) &ipaddr, ipstr[3], sizeof(ipstr[3]));
+    
+            // Get bootp_server_ip parameter value from ROM-monitor
+            if(!CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET,
+                    "bootp_server_ip", &ipaddr, CYGNUM_FLASH_CFG_TYPE_CONFIG_IP))
+                ipaddr.s_addr = INADDR_ANY;
+            inet_ntop(AF_INET, (void*) &ipaddr, ipstr[4], sizeof(ipstr[4]));
+            
+            // Build bootp record
+            build_bootp_record(&eth0_bootp_data, eth0_name,
+                    ipstr[0], ipstr[1], ipstr[2], ipstr[3], ipstr[4]);
+            
+            show_bootp(eth0_name, &eth0_bootp_data);
+        }
+        else
+        {
+            diag_printf("RedBoot config read failed on eth0\n");
+            eth0_up = false;
+        }
 #elif defined(CYGHWR_NET_DRIVER_ETH0_ADDRS_IP)
         eth0_up = true;
         build_bootp_record(&eth0_bootp_data,

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