]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
lmb: add lmb_dump_region() function
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Fri, 7 May 2021 12:50:31 +0000 (14:50 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 7 Jun 2021 14:48:40 +0000 (10:48 -0400)
Add lmb_dump_region() function, to simplify lmb_dump_all_force().
This patch is based on Linux memblock dump function.

An example of bdinfo output is:

.....
fdt_size    = 0x000146a0
FB base     = 0xfdd00000
lmb_dump_all:
 memory.cnt  = 0x1
 memory[0] [0xc0000000-0xffffffff], 0x40000000 bytes flags: 0
 reserved.cnt  = 0x6
 reserved[0] [0x10000000-0x10045fff], 0x00046000 bytes flags: 4
 reserved[1] [0x30000000-0x3003ffff], 0x00040000 bytes flags: 4
 reserved[2] [0x38000000-0x3800ffff], 0x00010000 bytes flags: 4
 reserved[3] [0xe8000000-0xefffffff], 0x08000000 bytes flags: 4
 reserved[4] [0xfbaea344-0xfdffffff], 0x02515cbc bytes flags: 0
 reserved[5] [0xfe000000-0xffffffff], 0x02000000 bytes flags: 4
arch_number = 0x00000000
TLB addr    = 0xfdff0000
....

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
lib/lmb.c

index a0fb8c7e88d6cb3cf356cec6f3054168db4d9ac2..7bd1255f7a4c14cd8d0f6000c176b9151d98df0d 100644 (file)
--- a/lib/lmb.c
+++ b/lib/lmb.c
 
 #define LMB_ALLOC_ANYWHERE     0
 
-void lmb_dump_all_force(struct lmb *lmb)
+static void lmb_dump_region(struct lmb_region *rgn, char *name)
 {
-       unsigned long i;
+       unsigned long long base, size, end;
+       enum lmb_flags flags;
+       int i;
 
-       printf("lmb_dump_all:\n");
-       printf("    memory.cnt             = 0x%lx\n", lmb->memory.cnt);
-       for (i = 0; i < lmb->memory.cnt; i++) {
-               printf("    memory.reg[0x%lx].base   = 0x%llx\n", i,
-                      (unsigned long long)lmb->memory.region[i].base);
-               printf("                   .size   = 0x%llx\n",
-                      (unsigned long long)lmb->memory.region[i].size);
-               printf("                   .flags   = 0x%x\n",
-                      lmb->memory.region[i].flags);
-       }
+       printf(" %s.cnt  = 0x%lx\n", name, rgn->cnt);
 
-       printf("\n    reserved.cnt         = 0x%lx\n", lmb->reserved.cnt);
-       for (i = 0; i < lmb->reserved.cnt; i++) {
-               printf("    reserved.reg[0x%lx].base = 0x%llx\n", i,
-                      (unsigned long long)lmb->reserved.region[i].base);
-               printf("                     .size = 0x%llx\n",
-                      (unsigned long long)lmb->reserved.region[i].size);
-               printf("                     .flags = 0x%x\n",
-                      lmb->reserved.region[i].flags);
+       for (i = 0; i < rgn->cnt; i++) {
+               base = rgn->region[i].base;
+               size = rgn->region[i].size;
+               end = base + size - 1;
+               flags = rgn->region[i].flags;
+
+               printf(" %s[%d]\t[0x%llx-0x%llx], 0x%08llx bytes flags: %x\n",
+                      name, i, base, end, size, flags);
        }
 }
 
+void lmb_dump_all_force(struct lmb *lmb)
+{
+       printf("lmb_dump_all:\n");
+       lmb_dump_region(&lmb->memory, "memory");
+       lmb_dump_region(&lmb->reserved, "reserved");
+}
+
 void lmb_dump_all(struct lmb *lmb)
 {
 #ifdef DEBUG