]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - net/rarp.c
TI DaVinci DM646x: Adding initial support for DM6467 EVM
[karo-tx-uboot.git] / net / rarp.c
index 1c8aff063352f863035e11d284642d09457687eb..d37981bfc809dc01829379ee6e5bab10cd648aa5 100644 (file)
 #include <common.h>
 #include <command.h>
 #include <net.h>
+#include "nfs.h"
 #include "bootp.h"
 #include "rarp.h"
 #include "tftp.h"
 
-#if (CONFIG_COMMANDS & CFG_CMD_NET)
+#if defined(CONFIG_CMD_NET)
 
-#define TIMEOUT                5               /* Seconds before trying BOOTP again */
+#define TIMEOUT                5000UL  /* Milliseconds before trying BOOTP again */
 #ifndef        CONFIG_NET_RETRY_COUNT
 # define TIMEOUT_COUNT 5               /* # of timeouts before giving up  */
 #else
@@ -46,9 +47,23 @@ int          RarpTry;
 static void
 RarpHandler(uchar * dummi0, unsigned dummi1, unsigned dummi2, unsigned dummi3)
 {
-#ifdef DEBUG
-       printf("Got good RARP\n");
+       char *s;
+       debug("Got good RARP\n");
+       if ((s = getenv("autoload")) != NULL) {
+               if (*s == 'n') {
+                       /*
+                        * Just use RARP to configure system;
+                        * Do not use TFTP/NFS to to load the bootfile.
+                        */
+                       NetState = NETLOOP_SUCCESS;
+                       return;
+#if defined(CONFIG_CMD_NFS)
+               } else if ((s != NULL) && !strcmp(s, "NFS")) {
+                       NfsStart();
+                       return;
 #endif
+               }
+       }
        TftpStart ();
 }
 
@@ -63,7 +78,7 @@ RarpTimeout(void)
                puts ("\nRetry count exceeded; starting again\n");
                NetStartAgain ();
        } else {
-               NetSetTimeout (TIMEOUT * CFG_HZ, RarpTimeout);
+               NetSetTimeout (TIMEOUT, RarpTimeout);
                RarpRequest ();
        }
 }
@@ -79,8 +94,7 @@ RarpRequest (void)
        printf("RARP broadcast %d\n", ++RarpTry);
        pkt = NetTxPacket;
 
-       NetSetEther(pkt, NetBcastAddr, PROT_RARP);
-       pkt += ETHER_HDR_SIZE;
+       pkt += NetSetEther(pkt, NetBcastAddr, PROT_RARP);
 
        rarp = (ARP_t *)pkt;
 
@@ -97,10 +111,10 @@ RarpRequest (void)
                rarp->ar_data[16 + i] = 0xff;
        }
 
-       NetSendPacket(NetTxPacket, ETHER_HDR_SIZE + ARP_HDR_SIZE);
+       NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
 
-       NetSetTimeout(TIMEOUT * CFG_HZ, RarpTimeout);
+       NetSetTimeout(TIMEOUT, RarpTimeout);
        NetSetHandler(RarpHandler);
 }
 
-#endif /* CFG_CMD_NET */
+#endif