From: Florent Kermarrec Date: Mon, 18 May 2020 21:26:51 +0000 (+0200) Subject: software/bios: rename commands to cmds and update with libs' names. X-Git-Tag: 24jan2021_ls180~328^2~2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=21e2a34c3fda459ac4dc930892112197a38c153b;p=litex.git software/bios: rename commands to cmds and update with libs' names. --- diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index a4c39660..0e288a43 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -85,7 +85,7 @@ endif %.o: $(BIOS_DIRECTORY)/%.c $(compile) -%.o: $(BIOS_DIRECTORY)/commands/%.c +%.o: $(BIOS_DIRECTORY)/cmds/%.c $(compile) %.o: $(BIOS_DIRECTORY)/%.S diff --git a/litex/soc/software/bios/cmds/cmd_bios.c b/litex/soc/software/bios/cmds/cmd_bios.c new file mode 100644 index 00000000..bbca856c --- /dev/null +++ b/litex/soc/software/bios/cmds/cmd_bios.c @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: BSD-Source-Code + +#include +#include + +#include +#include +#include +#include + +#include "../command.h" +#include "../helpers.h" + +/** + * Command "help" + * + * Print a list of available commands with their help text + * + */ +static void help_handler(int nb_params, char **params) +{ + struct command_struct * const *cmd; + int i, not_empty; + + puts("\nLiteX BIOS, available commands:\n"); + + for (i = 0; i < NB_OF_GROUPS; i++) { + not_empty = 0; + for (cmd = __bios_cmd_start; cmd != __bios_cmd_end; cmd++) { + if ((*cmd)->group == i) { + printf("%-16s - %s\n", (*cmd)->name, (*cmd)->help ? (*cmd)->help : "-"); + not_empty = 1; + } + } + if (not_empty) + printf("\n"); + } +} + +define_command(help, help_handler, "Print this help", MISC_CMDS); + +/** + * Command "ident" + * + * Identifier of the system + * + */ +static void ident_helper(int nb_params, char **params) +{ + char buffer[IDENT_SIZE]; + + get_ident(buffer); + printf("Ident: %s", *buffer ? buffer : "-"); +} + +define_command(ident, ident_helper, "Identifier of the system", SYSTEM_CMDS); + +/** + * Command "reboot" + * + * Reboot the system + * + */ +#ifdef CSR_CTRL_RESET_ADDR +static void reboot(int nb_params, char **params) +{ + ctrl_reset_write(1); +} + +define_command(reboot, reboot, "Reboot the system", SYSTEM_CMDS); +#endif + +/** + * Command "uptime" + * + * Uptime of the system + * + */ +#ifdef CSR_TIMER0_UPTIME_CYCLES_ADDR +static void uptime(int nb_params, char **params) +{ + unsigned long uptime; + + timer0_uptime_latch_write(1); + uptime = timer0_uptime_cycles_read(); + printf("Uptime: %ld sys_clk cycles / %ld seconds", + uptime, + uptime/CONFIG_CLOCK_FREQUENCY + ); +} + +define_command(uptime, uptime, "Uptime of the system since power-up", SYSTEM_CMDS); +#endif + +/** + * Command "crc" + * + * Compute CRC32 over an address range + * + */ +static void crc(int nb_params, char **params) +{ + char *c; + unsigned int addr; + unsigned int length; + + if (nb_params < 2) { + printf("crc
"); + return; + } + + addr = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect address"); + return; + } + + length = strtoul(params[1], &c, 0); + if (*c != 0) { + printf("Incorrect length"); + return; + } + + printf("CRC32: %08x", crc32((unsigned char *)addr, length)); +} + +define_command(crc, crc, "Compute CRC32 of a part of the address space", MISC_CMDS); + +/** + * Command "flush_cpu_dcache" + * + * Flush CPU data cache + * + */ + +define_command(flush_cpu_dcache, flush_cpu_dcache, "Flush CPU data cache", CACHE_CMDS); + +/** + * Command "flush_l2_cache" + * + * Flush L2 cache + * + */ +#ifdef CONFIG_L2_SIZE +define_command(flush_l2_cache, flush_l2_cache, "Flush L2 cache", CACHE_CMDS); +#endif + diff --git a/litex/soc/software/bios/cmds/cmd_boot.c b/litex/soc/software/bios/cmds/cmd_boot.c new file mode 100644 index 00000000..c9cb8a11 --- /dev/null +++ b/litex/soc/software/bios/cmds/cmd_boot.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: BSD-Source-Code + +#include +#include + +#include + +#include "../command.h" +#include "../helpers.h" +#include "../boot.h" + +/** + * Command "flashboot" + * + * Boot software from flash + * + */ +#ifdef FLASH_BOOT_ADDRESS +define_command(flashboot, flashboot, "Boot from flash", BOOT_CMDS); +#endif + +/** + * Command "romboot" + * + * Boot software from embedded rom + * + */ +#ifdef ROM_BOOT_ADDRESS +define_command(romboot, romboot, "Boot from embedded rom", BOOT_CMDS); +#endif + +/** + * Command "serialboot" + * + * Boot software from serial interface + * + */ +define_command(serialboot, serialboot, "Boot via SFL", BOOT_CMDS); + +/** + * Command "netboot" + * + * Boot software from TFTP server + * + */ +#ifdef CSR_ETHMAC_BASE +define_command(netboot, netboot, "Boot via TFTP", BOOT_CMDS); +#endif + +/** + * Command "spisdcardboot" + * + * Boot software from SDcard + * + */ +#ifdef CSR_SPISDCARD_BASE +define_command(spisdcardboot, spisdcardboot, "Boot from SDCard via SPI hardware bitbang", BOOT_CMDS); +#endif + diff --git a/litex/soc/software/bios/cmds/cmd_litedram.c b/litex/soc/software/bios/cmds/cmd_litedram.c new file mode 100644 index 00000000..0b9ea228 --- /dev/null +++ b/litex/soc/software/bios/cmds/cmd_litedram.c @@ -0,0 +1,223 @@ +// SPDX-License-Identifier: BSD-Source-Code + +#include +#include + +#include + +#include "sdram.h" + +#include "../command.h" +#include "../helpers.h" + +/** + * Command "sdrrow" + * + * Precharge/Activate row + * + */ +#ifdef CSR_SDRAM_BASE +static void sdrrow_handler(int nb_params, char **params) +{ + char *c; + unsigned int row; + + if (nb_params < 1) { + sdrrow(0); + printf("Precharged"); + } + + row = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect row"); + return; + } + + sdrrow(row); + printf("Activated row %d", row); +} +define_command(sdrrow, sdrrow_handler, "Precharge/Activate row", LITEDRAM_CMDS); +#endif + +/** + * Command "sdrsw" + * + * Gives SDRAM control to SW + * + */ +#ifdef CSR_SDRAM_BASE +define_command(sdrsw, sdrsw, "Gives SDRAM control to SW", LITEDRAM_CMDS); +#endif + +/** + * Command "sdrhw" + * + * Gives SDRAM control to HW + * + */ +#ifdef CSR_SDRAM_BASE +define_command(sdrhw, sdrhw, "Gives SDRAM control to HW", LITEDRAM_CMDS); +#endif + +/** + * Command "sdrrdbuf" + * + * Dump SDRAM read buffer + * + */ +#ifdef CSR_SDRAM_BASE +static void sdrrdbuf_handler(int nb_params, char **params) +{ + sdrrdbuf(-1); +} + +define_command(sdrrdbuf, sdrrdbuf_handler, "Dump SDRAM read buffer", LITEDRAM_CMDS); +#endif + +/** + * Command "sdrrd" + * + * Read SDRAM data + * + */ +#ifdef CSR_SDRAM_BASE +static void sdrrd_handler(int nb_params, char **params) +{ + unsigned int addr; + int dq; + char *c; + + if (nb_params < 1) { + printf("sdrrd
"); + return; + } + + addr = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect address"); + return; + } + + if (nb_params < 2) + dq = -1; + else { + dq = strtoul(params[1], &c, 0); + if (*c != 0) { + printf("Incorrect DQ"); + return; + } + } + + sdrrd(addr, dq); +} + +define_command(sdrrd, sdrrd_handler, "Read SDRAM data", LITEDRAM_CMDS); +#endif + +/** + * Command "sdrrderr" + * + * Print SDRAM read errors + * + */ +#ifdef CSR_SDRAM_BASE +static void sdrrderr_handler(int nb_params, char **params) +{ + int count; + char *c; + + if (nb_params < 1) { + printf("sdrrderr "); + return; + } + + count = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect count"); + return; + } + + sdrrderr(count); +} + +define_command(sdrrderr, sdrrderr_handler, "Print SDRAM read errors", LITEDRAM_CMDS); +#endif + +/** + * Command "sdrwr" + * + * Write SDRAM test data + * + */ +#ifdef CSR_SDRAM_BASE +static void sdrwr_handler(int nb_params, char **params) +{ + unsigned int addr; + char *c; + + if (nb_params < 1) { + printf("sdrwr
"); + return; + } + + addr = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect address"); + return; + } + + sdrwr(addr); +} + +define_command(sdrwr, sdrwr_handler, "Write SDRAM test data", LITEDRAM_CMDS); +#endif + +/** + * Command "sdrinit" + * + * Start SDRAM initialisation + * + */ +#if defined(CSR_SDRAM_BASE) && defined(CSR_DDRPHY_BASE) +define_command(sdrinit, sdrinit, "Start SDRAM initialisation", LITEDRAM_CMDS); +#endif + +/** + * Command "sdrwlon" + * + * Write leveling ON + * + */ +#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE) +define_command(sdrwlon, sdrwlon, "Enable write leveling", LITEDRAM_CMDS); +#endif + +/** + * Command "sdrwloff" + * + * Write leveling OFF + * + */ +#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE) +define_command(sdrwloff, sdrwloff, "Disable write leveling", LITEDRAM_CMDS); +#endif + +/** + * Command "sdrlevel" + * + * Perform read/write leveling + * + */ +#if defined(CSR_DDRPHY_BASE) && defined(CSR_SDRAM_BASE) +define_command(sdrlevel, sdrlevel, "Perform read/write leveling", LITEDRAM_CMDS); +#endif + +/** + * Command "memtest" + * + * Run a memory test + * + */ +#ifdef CSR_SDRAM_BASE +define_command(memtest, memtest, "Run a memory test", LITEDRAM_CMDS); +#endif diff --git a/litex/soc/software/bios/cmds/cmd_liteeth.c b/litex/soc/software/bios/cmds/cmd_liteeth.c new file mode 100644 index 00000000..f9df1d24 --- /dev/null +++ b/litex/soc/software/bios/cmds/cmd_liteeth.c @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: BSD-Source-Code + +#include +#include + +#include + +#include "mdio.h" + +#include "../command.h" +#include "../helpers.h" + +/** + * Command "mdiow" + * + * Write MDIO register + * + */ +#ifdef CSR_ETHPHY_MDIO_W_ADDR +static void mdiow(int nb_params, char **params) +{ + char *c; + unsigned int phyadr2; + unsigned int reg2; + unsigned int val2; + + if (nb_params < 3) { + printf("mdiow "); + return; + } + + phyadr2 = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect phyadr"); + return; + } + + reg2 = strtoul(params[1], &c, 0); + if (*c != 0) { + printf("Incorrect reg"); + return; + } + + val2 = strtoul(params[2], &c, 0); + if (*c != 0) { + printf("Incorrect val"); + return; + } + + mdio_write(phyadr2, reg2, val2); +} + +define_command(mdiow, mdiow, "Write MDIO register", LITEETH_CMDS); +#endif + +/** + * Command "mdior" + * + * Read MDIO register + * + */ +#ifdef CSR_ETHPHY_MDIO_W_ADDR +static void mdior(int nb_params, char **params) +{ + char *c; + unsigned int phyadr2; + unsigned int reg2; + unsigned int val; + + if (nb_params < 2) { + printf("mdior "); + return; + } + + phyadr2 = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect phyadr"); + return; + } + + reg2 = strtoul(params[1], &c, 0); + if (*c != 0) { + printf("Incorrect reg"); + return; + } + + val = mdio_read(phyadr2, reg2); + printf("Reg %d: 0x%04x", reg2, val); +} + +define_command(mdior, mdior, "Read MDIO register", LITEETH_CMDS); +#endif + +/** + * Command "mdiod" + * + * Dump MDIO registers + * + */ +#ifdef CSR_ETHPHY_MDIO_W_ADDR +static void mdiod(int nb_params, char **params) +{ + char *c; + unsigned int phyadr; + unsigned int count; + unsigned int val; + int i; + + if (nb_params < 2) { + printf("mdiod "); + return; + } + + phyadr = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect phyadr"); + return; + } + + count = strtoul(params[1], &c, 0); + if (*c != 0) { + printf("Incorrect count"); + return; + } + + printf("MDIO dump @0x%x:\n", phyadr); + for (i = 0; i < count; i++) { + val = mdio_read(phyadr, i); + printf("reg %d: 0x%04x", i, val); + } +} + +define_command(mdiod, mdiod, "Dump MDIO registers", LITEETH_CMDS); +#endif diff --git a/litex/soc/software/bios/cmds/cmd_litesdcard.c b/litex/soc/software/bios/cmds/cmd_litesdcard.c new file mode 100644 index 00000000..d5d1651f --- /dev/null +++ b/litex/soc/software/bios/cmds/cmd_litesdcard.c @@ -0,0 +1,144 @@ +// SPDX-License-Identifier: BSD-Source-Code + +#include +#include + +#include + +#include "sdcard.h" + +#include "../command.h" +#include "../helpers.h" + +/** + * Command "sdclk" + * + * Configure SDcard clock frequency + * + */ +#ifdef CSR_SDCORE_BASE +static void sdclk(int nb_params, char **params) +{ + unsigned int frequ; + char *c; + + if (nb_params < 1) { + printf("sdclk "); + return; + } + + frequ = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect frequency"); + return; + } + + sdclk_set_clk(frequ); +} + +struct command_struct cmd_sdclk = +{ + .func = sdclk, + .name = "sdclk", + .help = "SDCard set clk frequency (Mhz)", +}; + +define_command(sdclk, sdclk, "SDCard set clk frequency (Mhz)", LITESDCARD_CMDS); +#endif + +/** + * Command "sdinit" + * + * Initialize SDcard + * + */ +#ifdef CSR_SDCORE_BASE +define_command(sdinit, sdcard_init, "SDCard initialization", LITESDCARD_CMDS); +#endif + +/** + * Command "sdtest" + * + * Perform SDcard read/write tests + * + */ +#ifdef CSR_SDCORE_BASE +static void sdtest(int nb_params, char **params) +{ + unsigned int blocks; + char *c; + + if (nb_params < 1) { + printf("sdtest "); + return; + } + + blocks = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect number of blocks to write"); + return; + } + + sdcard_test(blocks); +} + +define_command(sdtest, sdtest, "SDCard test", LITESDCARD_CMDS); +#endif + +/** + * Command "sdtestread" + * + * Perform SDcard read test + * + */ +#ifdef CSR_SDCORE_BASE +static void sdtestread(int nb_params, char **params) +{ + unsigned int block; + char *c; + + if (nb_params < 1) { + printf("sdtestread "); + return; + } + + block = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect number of block to read"); + return; + } + + sdcard_test_read(block); +} + +define_command(sdtestread, sdtestread, "SDCard test read", LITESDCARD_CMDS); +#endif + +/** + * Command "sdtestwrite" + * + * Perform SDcard write test + * + */ +#ifdef CSR_SDCORE_BASE +static void sdtestwrite(int nb_params, char **params) +{ + unsigned int block; + char *c; + + if (nb_params < 2) { + printf("sdtestread "); + return; + } + + block = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect number of block to write"); + return; + } + + sdcard_test_write(block, params[1]); +} + +define_command(sdtestwrite, sdtestwrite, "SDCard test write", LITESDCARD_CMDS); +#endif diff --git a/litex/soc/software/bios/cmds/cmd_mem.c b/litex/soc/software/bios/cmds/cmd_mem.c new file mode 100644 index 00000000..8c63d4c4 --- /dev/null +++ b/litex/soc/software/bios/cmds/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/cmds/cmd_spiflash.c b/litex/soc/software/bios/cmds/cmd_spiflash.c new file mode 100644 index 00000000..8ca18c87 --- /dev/null +++ b/litex/soc/software/bios/cmds/cmd_spiflash.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: BSD-Source-Code + +#include +#include + +#include + +#include "../command.h" +#include "../helpers.h" + +/** + * Command "fw" + * + * Write data from a memory buffer to SPI flash + * + */ +#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE) +static void fw(int nb_params, char **params) +{ + char *c; + unsigned int addr; + unsigned int value; + unsigned int count; + unsigned int i; + + if (nb_params < 2) { + printf("fw [count]"); + return; + } + + addr = strtoul(params[0], &c, 0); + if (*c != 0) { + printf("Incorrect offset"); + 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++) + write_to_flash(addr + i * 4, (unsigned char *)&value, 4); +} + +define_command(fw, fw, "Write to flash", SPIFLASH_CMDS); +#endif + +/** + * Command "fe" + * + * Flash erase + * + */ +#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE) +static void fe(int nb_params, char **params) +{ + erase_flash(); + printf("Flash erased\n"); +} + +define_command(fe, fe, "Erase whole flash", SPIFLASH_CMDS); +#endif + diff --git a/litex/soc/software/bios/command.h b/litex/soc/software/bios/command.h index 693d7982..1640231f 100644 --- a/litex/soc/software/bios/command.h +++ b/litex/soc/software/bios/command.h @@ -9,17 +9,16 @@ #define HIST_DEPTH 10 /* Used in string list, complete.c */ -#define MISC_CMDS 0 -#define SYSTEM_CMDS 1 -#define CACHE_CMDS 2 -#define BOOT_CMDS 3 -#define DRAM_CMDS 4 -#define MDIO_CMDS 5 -#define MEM_CMDS 6 -#define SD_CMDS 7 -#define SPIFLASH_CMDS 8 -#define DDR_CMDS 9 -#define NB_OF_GROUPS 10 +#define MISC_CMDS 0 +#define SYSTEM_CMDS 1 +#define CACHE_CMDS 2 +#define MEM_CMDS 3 +#define BOOT_CMDS 3 +#define SPIFLASH_CMDS 4 +#define LITEDRAM_CMDS 4 +#define LITEETH_CMDS 5 +#define LITESDCARD_CMDS 7 +#define NB_OF_GROUPS 8 typedef void (*cmd_handler)(int nb_params, char **params); diff --git a/litex/soc/software/bios/commands/cmd_bios.c b/litex/soc/software/bios/commands/cmd_bios.c deleted file mode 100644 index bbca856c..00000000 --- a/litex/soc/software/bios/commands/cmd_bios.c +++ /dev/null @@ -1,147 +0,0 @@ -// SPDX-License-Identifier: BSD-Source-Code - -#include -#include - -#include -#include -#include -#include - -#include "../command.h" -#include "../helpers.h" - -/** - * Command "help" - * - * Print a list of available commands with their help text - * - */ -static void help_handler(int nb_params, char **params) -{ - struct command_struct * const *cmd; - int i, not_empty; - - puts("\nLiteX BIOS, available commands:\n"); - - for (i = 0; i < NB_OF_GROUPS; i++) { - not_empty = 0; - for (cmd = __bios_cmd_start; cmd != __bios_cmd_end; cmd++) { - if ((*cmd)->group == i) { - printf("%-16s - %s\n", (*cmd)->name, (*cmd)->help ? (*cmd)->help : "-"); - not_empty = 1; - } - } - if (not_empty) - printf("\n"); - } -} - -define_command(help, help_handler, "Print this help", MISC_CMDS); - -/** - * Command "ident" - * - * Identifier of the system - * - */ -static void ident_helper(int nb_params, char **params) -{ - char buffer[IDENT_SIZE]; - - get_ident(buffer); - printf("Ident: %s", *buffer ? buffer : "-"); -} - -define_command(ident, ident_helper, "Identifier of the system", SYSTEM_CMDS); - -/** - * Command "reboot" - * - * Reboot the system - * - */ -#ifdef CSR_CTRL_RESET_ADDR -static void reboot(int nb_params, char **params) -{ - ctrl_reset_write(1); -} - -define_command(reboot, reboot, "Reboot the system", SYSTEM_CMDS); -#endif - -/** - * Command "uptime" - * - * Uptime of the system - * - */ -#ifdef CSR_TIMER0_UPTIME_CYCLES_ADDR -static void uptime(int nb_params, char **params) -{ - unsigned long uptime; - - timer0_uptime_latch_write(1); - uptime = timer0_uptime_cycles_read(); - printf("Uptime: %ld sys_clk cycles / %ld seconds", - uptime, - uptime/CONFIG_CLOCK_FREQUENCY - ); -} - -define_command(uptime, uptime, "Uptime of the system since power-up", SYSTEM_CMDS); -#endif - -/** - * Command "crc" - * - * Compute CRC32 over an address range - * - */ -static void crc(int nb_params, char **params) -{ - char *c; - unsigned int addr; - unsigned int length; - - if (nb_params < 2) { - printf("crc
"); - return; - } - - addr = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect address"); - return; - } - - length = strtoul(params[1], &c, 0); - if (*c != 0) { - printf("Incorrect length"); - return; - } - - printf("CRC32: %08x", crc32((unsigned char *)addr, length)); -} - -define_command(crc, crc, "Compute CRC32 of a part of the address space", MISC_CMDS); - -/** - * Command "flush_cpu_dcache" - * - * Flush CPU data cache - * - */ - -define_command(flush_cpu_dcache, flush_cpu_dcache, "Flush CPU data cache", CACHE_CMDS); - -/** - * Command "flush_l2_cache" - * - * Flush L2 cache - * - */ -#ifdef CONFIG_L2_SIZE -define_command(flush_l2_cache, flush_l2_cache, "Flush L2 cache", CACHE_CMDS); -#endif - diff --git a/litex/soc/software/bios/commands/cmd_boot.c b/litex/soc/software/bios/commands/cmd_boot.c deleted file mode 100644 index c9cb8a11..00000000 --- a/litex/soc/software/bios/commands/cmd_boot.c +++ /dev/null @@ -1,59 +0,0 @@ -// SPDX-License-Identifier: BSD-Source-Code - -#include -#include - -#include - -#include "../command.h" -#include "../helpers.h" -#include "../boot.h" - -/** - * Command "flashboot" - * - * Boot software from flash - * - */ -#ifdef FLASH_BOOT_ADDRESS -define_command(flashboot, flashboot, "Boot from flash", BOOT_CMDS); -#endif - -/** - * Command "romboot" - * - * Boot software from embedded rom - * - */ -#ifdef ROM_BOOT_ADDRESS -define_command(romboot, romboot, "Boot from embedded rom", BOOT_CMDS); -#endif - -/** - * Command "serialboot" - * - * Boot software from serial interface - * - */ -define_command(serialboot, serialboot, "Boot via SFL", BOOT_CMDS); - -/** - * Command "netboot" - * - * Boot software from TFTP server - * - */ -#ifdef CSR_ETHMAC_BASE -define_command(netboot, netboot, "Boot via TFTP", BOOT_CMDS); -#endif - -/** - * Command "spisdcardboot" - * - * Boot software from SDcard - * - */ -#ifdef CSR_SPISDCARD_BASE -define_command(spisdcardboot, spisdcardboot, "Boot from SDCard via SPI hardware bitbang", BOOT_CMDS); -#endif - diff --git a/litex/soc/software/bios/commands/cmd_litedram.c b/litex/soc/software/bios/commands/cmd_litedram.c deleted file mode 100644 index 0d05b253..00000000 --- a/litex/soc/software/bios/commands/cmd_litedram.c +++ /dev/null @@ -1,223 +0,0 @@ -// SPDX-License-Identifier: BSD-Source-Code - -#include -#include - -#include - -#include "sdram.h" - -#include "../command.h" -#include "../helpers.h" - -/** - * Command "sdrrow" - * - * Precharge/Activate row - * - */ -#ifdef CSR_SDRAM_BASE -static void sdrrow_handler(int nb_params, char **params) -{ - char *c; - unsigned int row; - - if (nb_params < 1) { - sdrrow(0); - printf("Precharged"); - } - - row = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect row"); - return; - } - - sdrrow(row); - printf("Activated row %d", row); -} -define_command(sdrrow, sdrrow_handler, "Precharge/Activate row", DRAM_CMDS); -#endif - -/** - * Command "sdrsw" - * - * Gives SDRAM control to SW - * - */ -#ifdef CSR_SDRAM_BASE -define_command(sdrsw, sdrsw, "Gives SDRAM control to SW", DRAM_CMDS); -#endif - -/** - * Command "sdrhw" - * - * Gives SDRAM control to HW - * - */ -#ifdef CSR_SDRAM_BASE -define_command(sdrhw, sdrhw, "Gives SDRAM control to HW", DRAM_CMDS); -#endif - -/** - * Command "sdrrdbuf" - * - * Dump SDRAM read buffer - * - */ -#ifdef CSR_SDRAM_BASE -static void sdrrdbuf_handler(int nb_params, char **params) -{ - sdrrdbuf(-1); -} - -define_command(sdrrdbuf, sdrrdbuf_handler, "Dump SDRAM read buffer", DRAM_CMDS); -#endif - -/** - * Command "sdrrd" - * - * Read SDRAM data - * - */ -#ifdef CSR_SDRAM_BASE -static void sdrrd_handler(int nb_params, char **params) -{ - unsigned int addr; - int dq; - char *c; - - if (nb_params < 1) { - printf("sdrrd
"); - return; - } - - addr = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect address"); - return; - } - - if (nb_params < 2) - dq = -1; - else { - dq = strtoul(params[1], &c, 0); - if (*c != 0) { - printf("Incorrect DQ"); - return; - } - } - - sdrrd(addr, dq); -} - -define_command(sdrrd, sdrrd_handler, "Read SDRAM data", DRAM_CMDS); -#endif - -/** - * Command "sdrrderr" - * - * Print SDRAM read errors - * - */ -#ifdef CSR_SDRAM_BASE -static void sdrrderr_handler(int nb_params, char **params) -{ - int count; - char *c; - - if (nb_params < 1) { - printf("sdrrderr "); - return; - } - - count = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect count"); - return; - } - - sdrrderr(count); -} - -define_command(sdrrderr, sdrrderr_handler, "Print SDRAM read errors", DRAM_CMDS); -#endif - -/** - * Command "sdrwr" - * - * Write SDRAM test data - * - */ -#ifdef CSR_SDRAM_BASE -static void sdrwr_handler(int nb_params, char **params) -{ - unsigned int addr; - char *c; - - if (nb_params < 1) { - printf("sdrwr
"); - return; - } - - addr = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect address"); - return; - } - - sdrwr(addr); -} - -define_command(sdrwr, sdrwr_handler, "Write SDRAM test data", DRAM_CMDS); -#endif - -/** - * Command "sdrinit" - * - * Start SDRAM initialisation - * - */ -#if defined(CSR_SDRAM_BASE) && defined(CSR_DDRPHY_BASE) -define_command(sdrinit, sdrinit, "Start SDRAM initialisation", DRAM_CMDS); -#endif - -/** - * Command "sdrwlon" - * - * Write leveling ON - * - */ -#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE) -define_command(sdrwlon, sdrwlon, "Enable write leveling", DRAM_CMDS); -#endif - -/** - * Command "sdrwloff" - * - * Write leveling OFF - * - */ -#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE) -define_command(sdrwloff, sdrwloff, "Disable write leveling", DRAM_CMDS); -#endif - -/** - * Command "sdrlevel" - * - * Perform read/write leveling - * - */ -#if defined(CSR_DDRPHY_BASE) && defined(CSR_SDRAM_BASE) -define_command(sdrlevel, sdrlevel, "Perform read/write leveling", DRAM_CMDS); -#endif - -/** - * Command "memtest" - * - * Run a memory test - * - */ -#ifdef CSR_SDRAM_BASE -define_command(memtest, memtest, "Run a memory test", DRAM_CMDS); -#endif diff --git a/litex/soc/software/bios/commands/cmd_liteeth.c b/litex/soc/software/bios/commands/cmd_liteeth.c deleted file mode 100644 index 86e8fc8a..00000000 --- a/litex/soc/software/bios/commands/cmd_liteeth.c +++ /dev/null @@ -1,134 +0,0 @@ -// SPDX-License-Identifier: BSD-Source-Code - -#include -#include - -#include - -#include "mdio.h" - -#include "../command.h" -#include "../helpers.h" - -/** - * Command "mdiow" - * - * Write MDIO register - * - */ -#ifdef CSR_ETHPHY_MDIO_W_ADDR -static void mdiow(int nb_params, char **params) -{ - char *c; - unsigned int phyadr2; - unsigned int reg2; - unsigned int val2; - - if (nb_params < 3) { - printf("mdiow "); - return; - } - - phyadr2 = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect phyadr"); - return; - } - - reg2 = strtoul(params[1], &c, 0); - if (*c != 0) { - printf("Incorrect reg"); - return; - } - - val2 = strtoul(params[2], &c, 0); - if (*c != 0) { - printf("Incorrect val"); - return; - } - - mdio_write(phyadr2, reg2, val2); -} - -define_command(mdiow, mdiow, "Write MDIO register", MDIO_CMDS); -#endif - -/** - * Command "mdior" - * - * Read MDIO register - * - */ -#ifdef CSR_ETHPHY_MDIO_W_ADDR -static void mdior(int nb_params, char **params) -{ - char *c; - unsigned int phyadr2; - unsigned int reg2; - unsigned int val; - - if (nb_params < 2) { - printf("mdior "); - return; - } - - phyadr2 = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect phyadr"); - return; - } - - reg2 = strtoul(params[1], &c, 0); - if (*c != 0) { - printf("Incorrect reg"); - return; - } - - val = mdio_read(phyadr2, reg2); - printf("Reg %d: 0x%04x", reg2, val); -} - -define_command(mdior, mdior, "Read MDIO register", MDIO_CMDS); -#endif - -/** - * Command "mdiod" - * - * Dump MDIO registers - * - */ -#ifdef CSR_ETHPHY_MDIO_W_ADDR -static void mdiod(int nb_params, char **params) -{ - char *c; - unsigned int phyadr; - unsigned int count; - unsigned int val; - int i; - - if (nb_params < 2) { - printf("mdiod "); - return; - } - - phyadr = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect phyadr"); - return; - } - - count = strtoul(params[1], &c, 0); - if (*c != 0) { - printf("Incorrect count"); - return; - } - - printf("MDIO dump @0x%x:\n", phyadr); - for (i = 0; i < count; i++) { - val = mdio_read(phyadr, i); - printf("reg %d: 0x%04x", i, val); - } -} - -define_command(mdiod, mdiod, "Dump MDIO registers", MDIO_CMDS); -#endif diff --git a/litex/soc/software/bios/commands/cmd_litesdcard.c b/litex/soc/software/bios/commands/cmd_litesdcard.c deleted file mode 100644 index 63347667..00000000 --- a/litex/soc/software/bios/commands/cmd_litesdcard.c +++ /dev/null @@ -1,144 +0,0 @@ -// SPDX-License-Identifier: BSD-Source-Code - -#include -#include - -#include - -#include "sdcard.h" - -#include "../command.h" -#include "../helpers.h" - -/** - * Command "sdclk" - * - * Configure SDcard clock frequency - * - */ -#ifdef CSR_SDCORE_BASE -static void sdclk(int nb_params, char **params) -{ - unsigned int frequ; - char *c; - - if (nb_params < 1) { - printf("sdclk "); - return; - } - - frequ = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect frequency"); - return; - } - - sdclk_set_clk(frequ); -} - -struct command_struct cmd_sdclk = -{ - .func = sdclk, - .name = "sdclk", - .help = "SDCard set clk frequency (Mhz)", -}; - -define_command(sdclk, sdclk, "SDCard set clk frequency (Mhz)", SD_CMDS); -#endif - -/** - * Command "sdinit" - * - * Initialize SDcard - * - */ -#ifdef CSR_SDCORE_BASE -define_command(sdinit, sdcard_init, "SDCard initialization", SD_CMDS); -#endif - -/** - * Command "sdtest" - * - * Perform SDcard read/write tests - * - */ -#ifdef CSR_SDCORE_BASE -static void sdtest(int nb_params, char **params) -{ - unsigned int blocks; - char *c; - - if (nb_params < 1) { - printf("sdtest "); - return; - } - - blocks = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect number of blocks to write"); - return; - } - - sdcard_test(blocks); -} - -define_command(sdtest, sdtest, "SDCard test", SD_CMDS); -#endif - -/** - * Command "sdtestread" - * - * Perform SDcard read test - * - */ -#ifdef CSR_SDCORE_BASE -static void sdtestread(int nb_params, char **params) -{ - unsigned int block; - char *c; - - if (nb_params < 1) { - printf("sdtestread "); - return; - } - - block = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect number of block to read"); - return; - } - - sdcard_test_read(block); -} - -define_command(sdtestread, sdtestread, "SDCard test read", SD_CMDS); -#endif - -/** - * Command "sdtestwrite" - * - * Perform SDcard write test - * - */ -#ifdef CSR_SDCORE_BASE -static void sdtestwrite(int nb_params, char **params) -{ - unsigned int block; - char *c; - - if (nb_params < 2) { - printf("sdtestread "); - return; - } - - block = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect number of block to write"); - return; - } - - sdcard_test_write(block, params[1]); -} - -define_command(sdtestwrite, sdtestwrite, "SDCard test write", SD_CMDS); -#endif diff --git a/litex/soc/software/bios/commands/cmd_mem.c b/litex/soc/software/bios/commands/cmd_mem.c deleted file mode 100644 index 8c63d4c4..00000000 --- a/litex/soc/software/bios/commands/cmd_mem.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); diff --git a/litex/soc/software/bios/commands/cmd_spiflash.c b/litex/soc/software/bios/commands/cmd_spiflash.c deleted file mode 100644 index 8ca18c87..00000000 --- a/litex/soc/software/bios/commands/cmd_spiflash.c +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-License-Identifier: BSD-Source-Code - -#include -#include - -#include - -#include "../command.h" -#include "../helpers.h" - -/** - * Command "fw" - * - * Write data from a memory buffer to SPI flash - * - */ -#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE) -static void fw(int nb_params, char **params) -{ - char *c; - unsigned int addr; - unsigned int value; - unsigned int count; - unsigned int i; - - if (nb_params < 2) { - printf("fw [count]"); - return; - } - - addr = strtoul(params[0], &c, 0); - if (*c != 0) { - printf("Incorrect offset"); - 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++) - write_to_flash(addr + i * 4, (unsigned char *)&value, 4); -} - -define_command(fw, fw, "Write to flash", SPIFLASH_CMDS); -#endif - -/** - * Command "fe" - * - * Flash erase - * - */ -#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE) -static void fe(int nb_params, char **params) -{ - erase_flash(); - printf("Flash erased\n"); -} - -define_command(fe, fe, "Erase whole flash", SPIFLASH_CMDS); -#endif -