Merge patch series "cmd: bdinfo: Optionally use getopt and implement bdinfo -a"
Clean up our bdinfo command a bit and introduce "bdinfo -a"
This commit is contained in:
commit
e54987d6af
37
cmd/bdinfo.c
37
cmd/bdinfo.c
|
@ -10,6 +10,7 @@
|
|||
#include <command.h>
|
||||
#include <dm.h>
|
||||
#include <env.h>
|
||||
#include <getopt.h>
|
||||
#include <lmb.h>
|
||||
#include <mapmem.h>
|
||||
#include <net.h>
|
||||
|
@ -133,10 +134,8 @@ static void print_serial(struct udevice *dev)
|
|||
bdinfo_print_num_l(" clock", info.clock);
|
||||
}
|
||||
|
||||
int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||
static int bdinfo_print_all(struct bd_info *bd)
|
||||
{
|
||||
struct bd_info *bd = gd->bd;
|
||||
|
||||
#ifdef DEBUG
|
||||
bdinfo_print_num_l("bd address", (ulong)bd);
|
||||
#endif
|
||||
|
@ -184,8 +183,38 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||
{
|
||||
struct bd_info *bd = gd->bd;
|
||||
struct getopt_state gs;
|
||||
int opt;
|
||||
|
||||
if (!CONFIG_IS_ENABLED(GETOPT) || argc == 1)
|
||||
return bdinfo_print_all(bd);
|
||||
|
||||
getopt_init_state(&gs);
|
||||
while ((opt = getopt(&gs, argc, argv, "aem")) > 0) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
return bdinfo_print_all(bd);
|
||||
case 'e':
|
||||
if (!IS_ENABLED(CONFIG_CMD_NET))
|
||||
return CMD_RET_USAGE;
|
||||
print_eth();
|
||||
return CMD_RET_SUCCESS;
|
||||
case 'm':
|
||||
print_bi_dram(bd);
|
||||
return CMD_RET_SUCCESS;
|
||||
default:
|
||||
return CMD_RET_USAGE;
|
||||
}
|
||||
}
|
||||
|
||||
return CMD_RET_USAGE;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
bdinfo, 1, 1, do_bdinfo,
|
||||
bdinfo, 2, 1, do_bdinfo,
|
||||
"print Board Info structure",
|
||||
""
|
||||
);
|
||||
|
|
|
@ -270,6 +270,7 @@ CONFIG_CMD_DHRYSTONE=y
|
|||
CONFIG_TPM=y
|
||||
CONFIG_LZ4=y
|
||||
CONFIG_ERRNO_STR=y
|
||||
CONFIG_GETOPT=y
|
||||
CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
|
||||
CONFIG_EFI_CAPSULE_ON_DISK=y
|
||||
CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
|
||||
|
|
|
@ -348,6 +348,7 @@ CONFIG_ECDSA=y
|
|||
CONFIG_ECDSA_VERIFY=y
|
||||
CONFIG_TPM=y
|
||||
CONFIG_ERRNO_STR=y
|
||||
CONFIG_GETOPT=y
|
||||
CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
|
||||
CONFIG_EFI_CAPSULE_ON_DISK=y
|
||||
CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
|
||||
|
|
|
@ -130,17 +130,11 @@ static int lmb_test_dump_all(struct unit_test_state *uts, struct lmb *lmb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int bdinfo_test_move(struct unit_test_state *uts)
|
||||
static int bdinfo_check_mem(struct unit_test_state *uts)
|
||||
{
|
||||
struct bd_info *bd = gd->bd;
|
||||
int i;
|
||||
|
||||
/* Test moving the working BDINFO to a new location */
|
||||
ut_assertok(console_record_reset_enable());
|
||||
ut_assertok(run_commandf("bdinfo"));
|
||||
|
||||
ut_assertok(test_num_l(uts, "boot_params", 0));
|
||||
|
||||
for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
|
||||
if (bd->bi_dram[i].size) {
|
||||
ut_assertok(test_num_l(uts, "DRAM bank", i));
|
||||
|
@ -151,6 +145,15 @@ static int bdinfo_test_move(struct unit_test_state *uts)
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bdinfo_test_all(struct unit_test_state *uts)
|
||||
{
|
||||
ut_assertok(test_num_l(uts, "boot_params", 0));
|
||||
|
||||
ut_assertok(bdinfo_check_mem(uts));
|
||||
|
||||
/* CONFIG_SYS_HAS_SRAM testing not supported */
|
||||
ut_assertok(test_num_l(uts, "flashstart", 0));
|
||||
ut_assertok(test_num_l(uts, "flashsize", 0));
|
||||
|
@ -212,12 +215,67 @@ static int bdinfo_test_move(struct unit_test_state *uts)
|
|||
ut_assertok(test_num_l(uts, "malloc base", gd_malloc_start()));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bdinfo_test_full(struct unit_test_state *uts)
|
||||
{
|
||||
/* Test BDINFO full print */
|
||||
ut_assertok(console_record_reset_enable());
|
||||
ut_assertok(run_commandf("bdinfo"));
|
||||
ut_assertok(bdinfo_test_all(uts));
|
||||
ut_assertok(run_commandf("bdinfo -a"));
|
||||
ut_assertok(bdinfo_test_all(uts));
|
||||
ut_assertok(ut_check_console_end(uts));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BDINFO_TEST(bdinfo_test_move, UT_TESTF_CONSOLE_REC);
|
||||
BDINFO_TEST(bdinfo_test_full, UT_TESTF_CONSOLE_REC);
|
||||
|
||||
static int bdinfo_test_help(struct unit_test_state *uts)
|
||||
{
|
||||
/* Test BDINFO unknown option help text print */
|
||||
ut_assertok(console_record_reset_enable());
|
||||
ut_asserteq(1, run_commandf("bdinfo -h"));
|
||||
ut_assert_nextlinen("bdinfo: invalid option -- h");
|
||||
ut_assert_nextlinen("bdinfo - print Board Info structure");
|
||||
ut_assert_nextline_empty();
|
||||
ut_assert_nextlinen("Usage:");
|
||||
ut_assert_nextlinen("bdinfo");
|
||||
ut_assertok(ut_check_console_end(uts));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BDINFO_TEST(bdinfo_test_help, UT_TESTF_CONSOLE_REC);
|
||||
|
||||
static int bdinfo_test_memory(struct unit_test_state *uts)
|
||||
{
|
||||
/* Test BDINFO memory layout only print */
|
||||
ut_assertok(console_record_reset_enable());
|
||||
ut_assertok(run_commandf("bdinfo -m"));
|
||||
ut_assertok(bdinfo_check_mem(uts));
|
||||
ut_assertok(ut_check_console_end(uts));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BDINFO_TEST(bdinfo_test_memory, UT_TESTF_CONSOLE_REC);
|
||||
|
||||
static int bdinfo_test_eth(struct unit_test_state *uts)
|
||||
{
|
||||
/* Test BDINFO ethernet settings only print */
|
||||
ut_assertok(console_record_reset_enable());
|
||||
ut_assertok(run_commandf("bdinfo -e"));
|
||||
if (IS_ENABLED(CONFIG_CMD_NET))
|
||||
ut_assertok(test_eth(uts));
|
||||
ut_assertok(ut_check_console_end(uts));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BDINFO_TEST(bdinfo_test_eth, UT_TESTF_CONSOLE_REC);
|
||||
|
||||
int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user