#include <asm/global_data.h>
#include <net/tftp.h>
#include "bootp.h"
-#ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
-#include <flash.h>
-#endif
DECLARE_GLOBAL_DATA_PTR;
#define WELL_KNOWN_PORT 69
/* Millisecs to timeout for lost pkt */
#define TIMEOUT 5000UL
-#ifndef CONFIG_NET_RETRY_COUNT
-/* # of timeouts before giving up */
-# define TIMEOUT_COUNT 10
-#else
-# define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT * 2)
-#endif
/* Number of "loading" hashes per line (for checking the image size) */
#define HASHES_PER_LINE 65
#define TFTP_OACK 6
static ulong timeout_ms = TIMEOUT;
-static int timeout_count_max = TIMEOUT_COUNT;
+static int timeout_count_max = (CONFIG_NET_RETRY_COUNT * 2);
static ulong time_start; /* Record time we started tftp */
/*
* non-standard timeout behavior when initiating a TFTP transfer.
*/
ulong tftp_timeout_ms = TIMEOUT;
-int tftp_timeout_count_max = TIMEOUT_COUNT;
+int tftp_timeout_count_max = (CONFIG_NET_RETRY_COUNT * 2);
enum {
TFTP_ERR_UNDEFINED = 0,
tftp_block_size;
ulong newsize = offset + len;
ulong store_addr = tftp_load_addr + offset;
-#ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
- int i, rc = 0;
-
- for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
- /* start address in flash? */
- if (flash_info[i].flash_id == FLASH_UNKNOWN)
- continue;
- if (store_addr >= flash_info[i].start[0]) {
- rc = 1;
- break;
- }
- }
-
- if (rc) { /* Flash is destination for this packet */
- rc = flash_write((char *)src, store_addr, len);
- if (rc) {
- flash_perror(rc);
- return rc;
- }
- } else
-#endif /* CONFIG_SYS_DIRECT_FLASH_TFTP */
- {
- void *ptr;
+ void *ptr;
#ifdef CONFIG_LMB
- ulong end_addr = tftp_load_addr + tftp_load_size;
+ ulong end_addr = tftp_load_addr + tftp_load_size;
- if (!end_addr)
- end_addr = ULONG_MAX;
+ if (!end_addr)
+ end_addr = ULONG_MAX;
- if (store_addr < tftp_load_addr ||
- store_addr + len > end_addr) {
- puts("\nTFTP error: ");
- puts("trying to overwrite reserved memory...\n");
- return -1;
- }
-#endif
- ptr = map_sysmem(store_addr, len);
- memcpy(ptr, src, len);
- unmap_sysmem(ptr);
+ if (store_addr < tftp_load_addr ||
+ store_addr + len > end_addr) {
+ puts("\nTFTP error: ");
+ puts("trying to overwrite reserved memory...\n");
+ return -1;
}
+#endif
+ ptr = map_sysmem(store_addr, len);
+ memcpy(ptr, src, len);
+ unmap_sysmem(ptr);
if (net_boot_file_size < newsize)
net_boot_file_size = newsize;
* @param block Block number to send
* @param dst Destination buffer for data
* @param len Number of bytes in block (this one and every other)
- * @return number of bytes loaded
+ * Return: number of bytes loaded
*/
static int load_block(unsigned block, uchar *dst, unsigned len)
{
for (i = 0; i+8 < len; i++) {
if (strcasecmp((char *)pkt + i, "blksize") == 0) {
tftp_block_size = (unsigned short)
- simple_strtoul((char *)pkt + i + 8,
- NULL, 10);
+ dectoul((char *)pkt + i + 8, NULL);
debug("Blocksize oack: %s, %d\n",
(char *)pkt + i + 8, tftp_block_size);
if (tftp_block_size > tftp_block_size_option) {
}
if (strcasecmp((char *)pkt + i, "timeout") == 0) {
timeout_val_rcvd = (unsigned short)
- simple_strtoul((char *)pkt + i + 8,
- NULL, 10);
+ dectoul((char *)pkt + i + 8, NULL);
debug("Timeout oack: %s, %d\n",
(char *)pkt + i + 8, timeout_val_rcvd);
if (timeout_val_rcvd != (timeout_ms / 1000)) {
}
#ifdef CONFIG_TFTP_TSIZE
if (strcasecmp((char *)pkt + i, "tsize") == 0) {
- tftp_tsize = simple_strtoul((char *)pkt + i + 6,
- NULL, 10);
+ tftp_tsize = dectoul((char *)pkt + i + 6,
+ NULL);
debug("size = %s, %d\n",
(char *)pkt + i + 6, tftp_tsize);
}
#endif
if (strcasecmp((char *)pkt + i, "windowsize") == 0) {
tftp_windowsize =
- simple_strtoul((char *)pkt + i + 11,
- NULL, 10);
+ dectoul((char *)pkt + i + 11, NULL);
debug("windowsize = %s, %d\n",
(char *)pkt + i + 11, tftp_windowsize);
}
tftp_block_size = TFTP_BLOCK_SIZE;
tftp_cur_block = 0;
tftp_our_port = WELL_KNOWN_PORT;
+ tftp_windowsize = 1;
+ tftp_next_ack = tftp_windowsize;
#ifdef CONFIG_TFTP_TSIZE
tftp_tsize = 0;
memset(net_server_ethaddr, 0, 6);
}
#endif /* CONFIG_CMD_TFTPSRV */
-