summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig8
-rw-r--r--cmd/Makefile1
-rw-r--r--cmd/mem.c30
-rw-r--r--cmd/sqfs.c42
4 files changed, 68 insertions, 13 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index e11176451b..23d7e27dc8 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -724,7 +724,7 @@ config CMD_MEMORY
base - print or set address offset
loop - initialize loop on address range
-config MEM_SEARCH
+config CMD_MEM_SEARCH
bool "ms - Memory search"
help
Memory-search command
@@ -2090,6 +2090,12 @@ config CMD_FAT
help
Support for the FAT fs
+config CMD_SQUASHFS
+ bool "SquashFS command support"
+ select FS_SQUASHFS
+ help
+ Enables SquashFS filesystem commands (e.g. load, ls).
+
config CMD_FS_GENERIC
bool "filesystem commands"
help
diff --git a/cmd/Makefile b/cmd/Makefile
index 70750375d1..ef2a22f9b1 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_CMD_EXT4) += ext4.o
obj-$(CONFIG_CMD_EXT2) += ext2.o
obj-$(CONFIG_CMD_FAT) += fat.o
obj-$(CONFIG_CMD_FDT) += fdt.o
+obj-$(CONFIG_CMD_SQUASHFS) += sqfs.o
obj-$(CONFIG_CMD_FLASH) += flash.o
obj-$(CONFIG_CMD_FPGA) += fpga.o
obj-$(CONFIG_CMD_FPGAD) += fpgad.o
diff --git a/cmd/mem.c b/cmd/mem.c
index 575893c18d..190e2b94a7 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -53,7 +53,8 @@ static ulong dp_last_length = 0x40;
static ulong mm_last_addr, mm_last_size;
static ulong base_address = 0;
-#ifdef CONFIG_MEM_SEARCH
+#ifdef CONFIG_CMD_MEM_SEARCH
+static ulong dp_last_ms_length;
static u8 search_buf[64];
static uint search_len;
#endif
@@ -367,7 +368,7 @@ static int do_mem_cp(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
-#ifdef CONFIG_MEM_SEARCH
+#ifdef CONFIG_CMD_MEM_SEARCH
static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -377,6 +378,7 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
ulong last_pos; /* Offset of last match in 'size' units*/
ulong last_addr; /* Address of last displayed line */
int limit = 10;
+ int used_len;
int count;
int size;
int i;
@@ -384,12 +386,12 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
/* We use the last specified parameters, unless new ones are entered */
addr = dp_last_addr;
size = dp_last_size;
- length = dp_last_length;
+ length = dp_last_ms_length;
if (argc < 3)
return CMD_RET_USAGE;
- if ((!flag & CMD_FLAG_REPEAT)) {
+ if (!(flag & CMD_FLAG_REPEAT)) {
/*
* Check for a size specification.
* Defaults to long if no or incorrect specification.
@@ -398,7 +400,8 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
if (size < 0 && size != -2 /* string */)
return 1;
- argc--; argv++;
+ argc--;
+ argv++;
while (argc && *argv[0] == '-') {
int ch = argv[0][1];
@@ -408,7 +411,8 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
limit = simple_strtoul(argv[0] + 2, NULL, 16);
else
return CMD_RET_USAGE;
- argc--; argv++;
+ argc--;
+ argv++;
}
/* Address is specified since argc > 1 */
@@ -421,7 +425,7 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
/* Read the bytes to search for */
end = search_buf + sizeof(search_buf);
for (i = 2, ptr = search_buf; i < argc && ptr < end; i++) {
- if (SUPPORT_64BIT_DATA && size == 8) {
+ if (MEM_SUPPORT_64BIT_DATA && size == 8) {
u64 val = simple_strtoull(argv[i], NULL, 16);
*(u64 *)ptr = val;
@@ -460,7 +464,8 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
last_pos = 0;
last_addr = 0;
count = 0;
- for (offset = 0; offset <= bytes - search_len && count < limit;
+ for (offset = 0;
+ offset < bytes && offset <= bytes - search_len && count < limit;
offset += size) {
void *ptr = buf + offset;
@@ -495,9 +500,10 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
unmap_sysmem(buf);
- dp_last_addr = addr + offset / size;
+ used_len = offset / size;
+ dp_last_addr = addr + used_len;
dp_last_size = size;
- dp_last_length = length - offset / size;
+ dp_last_ms_length = length < used_len ? 0 : length - used_len;
return count ? 0 : CMD_RET_FAILURE;
}
@@ -1337,13 +1343,13 @@ U_BOOT_CMD(
"[.b, .w, .l" HELP_Q "] addr1 addr2 count"
);
-#ifdef CONFIG_MEM_SEARCH
+#ifdef CONFIG_CMD_MEM_SEARCH
/**************************************************/
U_BOOT_CMD(
ms, 255, 1, do_mem_search,
"memory search",
"[.b, .w, .l" HELP_Q ", .s] [-q | -<n>] address #-of-objects <value>..."
- " -q = quiet, -l<val> = match limit" :
+ " -q = quiet, -l<val> = match limit"
);
#endif
diff --git a/cmd/sqfs.c b/cmd/sqfs.c
new file mode 100644
index 0000000000..107038c4cf
--- /dev/null
+++ b/cmd/sqfs.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ *
+ * squashfs.c: implements SquashFS related commands
+ */
+
+#include <command.h>
+#include <fs.h>
+#include <squashfs.h>
+
+static int do_sqfs_ls(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
+{
+ return do_ls(cmdtp, flag, argc, argv, FS_TYPE_SQUASHFS);
+}
+
+U_BOOT_CMD(sqfsls, 4, 1, do_sqfs_ls,
+ "List files in directory. Default: root (/).",
+ "<interface> [<dev[:part]>] [directory]\n"
+ " - list files from 'dev' on 'interface' in 'directory'\n"
+);
+
+static int do_sqfs_load(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
+{
+ return do_load(cmdtp, flag, argc, argv, FS_TYPE_SQUASHFS);
+}
+
+U_BOOT_CMD(sqfsload, 7, 0, do_sqfs_load,
+ "load binary file from a SquashFS filesystem",
+ "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
+ " - Load binary file 'filename' from 'dev' on 'interface'\n"
+ " to address 'addr' from SquashFS filesystem.\n"
+ " 'pos' gives the file position to start loading from.\n"
+ " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n"
+ " 'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n"
+ " the load stops on end of file.\n"
+ " If either 'pos' or 'bytes' are not aligned to\n"
+ " ARCH_DMA_MINALIGN then a misaligned buffer warning will\n"
+ " be printed and performance will suffer for the load."
+);