image: Rename load_addr, save_addr, save_size
[oweals/u-boot.git] / cmd / load.c
index 0aa7937fd4bfeed10a283bbdcd42c129350c0bf6..bed973ede9127942a306fe0dc2657cbf181e6927 100644 (file)
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2000-2004
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
 #include <common.h>
 #include <command.h>
 #include <console.h>
+#include <cpu_func.h>
+#include <env.h>
+#include <flash.h>
 #include <s_record.h>
 #include <net.h>
 #include <exports.h>
+#include <serial.h>
 #include <xyzModem.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -50,11 +53,11 @@ static int do_load_serial(cmd_tbl_t *cmdtp, int flag, int argc,
        load_baudrate = current_baudrate = gd->baudrate;
 #endif
 
-       if (((env_echo = getenv("loads_echo")) != NULL) && (*env_echo == '1')) {
+       env_echo = env_get("loads_echo");
+       if (env_echo && *env_echo == '1')
                do_echo = 1;
-       } else {
+       else
                do_echo = 0;
-       }
 
 #ifdef CONFIG_SYS_LOADS_BAUD_CHANGE
        if (argc >= 2) {
@@ -106,7 +109,7 @@ static int do_load_serial(cmd_tbl_t *cmdtp, int flag, int argc,
                rcode = 1;
        } else {
                printf("## Start Addr      = 0x%08lX\n", addr);
-               load_addr = addr;
+               image_load_addr = addr;
        }
 
 #ifdef CONFIG_SYS_LOADS_BAUD_CHANGE
@@ -151,7 +154,7 @@ static ulong load_serial(long offset)
                case SREC_DATA3:
                case SREC_DATA4:
                    store_addr = addr + offset;
-#ifndef CONFIG_SYS_NO_FLASH
+#ifdef CONFIG_MTD_NOR_FLASH
                    if (addr2info(store_addr)) {
                        int rc;
 
@@ -182,7 +185,7 @@ static ulong load_serial(long offset)
                            start_addr, end_addr, size, size
                    );
                    flush_cache(start_addr, size);
-                   setenv_hex("filesize", size);
+                   env_set_hex("filesize", size);
                    return (addr);
                case SREC_START:
                    break;
@@ -427,9 +430,9 @@ static int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc,
        offset = CONFIG_SYS_LOAD_ADDR;
 
        /* pre-set offset from $loadaddr */
-       if ((s = getenv("loadaddr")) != NULL) {
+       s = env_get("loadaddr");
+       if (s)
                offset = simple_strtoul(s, NULL, 16);
-       }
 
        load_baudrate = current_baudrate = gd->baudrate;
 
@@ -482,12 +485,12 @@ static int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc,
                addr = load_serial_bin(offset);
 
                if (addr == ~0) {
-                       load_addr = 0;
+                       image_load_addr = 0;
                        printf("## Binary (kermit) download aborted\n");
                        rcode = 1;
                } else {
                        printf("## Start Addr      = 0x%08lX\n", addr);
-                       load_addr = addr;
+                       image_load_addr = addr;
                }
        }
        if (load_baudrate != current_baudrate) {
@@ -529,7 +532,7 @@ static ulong load_serial_bin(ulong offset)
        flush_cache(offset, size);
 
        printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
-       setenv_hex("filesize", size);
+       env_set_hex("filesize", size);
 
        return offset;
 }
@@ -971,14 +974,14 @@ static ulong load_serial_ymodem(ulong offset, int mode)
                        store_addr = addr + offset;
                        size += res;
                        addr += res;
-#ifndef CONFIG_SYS_NO_FLASH
+#ifdef CONFIG_MTD_NOR_FLASH
                        if (addr2info(store_addr)) {
                                int rc;
 
                                rc = flash_write((char *) ymodemBuf,
                                                  store_addr, res);
                                if (rc != 0) {
-                                       flash_perror (rc);
+                                       flash_perror(rc);
                                        return (~0);
                                }
                        } else
@@ -997,10 +1000,10 @@ static ulong load_serial_ymodem(ulong offset, int mode)
        xyzModem_stream_terminate(false, &getcxmodem);
 
 
-       flush_cache(offset, size);
+       flush_cache(offset, ALIGN(size, ARCH_DMA_MINALIGN));
 
        printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
-       setenv_hex("filesize", size);
+       env_set_hex("filesize", size);
 
        return offset;
 }
@@ -1081,33 +1084,3 @@ U_BOOT_CMD(
 );
 
 #endif /* CONFIG_CMD_LOADB */
-
-/* -------------------------------------------------------------------- */
-
-#if defined(CONFIG_CMD_HWFLOW)
-int do_hwflow(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-       extern int hwflow_onoff(int);
-
-       if (argc == 2) {
-               if (strcmp(argv[1], "off") == 0)
-                       hwflow_onoff(-1);
-               else
-                       if (strcmp(argv[1], "on") == 0)
-                               hwflow_onoff(1);
-                       else
-                               return CMD_RET_USAGE;
-       }
-       printf("RTS/CTS hardware flow control: %s\n", hwflow_onoff(0) ? "on" : "off");
-       return 0;
-}
-
-/* -------------------------------------------------------------------- */
-
-U_BOOT_CMD(
-       hwflow, 2, 0,   do_hwflow,
-       "turn RTS/CTS hardware flow control in serial line on/off",
-       "[on|off]"
-);
-
-#endif /* CONFIG_CMD_HWFLOW */