X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=net%2Ftftp.c;h=6671b1f7ca726acf44b6f18f41f9f017c10fd1ec;hb=cb7116afe8c526aa05543b36a4722ce06dfde8ab;hp=89be32a26bd8cfaca738bda523cc400830088fa4;hpb=7628afebe9685a333e0a42398ed8be749a1fef0d;p=u-boot diff --git a/net/tftp.c b/net/tftp.c index 89be32a26b..6671b1f7ca 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -8,9 +8,10 @@ #include #include +#include #include #include -#include "tftp.h" +#include #include "bootp.h" #ifdef CONFIG_SYS_DIRECT_FLASH_TFTP #include @@ -602,7 +603,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip, } tftp_prev_block = tftp_cur_block; - timeout_count_max = TIMEOUT_COUNT; + timeout_count_max = tftp_timeout_count_max; net_set_timeout_handler(timeout_ms, tftp_timeout_handler); store_block(tftp_cur_block - 1, pkt + 2, len); @@ -697,17 +698,19 @@ static void tftp_timeout_handler(void) void tftp_start(enum proto_t protocol) { +#if CONFIG_NET_TFTP_VARS char *ep; /* Environment pointer */ /* * Allow the user to choose TFTP blocksize and timeout. * TFTP protocol has a minimal timeout of 1 second. */ - ep = getenv("tftpblocksize"); + + ep = env_get("tftpblocksize"); if (ep != NULL) tftp_block_size_option = simple_strtol(ep, NULL, 10); - ep = getenv("tftptimeout"); + ep = env_get("tftptimeout"); if (ep != NULL) timeout_ms = simple_strtol(ep, NULL, 10); @@ -717,6 +720,17 @@ void tftp_start(enum proto_t protocol) timeout_ms = 1000; } + ep = env_get("tftptimeoutcountmax"); + if (ep != NULL) + tftp_timeout_count_max = simple_strtol(ep, NULL, 10); + + if (tftp_timeout_count_max < 0) { + printf("TFTP timeout count max (%d ms) negative, set to 0\n", + tftp_timeout_count_max); + tftp_timeout_count_max = 0; + } +#endif + debug("TFTP blocksize = %i, timeout = %ld ms\n", tftp_block_size_option, timeout_ms); @@ -728,8 +742,8 @@ void tftp_start(enum proto_t protocol) (net_ip.s_addr >> 16) & 0xFF, (net_ip.s_addr >> 24) & 0xFF); - strncpy(tftp_filename, default_filename, MAX_LEN); - tftp_filename[MAX_LEN - 1] = 0; + strncpy(tftp_filename, default_filename, DEFAULT_NAME_LEN); + tftp_filename[DEFAULT_NAME_LEN - 1] = 0; printf("*** Warning: no boot file name; using '%s'\n", tftp_filename); @@ -791,6 +805,9 @@ void tftp_start(enum proto_t protocol) printf("Load address: 0x%lx\n", load_addr); puts("Loading: *\b"); tftp_state = STATE_SEND_RRQ; +#ifdef CONFIG_CMD_BOOTEFI + efi_set_bootdev("Net", "", tftp_filename); +#endif } time_start = get_timer(0); @@ -807,10 +824,10 @@ void tftp_start(enum proto_t protocol) tftp_our_port = 1024 + (get_timer(0) % 3072); #ifdef CONFIG_TFTP_PORT - ep = getenv("tftpdstp"); + ep = env_get("tftpdstp"); if (ep != NULL) tftp_remote_port = simple_strtol(ep, NULL, 10); - ep = getenv("tftpsrcp"); + ep = env_get("tftpsrcp"); if (ep != NULL) tftp_our_port = simple_strtol(ep, NULL, 10); #endif @@ -842,7 +859,7 @@ void tftp_start_server(void) puts("Loading: *\b"); - timeout_count_max = TIMEOUT_COUNT; + timeout_count_max = tftp_timeout_count_max; timeout_count = 0; timeout_ms = TIMEOUT; net_set_timeout_handler(timeout_ms, tftp_timeout_handler);