From: Florent Kermarrec Date: Mon, 18 May 2020 17:59:28 +0000 (+0200) Subject: software/bios: rename cmd_mem_access to cmd_mem. X-Git-Tag: 24jan2021_ls180~328^2~10 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=56b8723b72d17a850983b3003d1128d50e58ec3a;p=litex.git software/bios: rename cmd_mem_access to cmd_mem. --- diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index 9fba33a6..ac7725e6 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -21,7 +21,7 @@ OBJECTS = isr.o \ cmd_boot.o \ cmd_dram.o \ cmd_mdio.o \ - cmd_mem_access.o \ + cmd_mem.o \ cmd_sdcard.o \ cmd_spi_flash.o \ diff --git a/litex/soc/software/bios/commands/cmd_mem.c b/litex/soc/software/bios/commands/cmd_mem.c new file mode 100644 index 00000000..8c63d4c4 --- /dev/null +++ b/litex/soc/software/bios/commands/cmd_mem.c @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: BSD-Source-Code + +#include +#include + +#include "../command.h" +#include "../helpers.h" + +/** + * Command "mr" + * + * Memory read + * + */ +static void mr(int nb_params, char **params) +{ + char *c; + unsigned int *addr; + unsigned int length; + + if (nb_params < 1) { + printf("mr
[length]"); + return; + } + addr = (unsigned int *)strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect address"); + return; + } + if (nb_params == 1) { + length = 4; + } else { + length = strtoul(params[1], &c, 0); + if(*c != 0) { + printf("\nIncorrect length"); + return; + } + } + + dump_bytes(addr, length, (unsigned long)addr); +} + +define_command(mr, mr, "Read address space", MEM_CMDS); + +/** + * Command "mw" + * + * Memory write + * + */ +static void mw(int nb_params, char **params) +{ + char *c; + unsigned int *addr; + unsigned int value; + unsigned int count; + unsigned int i; + + if (nb_params < 2) { + printf("mw
[count]"); + return; + } + + addr = (unsigned int *)strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect address"); + return; + } + + value = strtoul(params[1], &c, 0); + if(*c != 0) { + printf("Incorrect value"); + return; + } + + if (nb_params == 2) { + count = 1; + } else { + count = strtoul(params[2], &c, 0); + if(*c != 0) { + printf("Incorrect count"); + return; + } + } + + for (i = 0; i < count; i++) + *addr++ = value; +} + +define_command(mw, mw, "Write address space", MEM_CMDS); + +/** + * Command "mc" + * + * Memory copy + * + */ +static void mc(int nb_params, char **params) +{ + char *c; + unsigned int *dstaddr; + unsigned int *srcaddr; + unsigned int count; + unsigned int i; + + if (nb_params < 2) { + printf("mc [count]"); + return; + } + + dstaddr = (unsigned int *)strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect destination address"); + return; + } + + srcaddr = (unsigned int *)strtoul(params[1], &c, 0); + if (*c != 0) { + printf("Incorrect source address"); + return; + } + + if (nb_params == 2) { + count = 1; + } else { + count = strtoul(params[2], &c, 0); + if (*c != 0) { + printf("Incorrect count"); + return; + } + } + + for (i = 0; i < count; i++) + *dstaddr++ = *srcaddr++; +} + +define_command(mc, mc, "Copy address space", MEM_CMDS); diff --git a/litex/soc/software/bios/commands/cmd_mem_access.c b/litex/soc/software/bios/commands/cmd_mem_access.c deleted file mode 100644 index 8c63d4c4..00000000 --- a/litex/soc/software/bios/commands/cmd_mem_access.c +++ /dev/null @@ -1,137 +0,0 @@ -// SPDX-License-Identifier: BSD-Source-Code - -#include -#include - -#include "../command.h" -#include "../helpers.h" - -/** - * Command "mr" - * - * Memory read - * - */ -static void mr(int nb_params, char **params) -{ - char *c; - unsigned int *addr; - unsigned int length; - - if (nb_params < 1) { - printf("mr
[length]"); - return; - } - addr = (unsigned int *)strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect address"); - return; - } - if (nb_params == 1) { - length = 4; - } else { - length = strtoul(params[1], &c, 0); - if(*c != 0) { - printf("\nIncorrect length"); - return; - } - } - - dump_bytes(addr, length, (unsigned long)addr); -} - -define_command(mr, mr, "Read address space", MEM_CMDS); - -/** - * Command "mw" - * - * Memory write - * - */ -static void mw(int nb_params, char **params) -{ - char *c; - unsigned int *addr; - unsigned int value; - unsigned int count; - unsigned int i; - - if (nb_params < 2) { - printf("mw
[count]"); - return; - } - - addr = (unsigned int *)strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect address"); - return; - } - - value = strtoul(params[1], &c, 0); - if(*c != 0) { - printf("Incorrect value"); - return; - } - - if (nb_params == 2) { - count = 1; - } else { - count = strtoul(params[2], &c, 0); - if(*c != 0) { - printf("Incorrect count"); - return; - } - } - - for (i = 0; i < count; i++) - *addr++ = value; -} - -define_command(mw, mw, "Write address space", MEM_CMDS); - -/** - * Command "mc" - * - * Memory copy - * - */ -static void mc(int nb_params, char **params) -{ - char *c; - unsigned int *dstaddr; - unsigned int *srcaddr; - unsigned int count; - unsigned int i; - - if (nb_params < 2) { - printf("mc [count]"); - return; - } - - dstaddr = (unsigned int *)strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect destination address"); - return; - } - - srcaddr = (unsigned int *)strtoul(params[1], &c, 0); - if (*c != 0) { - printf("Incorrect source address"); - return; - } - - if (nb_params == 2) { - count = 1; - } else { - count = strtoul(params[2], &c, 0); - if (*c != 0) { - printf("Incorrect count"); - return; - } - } - - for (i = 0; i < count; i++) - *dstaddr++ = *srcaddr++; -} - -define_command(mc, mc, "Copy address space", MEM_CMDS);