]> git.ozlabs.org Git - yaboot.git/commitdiff
print available ranges under control of linux, yaboot-debug property
authorAnton Blanchard <anton@samba.org>
Thu, 8 Jul 2010 19:03:37 +0000 (19:03 +0000)
committerTony Breeds <tony@bakeyournoodle.com>
Fri, 16 Jul 2010 05:51:57 +0000 (15:51 +1000)
Debugging yaboot failures is difficult because we often have to retest with a
yaboot built with debug enabled. As a first step to fixing this, look for a
linux,yaboot-debug property and dump the available ranges when it is non zero.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
include/prom.h
second/prom.c
second/yaboot.c

index a512f2be5a4d1db15a144dfc3e256ce81eb0bc93..27436095bddcdfefd51fd33a6951b66876704782 100644 (file)
@@ -93,6 +93,7 @@ void *prom_claim_chunk(void *virt, unsigned int size, unsigned int align);
 void *prom_claim (void *virt, unsigned int size, unsigned int align);
 void prom_release(void *virt, unsigned int size);
 void prom_map (void *phys, void *virt, int size);
+void prom_print_available(void);
 
 /* packages and device nodes */
 
index 5aa0a02830f7dbe83d1dae968fca64878c3d1a5a..3310ef364b9345ed4c220226a1e47cb4d66a4596 100644 (file)
@@ -37,6 +37,8 @@
 
 #define READ_BLOCKS_USE_READ   1
 
+static int yaboot_debug;
+
 prom_entry prom;
 
 ihandle prom_stdin, prom_stdout;
@@ -237,6 +239,9 @@ prom_init (prom_entry pp)
      if (prom_get_chosen ("mmu", &prom_mmu, sizeof(prom_mmu)) <= 0)
          prom_abort ("\nCan't get mmu handle");
 
+     yaboot_debug = 0;
+     prom_get_options("linux,yaboot-debug", &yaboot_debug, sizeof(yaboot_debug));
+
   // move cursor to fresh line
      prom_printf ("\n");
 
@@ -646,6 +651,7 @@ prom_getms(void)
 void
 prom_pause(void)
 {
+     prom_print_available();
      call_prom("enter", 0, 0);
 }
 
@@ -749,6 +755,68 @@ char * prom_get_ip (struct bootp_packet * packet)
      return conf_path;
 }
 
+/* We call this too early to use malloc, 128 cells should be large enough */
+#define NR_AVAILABLE 128
+
+void prom_print_available(void)
+{
+     prom_handle root;
+     unsigned int addr_cells, size_cells;
+     ihandle mem;
+     unsigned int available[NR_AVAILABLE];
+     unsigned int len;
+     unsigned int *p;
+
+     if (!yaboot_debug)
+          return;
+
+     root = prom_finddevice("/");
+     if (!root)
+          return;
+
+     addr_cells = 2;
+     prom_getprop(root, "#address-cells", &addr_cells, sizeof(addr_cells));
+
+     size_cells = 1;
+     prom_getprop(root, "#size-cells", &size_cells, sizeof(size_cells));
+
+     mem = prom_finddevice("/memory@0");
+     if (mem == PROM_INVALID_HANDLE)
+          return;
+
+     len = prom_getprop(mem, "available", available, sizeof(available));
+     if (len == -1)
+          return;
+     len /= 4;
+
+     prom_printf("\nAvailable memory ranges:\n");
+
+     p = available;
+     while (len > 0) {
+          unsigned int addr, size;
+
+          /*
+           * Since we are in 32bit mode it should be safe to only print the
+           * bottom 32bits of each range.
+           */
+          p += (addr_cells - 1);
+          addr = *p;
+          p++;
+
+          p += (size_cells - 1);
+          size = *p;
+          p++;
+
+          if (size)
+               prom_printf("0x%08x-0x%08x (%3d MB)\n", addr, addr + size,
+                           size/1024/1024);
+
+          len -= (addr_cells + size_cells);
+     }
+
+     prom_printf("\n");
+}
+
 /*
  * Local variables:
  * c-file-style: "k&r"
index afa79eeb4feb031ecd9459e533ba8fa0700441dd..c73348845721ee06eaadaff8bab1e5cb8497e37f 100644 (file)
@@ -177,6 +177,8 @@ yaboot_start (unsigned long r3, unsigned long r4, unsigned long r5)
      /* Initialize OF interface */
      prom_init ((prom_entry) r5);
 
+     prom_print_available();
+
      /* Allocate some memory for malloc'ator */
      malloc_base = prom_claim_chunk((void *)MALLOCADDR, MALLOCSIZE, 0);
      if (malloc_base == (void *)-1) {
@@ -1168,6 +1170,8 @@ yaboot_text_ui(void)
 
          DEBUG_F("Entering kernel...\n");
 
+         prom_print_available();
+
           /* call the kernel with our stack. */
          kernel_entry(initrd_base + loadinfo.load_loc, initrd_size, prom, 0, 0);
          continue;