DECLARE_GLOBAL_DATA_PTR;
+/*
+ * We cannot use the 'tftpput' command in xPL phases. Given how the
+ * support is integrated in the code, this is how we disable that support
+ * in xPL.
+ */
+#if defined(CONFIG_CMD_TFTPPUT) && !defined(CONFIG_XPL_BUILD)
+#define CMD_TFTPPUT
+#endif
+
/* Well known TFTP port # */
#define WELL_KNOWN_PORT 69
/* Millisecs to timeout for lost pkt */
static ushort tftp_next_ack;
/* Last nack block we send */
static ushort tftp_last_nack;
-#ifdef CONFIG_CMD_TFTPPUT
+#ifdef CMD_TFTPPUT
/* 1 if writing, else 0 */
static int tftp_put_active;
/* 1 if we have sent the last block */
tftp_prev_block = 0;
tftp_block_wrap = 0;
tftp_block_wrap_offset = 0;
-#ifdef CONFIG_CMD_TFTPPUT
+#ifdef CMD_TFTPPUT
tftp_put_final_block_sent = 0;
#endif
led_activity_blink();
}
-#ifdef CONFIG_CMD_TFTPPUT
+#ifdef CMD_TFTPPUT
/**
* Load the next block from memory to be sent over tftp.
*
case STATE_SEND_WRQ:
xp = pkt;
s = (ushort *)pkt;
-#ifdef CONFIG_CMD_TFTPPUT
+#ifdef CMD_TFTPPUT
*s++ = htons(tftp_state == STATE_SEND_RRQ ? TFTP_RRQ :
TFTP_WRQ);
#else
s[0] = htons(TFTP_ACK);
s[1] = htons(tftp_cur_block);
pkt = (uchar *)(s + 2);
-#ifdef CONFIG_CMD_TFTPPUT
+#ifdef CMD_TFTPPUT
if (tftp_put_active) {
int toload = tftp_block_size;
int loaded = load_block(tftp_cur_block, pkt, toload);
net_set_state(NETLOOP_FAIL);
}
-#ifdef CONFIG_CMD_TFTPPUT
+#ifdef CMD_TFTPPUT
static void icmp_handler(unsigned type, unsigned code, unsigned dest,
struct in_addr sip, unsigned src, uchar *pkt,
unsigned len)
break;
case TFTP_ACK:
-#ifdef CONFIG_CMD_TFTPPUT
+#ifdef CMD_TFTPPUT
if (tftp_put_active) {
timeout_count = 0;
if (tftp_put_final_block_sent) {
tftp_next_ack = tftp_windowsize;
-#ifdef CONFIG_CMD_TFTPPUT
+#ifdef CMD_TFTPPUT
if (tftp_put_active && tftp_state == STATE_OACK) {
/* Get ready to send the first block */
tftp_state = STATE_DATA;
tftp_block_size_option = TFTP_MTU_BLOCKSIZE6;
} else {
printf("TFTP %s server %pI4; our IP address is %pI4",
-#ifdef CONFIG_CMD_TFTPPUT
+#ifdef CMD_TFTPPUT
protocol == TFTPPUT ? "to" : "from",
#else
"from",
}
putc('\n');
-#ifdef CONFIG_CMD_TFTPPUT
+#ifdef CMD_TFTPPUT
tftp_put_active = (protocol == TFTPPUT);
if (tftp_put_active) {
printf("Save address: 0x%lx\n", image_save_addr);
net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
net_set_udp_handler(tftp_handler);
-#ifdef CONFIG_CMD_TFTPPUT
+#ifdef CMD_TFTPPUT
net_set_icmp_handler(icmp_handler);
#endif
tftp_remote_port = WELL_KNOWN_PORT;