Make the bdinfo printing-functions more generic
The bdinfo command makes use of quite a few functions which show a label followed by a value, on a single line. This sort of thing is generally useful outside of bdinfo, so move it to a generic place. Use 'l' (for label) as the prefix. The margin is still hard-coded to 12, which seems a reasonable limit for a label. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <display_options.h>
|
||||
#include <init.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <asm/mach-types.h>
|
||||
@@ -28,23 +29,22 @@ void arch_print_bdinfo(void)
|
||||
{
|
||||
struct bd_info *bd = gd->bd;
|
||||
|
||||
bdinfo_print_num_l("arch_number", bd->bi_arch_number);
|
||||
lprint_num_l("arch_number", bd->bi_arch_number);
|
||||
#ifdef CFG_SYS_MEM_RESERVE_SECURE
|
||||
if (gd->arch.secure_ram & MEM_RESERVE_SECURE_SECURED) {
|
||||
bdinfo_print_num_ll("Secure ram",
|
||||
gd->arch.secure_ram &
|
||||
MEM_RESERVE_SECURE_ADDR_MASK);
|
||||
lprint_num_ll("Secure ram", gd->arch.secure_ram &
|
||||
MEM_RESERVE_SECURE_ADDR_MASK);
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_RESV_RAM
|
||||
if (gd->arch.resv_ram)
|
||||
bdinfo_print_num_ll("Reserved ram", gd->arch.resv_ram);
|
||||
lprint_num_ll("Reserved ram", gd->arch.resv_ram);
|
||||
#endif
|
||||
#if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
|
||||
bdinfo_print_num_l("TLB addr", gd->arch.tlb_addr);
|
||||
lprint_num_l("TLB addr", gd->arch.tlb_addr);
|
||||
#endif
|
||||
bdinfo_print_num_l("irq_sp", gd->irq_sp); /* irq stack pointer */
|
||||
bdinfo_print_num_l("sp start ", gd->start_addr_sp);
|
||||
lprint_num_l("irq_sp", gd->irq_sp); /* irq stack pointer */
|
||||
lprint_num_l("sp start ", gd->start_addr_sp);
|
||||
/*
|
||||
* TODO: Currently only support for davinci SOC's is added.
|
||||
* Remove this check once all the board implement this.
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <display_options.h>
|
||||
#include <init.h>
|
||||
#include <asm/global_data.h>
|
||||
|
||||
@@ -37,16 +38,16 @@ void arch_print_bdinfo(void)
|
||||
{
|
||||
struct bd_info *bd = gd->bd;
|
||||
|
||||
bdinfo_print_mhz("busfreq", bd->bi_busfreq);
|
||||
lprint_mhz("busfreq", bd->bi_busfreq);
|
||||
#if defined(CFG_SYS_MBAR)
|
||||
bdinfo_print_num_l("mbar", bd->bi_mbar_base);
|
||||
lprint_num_l("mbar", bd->bi_mbar_base);
|
||||
#endif
|
||||
bdinfo_print_mhz("cpufreq", bd->bi_intfreq);
|
||||
lprint_mhz("cpufreq", bd->bi_intfreq);
|
||||
if (IS_ENABLED(CONFIG_PCI))
|
||||
bdinfo_print_mhz("pcifreq", bd->bi_pcifreq);
|
||||
lprint_mhz("pcifreq", bd->bi_pcifreq);
|
||||
#ifdef CONFIG_EXTRA_CLOCK
|
||||
bdinfo_print_mhz("flbfreq", bd->bi_flbfreq);
|
||||
bdinfo_print_mhz("inpfreq", bd->bi_inpfreq);
|
||||
bdinfo_print_mhz("vcofreq", bd->bi_vcofreq);
|
||||
lprint_mhz("flbfreq", bd->bi_flbfreq);
|
||||
lprint_mhz("inpfreq", bd->bi_inpfreq);
|
||||
lprint_mhz("vcofreq", bd->bi_vcofreq);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
/*
|
||||
* Copyright (C) 2022, Ovidiu Panait <ovpanait@gmail.com>
|
||||
*/
|
||||
|
||||
#include <display_options.h>
|
||||
#include <init.h>
|
||||
#include <asm/cpuinfo.h>
|
||||
#include <asm/global_data.h>
|
||||
@@ -13,12 +15,12 @@ void arch_print_bdinfo(void)
|
||||
struct microblaze_cpuinfo *ci = gd_cpuinfo();
|
||||
|
||||
if (ci->icache_size) {
|
||||
bdinfo_print_size("icache", ci->icache_size);
|
||||
bdinfo_print_size("icache line", ci->icache_line_length);
|
||||
lprint_size("icache", ci->icache_size);
|
||||
lprint_size("icache line", ci->icache_line_length);
|
||||
}
|
||||
|
||||
if (ci->dcache_size) {
|
||||
bdinfo_print_size("dcache", ci->dcache_size);
|
||||
bdinfo_print_size("dcache line", ci->dcache_line_length);
|
||||
lprint_size("dcache", ci->dcache_size);
|
||||
lprint_size("dcache line", ci->dcache_line_length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*/
|
||||
|
||||
#include <display_options.h>
|
||||
#include <init.h>
|
||||
#include <asm/global_data.h>
|
||||
|
||||
@@ -38,12 +39,12 @@ void arch_print_bdinfo(void)
|
||||
{
|
||||
struct bd_info *bd = gd->bd;
|
||||
|
||||
bdinfo_print_mhz("busfreq", bd->bi_busfreq);
|
||||
lprint_mhz("busfreq", bd->bi_busfreq);
|
||||
#if defined(CONFIG_MPC8xx) || defined(CONFIG_E500)
|
||||
bdinfo_print_num_l("immr_base", bd->bi_immr_base);
|
||||
lprint_num_l("immr_base", bd->bi_immr_base);
|
||||
#endif
|
||||
bdinfo_print_num_l("bootflags", bd->bi_bootflags);
|
||||
bdinfo_print_mhz("intfreq", bd->bi_intfreq);
|
||||
lprint_num_l("bootflags", bd->bi_bootflags);
|
||||
lprint_mhz("intfreq", bd->bi_intfreq);
|
||||
#ifdef CONFIG_ENABLE_36BIT_PHYS
|
||||
if (IS_ENABLED(CONFIG_PHYS_64BIT))
|
||||
puts("addressing = 36-bit\n");
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* RISC-V-specific information for the 'bdinfo' command
|
||||
*/
|
||||
|
||||
#include <display_options.h>
|
||||
#include <init.h>
|
||||
#include <asm/global_data.h>
|
||||
|
||||
@@ -10,9 +11,9 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
void arch_print_bdinfo(void)
|
||||
{
|
||||
bdinfo_print_num_l("boot hart", gd->arch.boot_hart);
|
||||
lprint_num_l("boot hart", gd->arch.boot_hart);
|
||||
|
||||
if (gd->arch.firmware_fdt_addr)
|
||||
bdinfo_print_num_ll("firmware fdt",
|
||||
(long long)gd->arch.firmware_fdt_addr);
|
||||
lprint_num_ll("firmware fdt",
|
||||
(long long)gd->arch.firmware_fdt_addr);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <cpu_func.h>
|
||||
#include <display_options.h>
|
||||
#include <efi.h>
|
||||
#include <efi_api.h>
|
||||
#include <efi_stub.h>
|
||||
@@ -271,9 +272,9 @@ void efi_show_bdinfo(void)
|
||||
|
||||
ret = efi_info_get(EFIET_SYS_TABLE, (void **)&table, &size);
|
||||
if (!ret) {
|
||||
bdinfo_print_num_l("efi_table", table->sys_table);
|
||||
lprint_num_l("efi_table", table->sys_table);
|
||||
sys_table = (struct efi_system_table *)(uintptr_t)
|
||||
table->sys_table;
|
||||
bdinfo_print_num_l(" revision", sys_table->fw_revision);
|
||||
lprint_num_l(" revision", sys_table->fw_revision);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <cpu.h>
|
||||
#include <display_options.h>
|
||||
#include <efi.h>
|
||||
#include <init.h>
|
||||
#include <asm/cpu.h>
|
||||
@@ -16,24 +17,24 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
void arch_print_bdinfo(void)
|
||||
{
|
||||
bdinfo_print_num_l("prev table", gd->arch.table);
|
||||
bdinfo_print_num_l("clock_rate", gd->arch.clock_rate);
|
||||
bdinfo_print_num_l("tsc_base", gd->arch.tsc_base);
|
||||
bdinfo_print_num_l("vendor", gd->arch.x86_vendor);
|
||||
lprint_num_l("prev table", gd->arch.table);
|
||||
lprint_num_l("clock_rate", gd->arch.clock_rate);
|
||||
lprint_num_l("tsc_base", gd->arch.tsc_base);
|
||||
lprint_num_l("vendor", gd->arch.x86_vendor);
|
||||
if (!IS_ENABLED(CONFIG_X86_64)) {
|
||||
char vendor_name[16];
|
||||
|
||||
x86_cpu_vendor_info(vendor_name);
|
||||
bdinfo_print_str(" name", vendor_name);
|
||||
lprint_str(" name", vendor_name);
|
||||
}
|
||||
bdinfo_print_num_l("model", gd->arch.x86_model);
|
||||
bdinfo_print_num_l("phys_addr in bits", cpu_phys_address_size());
|
||||
bdinfo_print_num_l("table start", gd->arch.table_start);
|
||||
bdinfo_print_num_l("table end", gd->arch.table_end);
|
||||
bdinfo_print_num_l(" high start", gd->arch.table_start_high);
|
||||
bdinfo_print_num_l(" high end", gd->arch.table_end_high);
|
||||
lprint_num_l("model", gd->arch.x86_model);
|
||||
lprint_num_l("phys_addr in bits", cpu_phys_address_size());
|
||||
lprint_num_l("table start", gd->arch.table_start);
|
||||
lprint_num_l("table end", gd->arch.table_end);
|
||||
lprint_num_l(" high start", gd->arch.table_start_high);
|
||||
lprint_num_l(" high end", gd->arch.table_end_high);
|
||||
|
||||
bdinfo_print_num_ll("tsc", rdtsc());
|
||||
lprint_num_ll("tsc", rdtsc());
|
||||
|
||||
if (IS_ENABLED(CONFIG_EFI_STUB))
|
||||
efi_show_bdinfo();
|
||||
|
||||
73
cmd/bdinfo.c
73
cmd/bdinfo.c
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <command.h>
|
||||
#include <display_options.h>
|
||||
#include <dm.h>
|
||||
#include <env.h>
|
||||
#include <getopt.h>
|
||||
@@ -22,27 +23,6 @@
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
void bdinfo_print_size(const char *name, uint64_t size)
|
||||
{
|
||||
printf("%-12s= ", name);
|
||||
print_size(size, "\n");
|
||||
}
|
||||
|
||||
void bdinfo_print_str(const char *name, const char *str)
|
||||
{
|
||||
printf("%-12s= %s\n", name, str);
|
||||
}
|
||||
|
||||
void bdinfo_print_num_l(const char *name, ulong value)
|
||||
{
|
||||
printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
|
||||
}
|
||||
|
||||
void bdinfo_print_num_ll(const char *name, unsigned long long value)
|
||||
{
|
||||
printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong), value);
|
||||
}
|
||||
|
||||
static void print_eth(void)
|
||||
{
|
||||
const int idx = eth_get_dev_index();
|
||||
@@ -65,7 +45,7 @@ static void print_eth(void)
|
||||
printf("IP addr = %s\n", env_get("ipaddr"));
|
||||
}
|
||||
|
||||
void bdinfo_print_mhz(const char *name, unsigned long hz)
|
||||
void lprint_mhz(const char *name, unsigned long hz)
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
@@ -78,9 +58,9 @@ static void print_bi_dram(const struct bd_info *bd)
|
||||
|
||||
for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
|
||||
if (bd->bi_dram[i].size) {
|
||||
bdinfo_print_num_l("DRAM bank", i);
|
||||
bdinfo_print_num_ll("-> start", bd->bi_dram[i].start);
|
||||
bdinfo_print_num_ll("-> size", bd->bi_dram[i].size);
|
||||
lprint_num_l("DRAM bank", i);
|
||||
lprint_num_ll("-> start", bd->bi_dram[i].start);
|
||||
lprint_num_ll("-> size", bd->bi_dram[i].size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,12 +81,11 @@ static void show_video_info(void)
|
||||
struct video_priv *upriv = dev_get_uclass_priv(dev);
|
||||
struct video_uc_plat *plat = dev_get_uclass_plat(dev);
|
||||
|
||||
bdinfo_print_num_ll("FB base", (ulong)upriv->fb);
|
||||
lprint_num_ll("FB base", (ulong)upriv->fb);
|
||||
if (upriv->copy_fb) {
|
||||
bdinfo_print_num_ll("FB copy",
|
||||
(ulong)upriv->copy_fb);
|
||||
bdinfo_print_num_l(" copy size",
|
||||
plat->copy_size);
|
||||
lprint_num_ll("FB copy",
|
||||
(ulong)upriv->copy_fb);
|
||||
lprint_num_l(" copy size", plat->copy_size);
|
||||
}
|
||||
printf("%-12s= %dx%dx%d\n", "FB size", upriv->xsize,
|
||||
upriv->ysize, 1 << upriv->bpix);
|
||||
@@ -126,34 +105,34 @@ static void print_serial(struct udevice *dev)
|
||||
if (ret)
|
||||
return;
|
||||
|
||||
bdinfo_print_num_l("serial addr", info.addr);
|
||||
bdinfo_print_num_l(" width", info.reg_width);
|
||||
bdinfo_print_num_l(" shift", info.reg_shift);
|
||||
bdinfo_print_num_l(" offset", info.reg_offset);
|
||||
bdinfo_print_num_l(" clock", info.clock);
|
||||
lprint_num_l("serial addr", info.addr);
|
||||
lprint_num_l(" width", info.reg_width);
|
||||
lprint_num_l(" shift", info.reg_shift);
|
||||
lprint_num_l(" offset", info.reg_offset);
|
||||
lprint_num_l(" clock", info.clock);
|
||||
}
|
||||
|
||||
static int bdinfo_print_all(struct bd_info *bd)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
bdinfo_print_num_l("bd address", (ulong)bd);
|
||||
lprint_num_l("bd address", (ulong)bd);
|
||||
#endif
|
||||
bdinfo_print_num_l("boot_params", (ulong)bd->bi_boot_params);
|
||||
lprint_num_l("boot_params", (ulong)bd->bi_boot_params);
|
||||
print_bi_dram(bd);
|
||||
bdinfo_print_num_l("flashstart", (ulong)bd->bi_flashstart);
|
||||
bdinfo_print_num_l("flashsize", (ulong)bd->bi_flashsize);
|
||||
bdinfo_print_num_l("flashoffset", (ulong)bd->bi_flashoffset);
|
||||
lprint_num_l("flashstart", (ulong)bd->bi_flashstart);
|
||||
lprint_num_l("flashsize", (ulong)bd->bi_flashsize);
|
||||
lprint_num_l("flashoffset", (ulong)bd->bi_flashoffset);
|
||||
printf("baudrate = %u bps\n", gd->baudrate);
|
||||
bdinfo_print_num_l("relocaddr", gd->relocaddr);
|
||||
bdinfo_print_num_l("reloc off", gd->reloc_off);
|
||||
lprint_num_l("relocaddr", gd->relocaddr);
|
||||
lprint_num_l("reloc off", gd->reloc_off);
|
||||
printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
|
||||
if (IS_ENABLED(CONFIG_CMD_NET) || IS_ENABLED(CONFIG_CMD_NET_LWIP))
|
||||
print_eth();
|
||||
bdinfo_print_num_l("fdt_blob", (ulong)map_to_sysmem(gd->fdt_blob));
|
||||
lprint_num_l("fdt_blob", (ulong)map_to_sysmem(gd->fdt_blob));
|
||||
if (IS_ENABLED(CONFIG_VIDEO))
|
||||
show_video_info();
|
||||
#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
|
||||
bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
|
||||
lprint_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
|
||||
#endif
|
||||
if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
|
||||
lmb_dump_all_force();
|
||||
@@ -163,9 +142,9 @@ static int bdinfo_print_all(struct bd_info *bd)
|
||||
print_serial(gd->cur_serial_dev);
|
||||
|
||||
if (IS_ENABLED(CONFIG_CMD_BDINFO_EXTRA)) {
|
||||
bdinfo_print_num_ll("stack ptr", (ulong)&bd);
|
||||
bdinfo_print_num_ll("ram_top ptr", (ulong)gd->ram_top);
|
||||
bdinfo_print_num_l("malloc base", gd_malloc_start());
|
||||
lprint_num_ll("stack ptr", (ulong)&bd);
|
||||
lprint_num_ll("ram_top ptr", (ulong)gd->ram_top);
|
||||
lprint_num_l("malloc base", gd_malloc_start());
|
||||
}
|
||||
|
||||
arch_print_bdinfo();
|
||||
|
||||
@@ -101,4 +101,27 @@ char *display_options_get_banner(bool newlines, char *buf, int size);
|
||||
char *display_options_get_banner_priv(bool newlines, const char *build_tag,
|
||||
char *buf, int size);
|
||||
|
||||
/* Print a numeric value (for use in arch_print_bdinfo()) */
|
||||
void lprint_num_l(const char *name, ulong value);
|
||||
void lprint_num_ll(const char *name, unsigned long long value);
|
||||
|
||||
/* Print a string value (for use in arch_print_bdinfo()) */
|
||||
void lprint_str(const char *name, const char *str);
|
||||
|
||||
/* Print a clock speed in MHz */
|
||||
void lprint_mhz(const char *name, unsigned long hz);
|
||||
|
||||
/**
|
||||
* lprint_size - print size variables in bdinfo format
|
||||
* @name: string to print before the size
|
||||
* @size: size to print
|
||||
*
|
||||
* Helper function for displaying size variables as properly formatted bdinfo
|
||||
* entries. The size is printed as "xxx Bytes", "xxx KiB", "xxx MiB",
|
||||
* "xxx GiB", etc. as needed;
|
||||
*
|
||||
* For use in arch_print_bdinfo().
|
||||
*/
|
||||
void lprint_size(const char *name, uint64_t size);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -372,29 +372,6 @@ void relocate_code(ulong start_addr_sp, struct global_data *new_gd,
|
||||
__attribute__ ((noreturn));
|
||||
#endif
|
||||
|
||||
/* Print a numeric value (for use in arch_print_bdinfo()) */
|
||||
void bdinfo_print_num_l(const char *name, ulong value);
|
||||
void bdinfo_print_num_ll(const char *name, unsigned long long value);
|
||||
|
||||
/* Print a string value (for use in arch_print_bdinfo()) */
|
||||
void bdinfo_print_str(const char *name, const char *str);
|
||||
|
||||
/* Print a clock speed in MHz */
|
||||
void bdinfo_print_mhz(const char *name, unsigned long hz);
|
||||
|
||||
/**
|
||||
* bdinfo_print_size - print size variables in bdinfo format
|
||||
* @name: string to print before the size
|
||||
* @size: size to print
|
||||
*
|
||||
* Helper function for displaying size variables as properly formatted bdinfo
|
||||
* entries. The size is printed as "xxx Bytes", "xxx KiB", "xxx MiB",
|
||||
* "xxx GiB", etc. as needed;
|
||||
*
|
||||
* For use in arch_print_bdinfo().
|
||||
*/
|
||||
void bdinfo_print_size(const char *name, uint64_t size);
|
||||
|
||||
/* Show arch-specific information for the 'bd' command */
|
||||
void arch_print_bdinfo(void);
|
||||
|
||||
|
||||
@@ -242,3 +242,24 @@ int print_buffer(ulong addr, const void *data, uint width, uint count,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void lprint_size(const char *name, uint64_t size)
|
||||
{
|
||||
printf("%-12s= ", name);
|
||||
print_size(size, "\n");
|
||||
}
|
||||
|
||||
void lprint_str(const char *name, const char *str)
|
||||
{
|
||||
printf("%-12s= %s\n", name, str);
|
||||
}
|
||||
|
||||
void lprint_num_l(const char *name, ulong value)
|
||||
{
|
||||
printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
|
||||
}
|
||||
|
||||
void lprint_num_ll(const char *name, unsigned long long value)
|
||||
{
|
||||
printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong), value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user