]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - net/tftp.c
Revert "net: nfs: Correct the reply data buffer size"
[people/ms/u-boot.git] / net / tftp.c
index 3e99e7309116c333576a366735214ccb66c6fdc3..ced45ec1f1f4aa836670115a8be30bf2e507b291 100644 (file)
@@ -8,9 +8,10 @@
 
 #include <common.h>
 #include <command.h>
+#include <efi_loader.h>
 #include <mapmem.h>
 #include <net.h>
-#include "tftp.h"
+#include <net/tftp.h>
 #include "bootp.h"
 #ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
 #include <flash.h>
@@ -249,6 +250,8 @@ static void show_block_marker(void)
        if (tftp_tsize) {
                ulong pos = tftp_cur_block * tftp_block_size +
                        tftp_block_wrap_offset;
+               if (pos > tftp_tsize)
+                       pos = tftp_tsize;
 
                while (tftp_tsize_num_hash < pos * 50 / tftp_tsize) {
                        putc('#');
@@ -600,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);
@@ -695,12 +698,14 @@ 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");
        if (ep != NULL)
                tftp_block_size_option = simple_strtol(ep, NULL, 10);
@@ -715,6 +720,17 @@ void tftp_start(enum proto_t protocol)
                timeout_ms = 1000;
        }
 
+       ep = getenv("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);
 
@@ -789,6 +805,7 @@ void tftp_start(enum proto_t protocol)
                printf("Load address: 0x%lx\n", load_addr);
                puts("Loading: *\b");
                tftp_state = STATE_SEND_RRQ;
+               efi_set_bootdev("Net", "", tftp_filename);
        }
 
        time_start = get_timer(0);
@@ -840,7 +857,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);