diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/link_local.c | 2 | ||||
-rw-r--r-- | net/net.c | 49 | ||||
-rw-r--r-- | net/tftp.c | 8 |
3 files changed, 41 insertions, 18 deletions
diff --git a/net/link_local.c b/net/link_local.c index d52f13adb45..1ba796ebdf9 100644 --- a/net/link_local.c +++ b/net/link_local.c @@ -103,7 +103,7 @@ static void configure_wait(void) void link_local_start(void) { ip = getenv_IPaddr("llipaddr"); - if (ip != 0 && (ip & IN_CLASSB_NET) != LINKLOCAL_ADDR) { + if (ip != 0 && (ntohl(ip) & IN_CLASSB_NET) != LINKLOCAL_ADDR) { puts("invalid link address"); net_set_state(NETLOOP_FAIL); return; diff --git a/net/net.c b/net/net.c index 82c4cc91179..a40cde1e94e 100644 --- a/net/net.c +++ b/net/net.c @@ -82,6 +82,7 @@ #include <common.h> #include <command.h> +#include <environment.h> #include <net.h> #if defined(CONFIG_STATUS_LED) #include <miiphy.h> @@ -208,32 +209,46 @@ static int NetTryCount; /**********************************************************************/ +static int on_bootfile(const char *name, const char *value, enum env_op op, + int flags) +{ + switch (op) { + case env_op_create: + case env_op_overwrite: + copy_filename(BootFile, value, sizeof(BootFile)); + break; + default: + break; + } + + return 0; +} +U_BOOT_ENV_CALLBACK(bootfile, on_bootfile); + /* * Check if autoload is enabled. If so, use either NFS or TFTP to download * the boot file. */ void net_auto_load(void) { +#if defined(CONFIG_CMD_NFS) const char *s = getenv("autoload"); - if (s != NULL) { - if (*s == 'n') { - /* - * Just use BOOTP/RARP to configure system; - * Do not use TFTP to load the bootfile. - */ - net_set_state(NETLOOP_SUCCESS); - return; - } -#if defined(CONFIG_CMD_NFS) - if (strcmp(s, "NFS") == 0) { - /* - * Use NFS to load the bootfile. - */ - NfsStart(); - return; - } + if (s != NULL && strcmp(s, "NFS") == 0) { + /* + * Use NFS to load the bootfile. + */ + NfsStart(); + return; + } #endif + if (getenv_yesno("autoload") == 0) { + /* + * Just use BOOTP/RARP to configure system; + * Do not use TFTP to load the bootfile. + */ + net_set_state(NETLOOP_SUCCESS); + return; } TftpStart(TFTPGET); } diff --git a/net/tftp.c b/net/tftp.c index 59a8ebb3cf3..09790eb7cf8 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -40,6 +40,7 @@ static ulong TftpTimeoutMSecs = TIMEOUT; static int TftpTimeoutCountMax = TIMEOUT_COUNT; +static ulong time_start; /* Record time we started tftp */ /* * These globals govern the timeout behavior when attempting a connection to a @@ -299,6 +300,12 @@ static void tftp_complete(void) TftpNumchars++; } #endif + time_start = get_timer(time_start); + if (time_start > 0) { + puts("\n\t "); /* Line up with "Loading: " */ + print_size(NetBootFileXferSize / + time_start * 1000, "/s"); + } puts("\ndone\n"); net_set_state(NETLOOP_SUCCESS); } @@ -775,6 +782,7 @@ void TftpStart(enum proto_t protocol) TftpState = STATE_SEND_RRQ; } + time_start = get_timer(0); TftpTimeoutCountMax = TftpRRQTimeoutCountMax; NetSetTimeout(TftpTimeoutMSecs, TftpTimeout); |