+/* Clear our state ready for a new transfer */
+static void new_transfer(void)
+{
+ tftp_prev_block = 0;
+ tftp_block_wrap = 0;
+ tftp_block_wrap_offset = 0;
+#ifdef CONFIG_CMD_TFTPPUT
+ tftp_put_final_block_sent = 0;
+#endif
+}
+
+#ifdef CONFIG_CMD_TFTPPUT
+/**
+ * Load the next block from memory to be sent over tftp.
+ *
+ * @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
+ */
+static int load_block(unsigned block, uchar *dst, unsigned len)
+{
+ /* We may want to get the final block from the previous set */
+ ulong offset = ((int)block - 1) * len + tftp_block_wrap_offset;
+ ulong tosend = len;
+
+ tosend = min(net_boot_file_size - offset, tosend);
+ (void)memcpy(dst, (void *)(save_addr + offset), tosend);
+ debug("%s: block=%d, offset=%ld, len=%d, tosend=%ld\n", __func__,
+ block, offset, len, tosend);
+ return tosend;
+}
+#endif
+
+static void tftp_send(void);
+static void tftp_timeout_handler(void);