summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig20
-rw-r--r--cmd/Makefile4
-rw-r--r--cmd/blk_common.c17
-rw-r--r--cmd/bootefi.c9
-rw-r--r--cmd/cls.c2
-rw-r--r--cmd/eficonfig.c19
-rw-r--r--cmd/fastboot.c4
-rw-r--r--cmd/fwu_mdata.c25
-rw-r--r--cmd/mvebu/bubt.c2
-rw-r--r--cmd/net.c3
-rw-r--r--cmd/optee.c2
-rw-r--r--cmd/pxe.c3
-rw-r--r--cmd/scsi.c3
-rw-r--r--cmd/spawn.c187
14 files changed, 269 insertions, 31 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index ecef664fcea..f21d27cb27f 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -5,7 +5,7 @@ menuconfig CMDLINE
Enable U-Boot's command-line functions. This provides a means
to enter commands into U-Boot for a wide variety of purposes. It
also allows scripts (containing commands) to be executed.
- Various commands and command categorys can be indivdually enabled.
+ Various commands and command categories can be individually enabled.
Depending on the number of commands enabled, this can add
substantially to the size of U-Boot.
@@ -185,6 +185,7 @@ config CMD_UFETCH
config CMD_FWU_METADATA
bool "fwu metadata read"
depends on FWU_MULTI_BANK_UPDATE
+ imply HEXDUMP if FWU_MDATA_V2
help
Command to read the metadata and dump it's contents
@@ -3080,4 +3081,21 @@ config CMD_MESON
help
Enable useful commands for the Meson Soc family developed by Amlogic Inc.
+config CMD_SPAWN
+ bool "spawn and wait commands"
+ depends on UTHREAD
+ help
+ spawn runs a command in the background and sets the job_id environment
+ variable. wait is used to suspend the shell execution until one or more
+ jobs are complete.
+
+config CMD_SPAWN_NUM_JOBS
+ int "Maximum number of simultaneous jobs for spawn"
+ default 16
+ help
+ Job identifiers are in the range 1..CMD_SPAWN_NUM_JOBS. In other words
+ there can be no more that CMD_SPAWN_NUM_JOBS running simultaneously.
+ When a jobs exits, its identifier is available to be re-used by the next
+ spawn command.
+
endif
diff --git a/cmd/Makefile b/cmd/Makefile
index c1275d466c8..80cf70b7fe8 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -239,6 +239,8 @@ obj-$(CONFIG_CMD_SCP03) += scp03.o
obj-$(CONFIG_HUSH_SELECTABLE) += cli.o
+obj-$(CONFIG_CMD_SPAWN) += spawn.o
+
obj-$(CONFIG_ARM) += arm/
obj-$(CONFIG_RISCV) += riscv/
obj-$(CONFIG_SANDBOX) += sandbox/
@@ -255,7 +257,7 @@ obj-$(CONFIG_ARCH_K3) += ti/
obj-$(CONFIG_ARCH_OMAP2PLUS) += ti/
endif # !CONFIG_XPL_BUILD
-obj-$(CONFIG_$(XPL_)CMD_TLV_EEPROM) += tlv_eeprom.o
+obj-$(CONFIG_$(PHASE_)CMD_TLV_EEPROM) += tlv_eeprom.o
obj-$(CONFIG_CMD_BCM_EXT_UTILS) += broadcom/
diff --git a/cmd/blk_common.c b/cmd/blk_common.c
index 4c05a4e0610..56529702a47 100644
--- a/cmd/blk_common.c
+++ b/cmd/blk_common.c
@@ -107,6 +107,23 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id,
printf("%ld blocks written: %s\n", n,
n == cnt ? "OK" : "ERROR");
return n == cnt ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
+ } else if (strcmp(argv[1], "erase") == 0) {
+ lbaint_t blk = hextoul(argv[2], NULL);
+ ulong cnt = hextoul(argv[3], NULL);
+ struct blk_desc *desc;
+ ulong n;
+
+ printf("\n%s erase: device %d block # "LBAFU", count %lu ... ",
+ if_name, *cur_devnump, blk, cnt);
+
+ if (blk_get_desc(uclass_id, *cur_devnump, &desc))
+ return CMD_RET_FAILURE;
+
+ n = blk_derase(desc, blk, cnt);
+
+ printf("%ld blocks erased: %s\n", n,
+ n == cnt ? "OK" : "ERROR");
+ return n == cnt ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
} else {
return CMD_RET_USAGE;
}
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index c1454ffb948..cea6d356ee6 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -38,6 +38,9 @@ static efi_status_t bootefi_run_prepare(const char *load_options_path,
if (ret != EFI_SUCCESS)
return ret;
+ (*image_objp)->auth_status = EFI_IMAGE_AUTH_PASSED;
+ (*image_objp)->entry = efi_selftest;
+
/* Transfer environment variable as load options */
return efi_env_set_load_options((efi_handle_t)*image_objp,
load_options_path,
@@ -106,8 +109,8 @@ static int do_efi_selftest(void)
return CMD_RET_FAILURE;
/* Execute the test */
- ret = EFI_CALL(efi_selftest(&image_obj->header, &systab));
- free(loaded_image_info->load_options);
+ ret = do_bootefi_exec(&image_obj->header,
+ loaded_image_info->load_options);
efi_free_pool(test_device_path);
efi_free_pool(test_image_path);
if (ret != EFI_SUCCESS)
@@ -211,7 +214,7 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
}
}
- ret = efi_binary_run(image_buf, size, fdt);
+ ret = efi_binary_run(image_buf, size, fdt, NULL, 0);
if (ret != EFI_SUCCESS)
return CMD_RET_FAILURE;
diff --git a/cmd/cls.c b/cmd/cls.c
index 4bee8a18305..b1e0619334b 100644
--- a/cmd/cls.c
+++ b/cmd/cls.c
@@ -18,4 +18,4 @@ static int do_video_clear(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_SUCCESS;
}
-U_BOOT_CMD(cls, 1, 1, do_video_clear, "clear screen", "");
+U_BOOT_CMD(cls, 1, 0, do_video_clear, "clear screen", "");
diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index e08b6ba4a5d..629bf1b82c7 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -2283,26 +2283,11 @@ static efi_status_t eficonfig_init(void)
{
efi_status_t ret = EFI_SUCCESS;
static bool init;
- struct efi_handler *handler;
unsigned long columns, rows;
if (!init) {
- ret = efi_search_protocol(efi_root, &efi_guid_text_input_protocol, &handler);
- if (ret != EFI_SUCCESS)
- return ret;
-
- ret = efi_protocol_open(handler, (void **)&cin, efi_root, NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (ret != EFI_SUCCESS)
- return ret;
- ret = efi_search_protocol(efi_root, &efi_guid_text_output_protocol, &handler);
- if (ret != EFI_SUCCESS)
- return ret;
-
- ret = efi_protocol_open(handler, (void **)&cout, efi_root, NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (ret != EFI_SUCCESS)
- return ret;
+ cout = systab.con_out;
+ cin = systab.con_in;
cout->query_mode(cout, cout->mode->mode, &columns, &rows);
avail_row = rows - (EFICONFIG_MENU_HEADER_ROW_NUM +
diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index d4cfc0c7a28..be84a482b81 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -16,6 +16,7 @@
#include <linux/printk.h>
#include <linux/stringify.h>
+#if CONFIG_IS_ENABLED(NET)
static int do_fastboot_udp(int argc, char *const argv[],
uintptr_t buf_addr, size_t buf_size)
{
@@ -55,6 +56,7 @@ static int do_fastboot_tcp(int argc, char *const argv[],
return CMD_RET_SUCCESS;
}
+#endif
static int do_fastboot_usb(int argc, char *const argv[],
uintptr_t buf_addr, size_t buf_size)
@@ -160,10 +162,12 @@ NXTARG:
fastboot_init((void *)buf_addr, buf_size);
+#if CONFIG_IS_ENABLED(NET)
if (!strcmp(argv[1], "udp"))
return do_fastboot_udp(argc, argv, buf_addr, buf_size);
if (!strcmp(argv[1], "tcp"))
return do_fastboot_tcp(argc, argv, buf_addr, buf_size);
+#endif
if (!strcmp(argv[1], "usb")) {
argv++;
argc--;
diff --git a/cmd/fwu_mdata.c b/cmd/fwu_mdata.c
index 9c048d69a13..5b5a2e4d1cd 100644
--- a/cmd/fwu_mdata.c
+++ b/cmd/fwu_mdata.c
@@ -7,6 +7,7 @@
#include <dm.h>
#include <fwu.h>
#include <fwu_mdata.h>
+#include <hexdump.h>
#include <log.h>
#include <stdio.h>
#include <stdlib.h>
@@ -45,6 +46,30 @@ static void print_mdata(struct fwu_data *data)
img_info->accepted == 0x1 ? "yes" : "no");
}
}
+
+ if (data->version == 2) {
+ struct fwu_mdata *mdata = data->fwu_mdata;
+ struct fwu_fw_store_desc *desc;
+ void *end;
+ u32 diff;
+
+ /*
+ * fwu_mdata defines only header that's why taking it as array
+ * which exactly point to image description location
+ */
+ desc = (struct fwu_fw_store_desc *)&mdata[1];
+
+ /* Number of entries is taken from for loop - variable i */
+ end = &desc->img_entry[i];
+ debug("mdata %p, desc %p, end %p\n", mdata, desc, end);
+
+ diff = data->metadata_size - ((void *)end - (void *)mdata);
+ if (diff) {
+ printf("Custom fields covered by CRC len: 0x%x\n", diff);
+ print_hex_dump_bytes("CUSTOM ", DUMP_PREFIX_OFFSET,
+ end, diff);
+ }
+ }
}
int do_fwu_mdata_read(struct cmd_tbl *cmdtp, int flag,
diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index 5e4ffc40d72..6b7d9ee061d 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -931,7 +931,7 @@ static int check_image_header(void)
size = le32_to_cpu(hdr->blocksize);
if (hdr->blockid == 0x78) { /* SATA id */
- struct blk_desc *blk_dev = IS_ENABLED(BLK) ? blk_get_devnum_by_uclass_id(UCLASS_SCSI, 0) : NULL;
+ struct blk_desc *blk_dev = IS_ENABLED(CONFIG_BLK) ? blk_get_devnum_by_uclass_id(UCLASS_SCSI, 0) : NULL;
unsigned long blksz = blk_dev ? blk_dev->blksz : 512;
offset *= blksz;
}
diff --git a/cmd/net.c b/cmd/net.c
index 79525f73a51..eaa1de5295f 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -456,8 +456,7 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc,
}
#if defined(CONFIG_CMD_PING)
-static int do_ping(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[])
+int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
if (argc < 2)
return CMD_RET_USAGE;
diff --git a/cmd/optee.c b/cmd/optee.c
index d0d37293986..e3aae5e9f9b 100644
--- a/cmd/optee.c
+++ b/cmd/optee.c
@@ -53,7 +53,7 @@ static int do_optee_hello_world_ta(struct cmd_tbl *cmdtp, int flag, int argc,
{
int ret, value = 0;
- if (strcmp(argv[1], NULL))
+ if (argc > 1)
value = hextoul(argv[1], NULL);
ret = hello_world_ta(value);
diff --git a/cmd/pxe.c b/cmd/pxe.c
index 37b8dea6ad6..0f26b3b4219 100644
--- a/cmd/pxe.c
+++ b/cmd/pxe.c
@@ -13,7 +13,6 @@
#include "pxe_utils.h"
-#ifdef CONFIG_CMD_NET
const char *pxe_default_paths[] = {
#ifdef CONFIG_SYS_SOC
#ifdef CONFIG_SYS_BOARD
@@ -331,5 +330,3 @@ U_BOOT_CMD(pxe, 4, 1, do_pxe,
"get [" USE_IP6_CMD_PARAM "] - try to retrieve a pxe file using tftp\n"
"pxe boot [pxefile_addr_r] [-ipv6] - boot from the pxe file at pxefile_addr_r\n"
);
-
-#endif /* CONFIG_CMD_NET */
diff --git a/cmd/scsi.c b/cmd/scsi.c
index c286bdc0726..9f7613424e5 100644
--- a/cmd/scsi.c
+++ b/cmd/scsi.c
@@ -60,7 +60,8 @@ U_BOOT_CMD(
"scsi read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"
" to memory address `addr'\n"
"scsi write addr blk# cnt - write `cnt' blocks starting at block\n"
- " `blk#' from memory address `addr'"
+ " `blk#' from memory address `addr'\n"
+ "scsi erase blk# cnt - erase `cnt' blocks starting at block `blk#'"
);
U_BOOT_CMD(
diff --git a/cmd/spawn.c b/cmd/spawn.c
new file mode 100644
index 00000000000..eddbcb792b3
--- /dev/null
+++ b/cmd/spawn.c
@@ -0,0 +1,187 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ */
+
+#include <command.h>
+#include <console.h>
+#include <malloc.h>
+#include <vsprintf.h>
+#include <uthread.h>
+
+/* Spawn arguments and job index */
+struct spa {
+ int argc;
+ char **argv;
+ unsigned int job_idx;
+};
+
+/*
+ * uthread group identifiers for each running job
+ * 0: job slot available, != 0: uthread group id
+ * Note that job[0] is job_id 1, job[1] is job_id 2 etc.
+ */
+static unsigned int job[CONFIG_CMD_SPAWN_NUM_JOBS];
+/* Return values of the commands run as jobs */
+static enum command_ret_t job_ret[CONFIG_CMD_SPAWN_NUM_JOBS];
+
+static void spa_free(struct spa *spa)
+{
+ int i;
+
+ if (!spa)
+ return;
+
+ for (i = 0; i < spa->argc; i++)
+ free(spa->argv[i]);
+ free(spa->argv);
+ free(spa);
+}
+
+static struct spa *spa_create(int argc, char *const argv[])
+{
+ struct spa *spa;
+ int i;
+
+ spa = calloc(1, sizeof(*spa));
+ if (!spa)
+ return NULL;
+ spa->argc = argc;
+ spa->argv = malloc(argc * sizeof(char *));
+ if (!spa->argv)
+ goto err;
+ for (i = 0; i < argc; i++) {
+ spa->argv[i] = strdup(argv[i]);
+ if (!spa->argv[i])
+ goto err;
+ }
+ return spa;
+err:
+ spa_free(spa);
+ return NULL;
+}
+
+static void spawn_thread(void *arg)
+{
+ struct spa *spa = (struct spa *)arg;
+ ulong cycles = 0;
+ int repeatable = 0;
+
+ job_ret[spa->job_idx] = cmd_process(0, spa->argc, spa->argv,
+ &repeatable, &cycles);
+ spa_free(spa);
+}
+
+static unsigned int next_job_id(void)
+{
+ int i;
+
+ for (i = 0; i < CONFIG_CMD_SPAWN_NUM_JOBS; i++)
+ if (!job[i])
+ return i + 1;
+
+ /* No job available */
+ return 0;
+}
+
+static void refresh_jobs(void)
+{
+ int i;
+
+ for (i = 0; i < CONFIG_CMD_SPAWN_NUM_JOBS; i++)
+ if (job[i] && uthread_grp_done(job[i]))
+ job[i] = 0;
+
+}
+
+static int do_spawn(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ unsigned int id;
+ unsigned int idx;
+ struct spa *spa;
+ int ret;
+
+ if (argc == 1)
+ return CMD_RET_USAGE;
+
+ spa = spa_create(argc - 1, argv + 1);
+ if (!spa)
+ return CMD_RET_FAILURE;
+
+ refresh_jobs();
+
+ id = next_job_id();
+ if (!id)
+ return CMD_RET_FAILURE;
+ idx = id - 1;
+
+ job[idx] = uthread_grp_new_id();
+
+ ret = uthread_create(NULL, spawn_thread, spa, 0, job[idx]);
+ if (ret) {
+ job[idx] = 0;
+ return CMD_RET_FAILURE;
+ }
+
+ ret = env_set_ulong("job_id", id);
+ if (ret)
+ return CMD_RET_FAILURE;
+
+ return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(spawn, CONFIG_SYS_MAXARGS, 0, do_spawn,
+ "run commands and summarize execution time",
+ "command [args...]\n");
+
+static enum command_ret_t wait_job(unsigned int idx)
+{
+ int prev = disable_ctrlc(false);
+
+ while (!uthread_grp_done(job[idx])) {
+ if (ctrlc()) {
+ puts("<INTERRUPT>\n");
+ disable_ctrlc(prev);
+ return CMD_RET_FAILURE;
+ }
+ uthread_schedule();
+ }
+
+ job[idx] = 0;
+ disable_ctrlc(prev);
+
+ return job_ret[idx];
+}
+
+static int do_wait(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ enum command_ret_t ret = CMD_RET_SUCCESS;
+ unsigned long id;
+ unsigned int idx;
+ int i;
+
+ if (argc == 1) {
+ for (i = 0; i < CONFIG_CMD_SPAWN_NUM_JOBS; i++)
+ if (job[i])
+ ret = wait_job(i);
+ } else {
+ for (i = 1; i < argc; i++) {
+ id = dectoul(argv[i], NULL);
+ if (id < 0 || id > CONFIG_CMD_SPAWN_NUM_JOBS)
+ return CMD_RET_USAGE;
+ idx = (int)id - 1;
+ ret = wait_job(idx);
+ }
+ }
+
+ return ret;
+}
+
+U_BOOT_CMD(wait, CONFIG_SYS_MAXARGS, 0, do_wait,
+ "wait for one or more jobs to complete",
+ "[job_id ...]\n"
+ " - Wait until all specified jobs have exited and return the\n"
+ " exit status of the last job waited for. When no job_id is\n"
+ " given, wait for all the background jobs.\n");