diff options
author | Haavard Skinnemoen <haavard.skinnemoen@atmel.com> | 2008-12-17 16:53:07 +0100 |
---|---|---|
committer | Haavard Skinnemoen <haavard.skinnemoen@atmel.com> | 2008-12-17 16:53:07 +0100 |
commit | cb5473205206c7f14cbb1e747f28ec75b48826e2 (patch) | |
tree | 8f4808d60917100b18a10b05230f7638a0a9bbcc /net | |
parent | baf449fc5ff96f071bb0e3789fd3265f6d4fd9a0 (diff) | |
parent | 92c78a3bbcb2ce508b4bf1c4a1e0940406a024bb (diff) | |
download | u-boot-imx-cb5473205206c7f14cbb1e747f28ec75b48826e2.zip u-boot-imx-cb5473205206c7f14cbb1e747f28ec75b48826e2.tar.gz u-boot-imx-cb5473205206c7f14cbb1e747f28ec75b48826e2.tar.bz2 |
Merge branch 'fixes' into cleanups
Conflicts:
board/atmel/atngw100/atngw100.c
board/atmel/atstk1000/atstk1000.c
cpu/at32ap/at32ap700x/gpio.c
include/asm-avr32/arch-at32ap700x/clk.h
include/configs/atngw100.h
include/configs/atstk1002.h
include/configs/atstk1003.h
include/configs/atstk1004.h
include/configs/atstk1006.h
include/configs/favr-32-ezkit.h
include/configs/hammerhead.h
include/configs/mimc200.h
Diffstat (limited to 'net')
-rw-r--r-- | net/bootp.c | 26 | ||||
-rw-r--r-- | net/bootp.h | 2 | ||||
-rw-r--r-- | net/eth.c | 110 | ||||
-rw-r--r-- | net/net.c | 41 | ||||
-rw-r--r-- | net/nfs.c | 12 | ||||
-rw-r--r-- | net/rarp.c | 6 | ||||
-rw-r--r-- | net/sntp.c | 4 | ||||
-rw-r--r-- | net/tftp.c | 45 |
8 files changed, 79 insertions, 167 deletions
diff --git a/net/bootp.c b/net/bootp.c index 64552ac..83465e4 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -33,7 +33,7 @@ #if defined(CONFIG_CMD_NET) -#define TIMEOUT 5UL /* 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 @@ -371,7 +371,7 @@ BootpTimeout(void) puts ("\nRetry count exceeded; starting again\n"); NetStartAgain (); } else { - NetSetTimeout (TIMEOUT * CFG_HZ, BootpTimeout); + NetSetTimeout (TIMEOUT, BootpTimeout); BootpRequest (); } } @@ -671,7 +671,7 @@ BootpRequest (void) bp->bp_htype = HWT_ETHER; bp->bp_hlen = HWL_ETHER; bp->bp_hops = 0; - bp->bp_secs = htons(get_timer(0) / CFG_HZ); + bp->bp_secs = htons(get_timer(0) / 1000); NetWriteIP(&bp->bp_ciaddr, 0); NetWriteIP(&bp->bp_yiaddr, 0); NetWriteIP(&bp->bp_siaddr, 0); @@ -688,7 +688,7 @@ BootpRequest (void) /* * Bootp ID is the lower 4 bytes of our ethernet address - * plus the current time in HZ. + * plus the current time in ms. */ BootpID = ((ulong)NetOurEther[2] << 24) | ((ulong)NetOurEther[3] << 16) @@ -705,7 +705,7 @@ BootpRequest (void) pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + ext_len; iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len; NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen); - NetSetTimeout(SELECT_TIMEOUT * CFG_HZ, BootpTimeout); + NetSetTimeout(SELECT_TIMEOUT, BootpTimeout); #if defined(CONFIG_CMD_DHCP) dhcp_state = SELECTING; @@ -849,7 +849,7 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer) bp->bp_htype = HWT_ETHER; bp->bp_hlen = HWL_ETHER; bp->bp_hops = 0; - bp->bp_secs = htons(get_timer(0) / CFG_HZ); + bp->bp_secs = htons(get_timer(0) / 1000); /* Do not set the client IP, your IP, or server IP yet, since it hasn't been ACK'ed by * the server yet */ @@ -912,11 +912,11 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len) * OFFER from a server we want. */ debug ("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file); -#ifdef CFG_BOOTFILE_PREFIX +#ifdef CONFIG_SYS_BOOTFILE_PREFIX if (strncmp(bp->bp_file, - CFG_BOOTFILE_PREFIX, - strlen(CFG_BOOTFILE_PREFIX)) == 0 ) { -#endif /* CFG_BOOTFILE_PREFIX */ + CONFIG_SYS_BOOTFILE_PREFIX, + strlen(CONFIG_SYS_BOOTFILE_PREFIX)) == 0 ) { +#endif /* CONFIG_SYS_BOOTFILE_PREFIX */ debug ("TRANSITIONING TO REQUESTING STATE\n"); dhcp_state = REQUESTING; @@ -924,11 +924,11 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len) if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC)) DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp); - NetSetTimeout(TIMEOUT * CFG_HZ, BootpTimeout); + NetSetTimeout(TIMEOUT, BootpTimeout); DhcpSendRequestPkt(bp); -#ifdef CFG_BOOTFILE_PREFIX +#ifdef CONFIG_SYS_BOOTFILE_PREFIX } -#endif /* CFG_BOOTFILE_PREFIX */ +#endif /* CONFIG_SYS_BOOTFILE_PREFIX */ return; break; diff --git a/net/bootp.h b/net/bootp.h index c2f011c..50625ab 100644 --- a/net/bootp.h +++ b/net/bootp.h @@ -88,7 +88,7 @@ typedef enum { INIT, #define DHCP_NAK 6 #define DHCP_RELEASE 7 -#define SELECT_TIMEOUT 3UL /* Seconds to wait for offers */ +#define SELECT_TIMEOUT 3000UL /* Milliseconds to wait for offers */ /**********************************************************************/ @@ -39,34 +39,8 @@ static int __def_eth_init(bd_t *bis) int cpu_eth_init(bd_t *bis) __attribute((weak, alias("__def_eth_init"))); int board_eth_init(bd_t *bis) __attribute((weak, alias("__def_eth_init"))); -#ifdef CFG_GT_6426x -extern int gt6426x_eth_initialize(bd_t *bis); -#endif - -extern int au1x00_enet_initialize(bd_t*); -extern int dc21x4x_initialize(bd_t*); -extern int e1000_initialize(bd_t*); -extern int eepro100_initialize(bd_t*); -extern int eth_3com_initialize(bd_t*); -extern int fec_initialize(bd_t*); -extern int inca_switch_initialize(bd_t*); -extern int mpc5xxx_fec_initialize(bd_t*); -extern int mpc512x_fec_initialize(bd_t*); -extern int mpc8220_fec_initialize(bd_t*); extern int mv6436x_eth_initialize(bd_t *); extern int mv6446x_eth_initialize(bd_t *); -extern int natsemi_initialize(bd_t*); -extern int ns8382x_initialize(bd_t*); -extern int pcnet_initialize(bd_t*); -extern int plb2800_eth_initialize(bd_t*); -extern int ppc_4xx_eth_initialize(bd_t *); -extern int rtl8139_initialize(bd_t*); -extern int rtl8169_initialize(bd_t*); -extern int scc_initialize(bd_t*); -extern int tsi108_eth_initialize(bd_t*); -extern int npe_initialize(bd_t *); -extern int uec_initialize(int); -extern int at91sam9_eth_initialize(bd_t *); #ifdef CONFIG_API extern void (*push_packet)(volatile void *, int); @@ -178,87 +152,6 @@ int eth_initialize(bd_t *bis) #if defined(CONFIG_DB64460) || defined(CONFIG_P3Mx) mv6446x_eth_initialize(bis); #endif -#if defined(CONFIG_4xx) && !defined(CONFIG_IOP480) && !defined(CONFIG_AP1000) - ppc_4xx_eth_initialize(bis); -#endif -#ifdef CONFIG_INCA_IP_SWITCH - inca_switch_initialize(bis); -#endif -#ifdef CONFIG_PLB2800_ETHER - plb2800_eth_initialize(bis); -#endif -#ifdef SCC_ENET - scc_initialize(bis); -#endif -#if defined(CONFIG_MPC5xxx_FEC) - mpc5xxx_fec_initialize(bis); -#endif -#if defined(CONFIG_MPC512x_FEC) - mpc512x_fec_initialize (bis); -#endif -#if defined(CONFIG_MPC8220_FEC) - mpc8220_fec_initialize(bis); -#endif -#if defined(CONFIG_UEC_ETH1) - uec_initialize(0); -#endif -#if defined(CONFIG_UEC_ETH2) - uec_initialize(1); -#endif -#if defined(CONFIG_UEC_ETH3) - uec_initialize(2); -#endif -#if defined(CONFIG_UEC_ETH4) - uec_initialize(3); -#endif - -#if defined(FEC_ENET) || defined(CONFIG_ETHER_ON_FCC) - fec_initialize(bis); -#endif -#if defined(CONFIG_AU1X00) - au1x00_enet_initialize(bis); -#endif -#if defined(CONFIG_IXP4XX_NPE) - npe_initialize(bis); -#endif -#ifdef CONFIG_E1000 - e1000_initialize(bis); -#endif -#ifdef CONFIG_EEPRO100 - eepro100_initialize(bis); -#endif -#ifdef CONFIG_TULIP - dc21x4x_initialize(bis); -#endif -#ifdef CONFIG_3COM - eth_3com_initialize(bis); -#endif -#ifdef CONFIG_PCNET - pcnet_initialize(bis); -#endif -#ifdef CFG_GT_6426x - gt6426x_eth_initialize(bis); -#endif -#ifdef CONFIG_NATSEMI - natsemi_initialize(bis); -#endif -#ifdef CONFIG_NS8382X - ns8382x_initialize(bis); -#endif -#if defined(CONFIG_TSI108_ETH) - tsi108_eth_initialize(bis); -#endif -#if defined(CONFIG_RTL8139) - rtl8139_initialize(bis); -#endif -#if defined(CONFIG_RTL8169) - rtl8169_initialize(bis); -#endif -#if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \ - defined(CONFIG_AT91SAM9263) - at91sam9_eth_initialize(bis); -#endif - if (!eth_devices) { puts ("No ethernet found.\n"); show_boot_progress (-64); @@ -588,8 +481,7 @@ int eth_initialize(bd_t *bis) #if defined(CONFIG_AT91RM9200) at91rm9200_miiphy_initialize(bis); #endif -#if defined(CONFIG_4xx) && !defined(CONFIG_IOP480) \ - && !defined(CONFIG_AP1000) && !defined(CONFIG_405) +#if defined(CONFIG_PPC4xx_EMAC) emac4xx_miiphy_initialize(bis); #endif #if defined(CONFIG_MCF52x2) @@ -89,20 +89,18 @@ #if defined(CONFIG_CMD_SNTP) #include "sntp.h" #endif +#if defined(CONFIG_CDP_VERSION) +#include <timestamp.h> +#endif #if defined(CONFIG_CMD_NET) DECLARE_GLOBAL_DATA_PTR; #ifndef CONFIG_ARP_TIMEOUT -# define ARP_TIMEOUT 50UL /* Deciseconds before trying ARP again */ -#elif (CONFIG_ARP_TIMEOUT < 100) -# error "Due to possible overflow CONFIG_ARP_TIMEOUT must be greater than 100ms" +# define ARP_TIMEOUT 5000UL /* Milliseconds before trying ARP again */ #else -# if (CONFIG_ARP_TIMEOUT % 100) -# warning "Supported ARP_TIMEOUT precision is 100ms" -# endif -# define ARP_TIMEOUT (CONFIG_ARP_TIMEOUT / 100) +# define ARP_TIMEOUT CONFIG_ARP_TIMEOUT #endif @@ -264,7 +262,7 @@ void ArpTimeoutCheck(void) t = get_timer(0); /* check for arp timeout */ - if ((t - NetArpWaitTimerStart) > ARP_TIMEOUT * CFG_HZ / 10) { + if ((t - NetArpWaitTimerStart) > ARP_TIMEOUT) { NetArpWaitTry++; if (NetArpWaitTry >= ARP_TIMEOUT_COUNT) { @@ -477,16 +475,16 @@ restart: } #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) -#if defined(CFG_FAULT_ECHO_LINK_DOWN) && defined(CONFIG_STATUS_LED) && defined(STATUS_LED_RED) +#if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && defined(CONFIG_STATUS_LED) && defined(STATUS_LED_RED) /* * Echo the inverted link state to the fault LED. */ - if(miiphy_link(eth_get_dev()->name, CFG_FAULT_MII_ADDR)) { + if(miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) { status_led_set (STATUS_LED_RED, STATUS_LED_OFF); } else { status_led_set (STATUS_LED_RED, STATUS_LED_ON); } -#endif /* CFG_FAULT_ECHO_LINK_DOWN, ... */ +#endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */ #endif /* CONFIG_MII, ... */ /* @@ -526,18 +524,18 @@ restart: thand_f *x; #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) -# if defined(CFG_FAULT_ECHO_LINK_DOWN) && \ +# if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && \ defined(CONFIG_STATUS_LED) && \ defined(STATUS_LED_RED) /* * Echo the inverted link state to the fault LED. */ - if(miiphy_link(eth_get_dev()->name, CFG_FAULT_MII_ADDR)) { + if(miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) { status_led_set (STATUS_LED_RED, STATUS_LED_OFF); } else { status_led_set (STATUS_LED_RED, STATUS_LED_ON); } -# endif /* CFG_FAULT_ECHO_LINK_DOWN, ... */ +# endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */ #endif /* CONFIG_MII, ... */ x = timeHandler; timeHandler = (thand_f *)0; @@ -603,7 +601,7 @@ void NetStartAgain (void) return; } #ifndef CONFIG_NET_MULTI - NetSetTimeout (10UL * CFG_HZ, startAgainTimeout); + NetSetTimeout (10000UL, startAgainTimeout); NetSetHandler (startAgainHandler); #else /* !CONFIG_NET_MULTI*/ eth_halt (); @@ -614,7 +612,7 @@ void NetStartAgain (void) if (NetRestartWrap) { NetRestartWrap = 0; if (NetDevExists && !once) { - NetSetTimeout (10UL * CFG_HZ, startAgainTimeout); + NetSetTimeout (10000UL, startAgainTimeout); NetSetHandler (startAgainHandler); } else { NetState = NETLOOP_FAIL; @@ -740,7 +738,7 @@ int PingSend(void) ip->ip_tos = 0; ip->ip_len = htons(IP_HDR_SIZE_NO_UDP + 8); ip->ip_id = htons(NetIPID++); - ip->ip_off = htons(0x4000); /* No fragmentation */ + ip->ip_off = htons(IP_FLAGS_DFRAG); /* Don't fragment */ ip->ip_ttl = 255; ip->ip_p = 0x01; /* ICMP */ ip->ip_sum = 0; @@ -790,7 +788,7 @@ static void PingStart(void) #if defined(CONFIG_NET_MULTI) printf ("Using %s device\n", eth_get_name()); #endif /* CONFIG_NET_MULTI */ - NetSetTimeout (10UL * CFG_HZ, PingTimeout); + NetSetTimeout (10000UL, PingTimeout); NetSetHandler (PingHandler); PingSend(); @@ -813,7 +811,7 @@ static void PingStart(void) #define CDP_SYSOBJECT_TLV 0x0015 #define CDP_MANAGEMENT_ADDRESS_TLV 0x0016 -#define CDP_TIMEOUT (CFG_HZ/4) /* one packet every 250ms */ +#define CDP_TIMEOUT 250UL /* one packet every 250ms */ static int CDPSeq; static int CDPOK; @@ -1404,7 +1402,8 @@ NetReceive(volatile uchar * inpkt, int len) if ((ip->ip_hl_v & 0xf0) != 0x40) { return; } - if (ip->ip_off & htons(0x1fff)) { /* Can't deal w/ fragments */ + /* Can't deal with fragments */ + if (ip->ip_off & htons(IP_OFFS | IP_FLAGS_MFRAG)) { return; } /* can't deal with headers > 20 bytes */ @@ -1703,7 +1702,7 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len) ip->ip_tos = 0; ip->ip_len = htons(IP_HDR_SIZE + len); ip->ip_id = htons(NetIPID++); - ip->ip_off = htons(0x4000); /* No fragmentation */ + ip->ip_off = htons(IP_FLAGS_DFRAG); /* Don't fragment */ ip->ip_ttl = 255; ip->ip_p = 17; /* UDP */ ip->ip_sum = 0; @@ -35,7 +35,7 @@ #define HASHES_PER_LINE 65 /* Number of "loading" hashes per line */ #define NFS_RETRY_COUNT 30 -#define NFS_TIMEOUT 2UL +#define NFS_TIMEOUT 2000UL static int fs_mounted = 0; static unsigned long rpc_id = 0; @@ -69,10 +69,10 @@ static __inline__ int store_block (uchar * src, unsigned offset, unsigned len) { ulong newsize = offset + len; -#ifdef CFG_DIRECT_FLASH_NFS +#ifdef CONFIG_SYS_DIRECT_FLASH_NFS int i, rc = 0; - for (i=0; i<CFG_MAX_FLASH_BANKS; i++) { + for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; i++) { /* start address in flash? */ if (load_addr + offset >= flash_info[i].start[0]) { rc = 1; @@ -87,7 +87,7 @@ store_block (uchar * src, unsigned offset, unsigned len) return -1; } } else -#endif /* CFG_DIRECT_FLASH_NFS */ +#endif /* CONFIG_SYS_DIRECT_FLASH_NFS */ { (void)memcpy ((void *)(load_addr + offset), src, len); } @@ -674,7 +674,7 @@ NfsHandler (uchar *pkt, unsigned dest, unsigned src, unsigned len) case STATE_READ_REQ: rlen = nfs_read_reply (pkt, len); - NetSetTimeout (NFS_TIMEOUT * CFG_HZ, NfsTimeout); + NetSetTimeout (NFS_TIMEOUT, NfsTimeout); if (rlen > 0) { nfs_offset += rlen; NfsSend (); @@ -763,7 +763,7 @@ NfsStart (void) printf ("\nLoad address: 0x%lx\n" "Loading: *\b", load_addr); - NetSetTimeout (NFS_TIMEOUT * CFG_HZ, NfsTimeout); + NetSetTimeout (NFS_TIMEOUT, NfsTimeout); NetSetHandler (NfsHandler); NfsTimeoutCount = 0; @@ -31,7 +31,7 @@ #if defined(CONFIG_CMD_NET) -#define TIMEOUT 5UL /* 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 @@ -80,7 +80,7 @@ RarpTimeout(void) puts ("\nRetry count exceeded; starting again\n"); NetStartAgain (); } else { - NetSetTimeout (TIMEOUT * CFG_HZ, RarpTimeout); + NetSetTimeout (TIMEOUT, RarpTimeout); RarpRequest (); } } @@ -115,7 +115,7 @@ RarpRequest (void) NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); - NetSetTimeout(TIMEOUT * CFG_HZ, RarpTimeout); + NetSetTimeout(TIMEOUT, RarpTimeout); NetSetHandler(RarpHandler); } @@ -14,7 +14,7 @@ #if defined(CONFIG_CMD_NET) && defined(CONFIG_CMD_SNTP) -#define SNTP_TIMEOUT 10 +#define SNTP_TIMEOUT 10000UL static int SntpOurPort; @@ -82,7 +82,7 @@ SntpStart (void) { debug ("%s\n", __FUNCTION__); - NetSetTimeout (SNTP_TIMEOUT * CFG_HZ, SntpTimeout); + NetSetTimeout (SNTP_TIMEOUT, SntpTimeout); NetSetHandler(SntpHandler); memset (NetServerEther, 0, 6); @@ -15,7 +15,7 @@ #if defined(CONFIG_CMD_NET) #define WELL_KNOWN_PORT 69 /* Well known TFTP port # */ -#define TIMEOUT 5UL /* Seconds to timeout for a lost pkt */ +#define TIMEOUT 5000UL /* Millisecs to timeout for lost pkt */ #ifndef CONFIG_NET_RETRY_COUNT # define TIMEOUT_COUNT 10 /* # of timeouts before giving up */ #else @@ -34,6 +34,21 @@ #define TFTP_ERROR 5 #define TFTP_OACK 6 +static ulong TftpTimeoutMSecs = TIMEOUT; +static int TftpTimeoutCountMax = TIMEOUT_COUNT; + +/* + * These globals govern the timeout behavior when attempting a connection to a + * TFTP server. TftpRRQTimeoutMSecs specifies the number of milliseconds to + * wait for the server to respond to initial connection. Second global, + * TftpRRQTimeoutCountMax, gives the number of such connection retries. + * TftpRRQTimeoutCountMax must be non-negative and TftpRRQTimeoutMSecs must be + * positive. The globals are meant to be set (and restored) by code needing + * non-standard timeout behavior when initiating a TFTP transfer. + */ +ulong TftpRRQTimeoutMSecs = TIMEOUT; +int TftpRRQTimeoutCountMax = TIMEOUT_COUNT; + static IPaddr_t TftpServerIP; static int TftpServerPort; /* The UDP port at their end */ static int TftpOurPort; /* The UDP port at our end */ @@ -64,7 +79,7 @@ static char default_filename[DEFAULT_NAME_LEN]; static char tftp_filename[MAX_LEN]; -#ifdef CFG_DIRECT_FLASH_TFTP +#ifdef CONFIG_SYS_DIRECT_FLASH_TFTP extern flash_info_t flash_info[]; #endif @@ -106,11 +121,13 @@ store_block (unsigned block, uchar * src, unsigned len) { ulong offset = block * TftpBlkSize + TftpBlockWrapOffset; ulong newsize = offset + len; -#ifdef CFG_DIRECT_FLASH_TFTP +#ifdef CONFIG_SYS_DIRECT_FLASH_TFTP int i, rc = 0; - for (i=0; i<CFG_MAX_FLASH_BANKS; i++) { + for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; i++) { /* start address in flash? */ + if (flash_info[i].flash_id == FLASH_UNKNOWN) + continue; if (load_addr + offset >= flash_info[i].start[0]) { rc = 1; break; @@ -126,7 +143,7 @@ store_block (unsigned block, uchar * src, unsigned len) } } else -#endif /* CFG_DIRECT_FLASH_TFTP */ +#endif /* CONFIG_SYS_DIRECT_FLASH_TFTP */ { (void)memcpy((void *)(load_addr + offset), src, len); } @@ -178,7 +195,7 @@ TftpSend (void) pkt += 5 /*strlen("octet")*/ + 1; strcpy ((char *)pkt, "timeout"); pkt += 7 /*strlen("timeout")*/ + 1; - sprintf((char *)pkt, "%lu", TIMEOUT); + sprintf((char *)pkt, "%lu", TIMEOUT / 1000); #ifdef ET_DEBUG printf("send option \"timeout %s\"\n", (char *)pkt); #endif @@ -368,7 +385,9 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) } TftpLastBlock = TftpBlock; - NetSetTimeout (TIMEOUT * CFG_HZ, TftpTimeout); + TftpTimeoutMSecs = TIMEOUT; + TftpTimeoutCountMax = TIMEOUT_COUNT; + NetSetTimeout (TftpTimeoutMSecs, TftpTimeout); store_block (TftpBlock - 1, pkt + 2, len); @@ -439,7 +458,7 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) static void TftpTimeout (void) { - if (++TftpTimeoutCount > TIMEOUT_COUNT) { + if (++TftpTimeoutCount > TftpTimeoutCountMax) { puts ("\nRetry count exceeded; starting again\n"); #ifdef CONFIG_MCAST_TFTP mcast_cleanup(); @@ -447,7 +466,7 @@ TftpTimeout (void) NetStartAgain (); } else { puts ("T "); - NetSetTimeout (TIMEOUT * CFG_HZ, TftpTimeout); + NetSetTimeout (TftpTimeoutMSecs, TftpTimeout); TftpSend (); } } @@ -480,9 +499,8 @@ TftpStart (void) strncpy(tftp_filename, BootFile, MAX_LEN); tftp_filename[MAX_LEN-1] = 0; } else { - *p++ = '\0'; TftpServerIP = string_to_ip (BootFile); - strncpy(tftp_filename, p, MAX_LEN); + strncpy(tftp_filename, p + 1, MAX_LEN); tftp_filename[MAX_LEN-1] = 0; } } @@ -518,7 +536,10 @@ TftpStart (void) puts ("Loading: *\b"); - NetSetTimeout (TIMEOUT * CFG_HZ, TftpTimeout); + TftpTimeoutMSecs = TftpRRQTimeoutMSecs; + TftpTimeoutCountMax = TftpRRQTimeoutCountMax; + + NetSetTimeout (TftpTimeoutMSecs, TftpTimeout); NetSetHandler (TftpHandler); TftpServerPort = WELL_KNOWN_PORT; |