Skip to contentSkip to conversation

cmd: bdinfo: cleanup phys_addr_t output

PATCH New Heinrich Schuchardt 5 participants 5 messages Jul 28, 2020 – Aug 5, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: bdinfo: cleanup phys_addr_t output

We currently print the memory size with at least 8 hexadecimal digits. This creates a ragged output on 64 bit boards, e.g. on a Kendryte K210:

DRAM bank   = 0x0000000000000002
-> start    = 0x0000000080600000
-> size     = 0x0000000000200000
memstart    = 0x0000000000000000
memsize     = 0x00000000
flashstart  = 0x0000000000000000
flashsize   = 0x0000000000000000

flashoffset = 0x0000000000000000

All other numbers are printed with the number of digits needed for the type ulong. So use this value as minimum number of digits (precision) for printing physical addresses.

---
 cmd/bdinfo.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
cmd/bdinfo.c +4 -3
index 8b2c105e77..519f5de146 100644
@@ -33,9 +33,10 @@ static void print_eth(int idx)
 	printf("%-12s= %s\n", name, val);
 }
 
-static void print_lnum(const char *name, unsigned long long value)
+static void print_phys_addr(const char *name, phys_addr_t value)
 {
-	printf("%-12s= 0x%.8llX\n", name, value);
+	printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong),
+	       (unsigned long long)value);
 }
 
 void bdinfo_print_mhz(const char *name, unsigned long hz)
@@ -74,7 +75,7 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 	bdinfo_print_num("boot_params", (ulong)bd->bi_boot_params);
 	print_bi_dram(bd);
 	bdinfo_print_num("memstart", (ulong)bd->bi_memstart);
-	print_lnum("memsize", (u64)bd->bi_memsize);
+	print_phys_addr("memsize", bd->bi_memsize);
 	bdinfo_print_num("flashstart", (ulong)bd->bi_flashstart);
 	bdinfo_print_num("flashsize", (ulong)bd->bi_flashsize);
 	bdinfo_print_num("flashoffset", (ulong)bd->bi_flashoffset);

--
2.27.0

#1 lore raw

PATCH 1/1 cmd: bdinfo: cleanup phys_addr_t output

Hello Heinrich,

Am 28.07.2020 um 17:56 schrieb Heinrich Schuchardt:

Quoted 12 lines

We currently print the memory size with at least 8 hexadecimal digits. This creates a ragged output on 64 bit boards, e.g. on a Kendryte K210:

DRAM bank   = 0x0000000000000002
-> start    = 0x0000000080600000
-> size     = 0x0000000000200000
memstart    = 0x0000000000000000
memsize     = 0x00000000
flashstart  = 0x0000000000000000
flashsize   = 0x0000000000000000

flashoffset = 0x0000000000000000

Quoted 8 lines

All other numbers are printed with the number of digits needed for the type ulong. So use this value as minimum number of digits (precision) for printing physical addresses.

---
  cmd/bdinfo.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#2 lore raw

PATCH 1/1 cmd: bdinfo: cleanup phys_addr_t output

In reply to Heinrich Schuchardt
Quoted 10 lines · Heinrich Schuchardt

We currently print the memory size with at least 8 hexadecimal digits. This creates a ragged output on 64 bit boards, e.g. on a Kendryte K210:

DRAM bank   = 0x0000000000000002
-> start    = 0x0000000080600000
-> size     = 0x0000000000200000
memstart    = 0x0000000000000000
memsize     = 0x00000000
flashstart  = 0x0000000000000000
flashsize   = 0x0000000000000000
Quoted 7 lines

flashoffset = 0x0000000000000000

All other numbers are printed with the number of digits needed for the type ulong. So use this value as minimum number of digits (precision) for printing physical addresses.

Thanks,
Stefan

Quoted 31 lines
---
  cmd/bdinfo.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
cmd/bdinfo.c +4 -4
index 8b2c105e77..519f5de146 100644
@@ -33,9 +33,10 @@ static void print_eth(int idx)
  	printf("%-12s= %s\n", name, val);
  }
 
-static void print_lnum(const char *name, unsigned long long value)
+static void print_phys_addr(const char *name, phys_addr_t value)
  {
-	printf("%-12s= 0x%.8llX\n", name, value);
+	printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong),
+	       (unsigned long long)value);
  }
 
  void bdinfo_print_mhz(const char *name, unsigned long hz)
@@ -74,7 +75,7 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  	bdinfo_print_num("boot_params", (ulong)bd->bi_boot_params);
  	print_bi_dram(bd);
  	bdinfo_print_num("memstart", (ulong)bd->bi_memstart);
-	print_lnum("memsize", (u64)bd->bi_memsize);
+	print_phys_addr("memsize", bd->bi_memsize);
  	bdinfo_print_num("flashstart", (ulong)bd->bi_flashstart);
  	bdinfo_print_num("flashsize", (ulong)bd->bi_flashsize);
  	bdinfo_print_num("flashoffset", (ulong)bd->bi_flashoffset);
--
Quoted 2 lines

2.27.0

Viele Gr??e,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
#3 lore raw

PATCH 1/1 cmd: bdinfo: cleanup phys_addr_t output

In reply to Heinrich Schuchardt
Quoted 13 lines · Heinrich Schuchardt

We currently print the memory size with at least 8 hexadecimal digits. This creates a ragged output on 64 bit boards, e.g. on a Kendryte K210:

DRAM bank   = 0x0000000000000002
-> start    = 0x0000000080600000
-> size     = 0x0000000000200000
memstart    = 0x0000000000000000
memsize     = 0x00000000
flashstart  = 0x0000000000000000
flashsize   = 0x0000000000000000

flashoffset = 0x0000000000000000

Quoted 8 lines

All other numbers are printed with the number of digits needed for the type ulong. So use this value as minimum number of digits (precision) for printing physical addresses.

---
 cmd/bdinfo.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
#4 lore raw

PATCH 1/1 cmd: bdinfo: cleanup phys_addr_t output

In reply to Heinrich Schuchardt
Quoted 12 lines · Heinrich Schuchardt

We currently print the memory size with at least 8 hexadecimal digits. This creates a ragged output on 64 bit boards, e.g. on a Kendryte K210:

DRAM bank   = 0x0000000000000002
-> start    = 0x0000000080600000
-> size     = 0x0000000000200000
memstart    = 0x0000000000000000
memsize     = 0x00000000
flashstart  = 0x0000000000000000
flashsize   = 0x0000000000000000

flashoffset = 0x0000000000000000

Quoted 8 lines

All other numbers are printed with the number of digits needed for the type ulong. So use this value as minimum number of digits (precision) for printing physical addresses.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200805/d12995c8/attachment.sig>