com32: make syslinux_dump_*() pure debugging functions
authorH. Peter Anvin <hpa@zytor.com>
Tue, 28 Jun 2011 02:06:43 +0000 (19:06 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 28 Jun 2011 02:06:43 +0000 (19:06 -0700)
Make the syslinux_dump_*() functions pure debugging functions; that is
the way that they are used anyway, and this way they log to the same
place as dprintf.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
com32/include/syslinux/movebits.h
com32/lib/syslinux/dump_mmap.c
com32/lib/syslinux/dump_movelist.c
com32/lib/syslinux/load_linux.c
com32/lib/syslinux/movebits.c
com32/lib/syslinux/zonelist.c
com32/mboot/map.c
com32/modules/elf.c
com32/modules/pmload.c

index 54ee7ff..8bcdf3e 100644 (file)
@@ -83,7 +83,12 @@ int syslinux_memmap_find(struct syslinux_memmap *list,
                         addr_t * start, addr_t * len, addr_t align);
 
 /* Debugging functions */
-void syslinux_dump_movelist(FILE * file, struct syslinux_movelist *ml);
-void syslinux_dump_memmap(FILE * file, struct syslinux_memmap *memmap);
+#ifdef DEBUG
+void syslinux_dump_movelist(struct syslinux_movelist *ml);
+void syslinux_dump_memmap(struct syslinux_memmap *memmap);
+#else
+#define syslinux_dump_movelist(x) ((void)0)
+#define syslinux_dump_memmap(x)          ((void)0)
+#endif
 
 #endif /* _SYSLINUX_MOVEBITS_H */
index 3f1e340..85638cd 100644 (file)
 /*
  * dump_mmap.c
  *
- * Writes a syslinux_memmap out to a specified file.  This is
- * intended for debugging.
+ * Writes a syslinux_memmap out to a dprintf.
  */
 
 #include <stdio.h>
+#include <dprintf.h>
 #include <syslinux/movebits.h>
 
-void syslinux_dump_memmap(FILE * file, struct syslinux_memmap *memmap)
+#ifdef DEBUG
+void syslinux_dump_memmap(struct syslinux_memmap *memmap)
 {
-    fprintf(file, "%10s %10s %10s\n"
+    dprintf("%10s %10s %10s\n"
            "--------------------------------\n", "Start", "Length", "Type");
     while (memmap->next) {
-       fprintf(file, "0x%08x 0x%08x %10d\n", memmap->start,
+       dprintf("0x%08x 0x%08x %10d\n", memmap->start,
                memmap->next->start - memmap->start, memmap->type);
        memmap = memmap->next;
     }
 }
+#endif
index 282d006..4042ce9 100644 (file)
  */
 
 #include <stdio.h>
+#include <dprintf.h>
 #include <syslinux/movebits.h>
 
-void syslinux_dump_movelist(FILE * file, struct syslinux_movelist *ml)
+#ifdef DEBUG
+void syslinux_dump_movelist(struct syslinux_movelist *ml)
 {
-    fprintf(file, "%10s %10s %10s\n"
+    dprintf("%10s %10s %10s\n"
            "--------------------------------\n", "Dest", "Src", "Length");
     while (ml) {
-       fprintf(file, "0x%08x 0x%08x 0x%08x\n", ml->dst, ml->src, ml->len);
+       dprintf("0x%08x 0x%08x 0x%08x\n", ml->dst, ml->src, ml->len);
        ml = ml->next;
     }
 }
+#endif
index 4b60a23..45cd696 100644 (file)
@@ -309,10 +309,8 @@ int syslinux_boot_linux(void *kernel_buf, size_t kernel_size,
     if (!mmap || !amap)
        goto bail;
 
-#if DEBUG
     dprintf("Initial memory map:\n");
-    syslinux_dump_memmap(stdout, mmap);
-#endif
+    syslinux_dump_memmap(mmap);
 
     /* If the user has specified a memory limit, mark that as unavailable.
        Question: should we mark this off-limit in the mmap as well (meaning
@@ -459,16 +457,14 @@ int syslinux_boot_linux(void *kernel_buf, size_t kernel_size,
     /* Linux is OK with sp = 0 = 64K, but perhaps other things aren't... */
     regs.esp.w[0] = min(cmdline_offset, (size_t) 0xfff0);
 
-#if DEBUG
     dprintf("Final memory map:\n");
-    syslinux_dump_memmap(stdout, mmap);
+    syslinux_dump_memmap(mmap);
 
     dprintf("Final available map:\n");
-    syslinux_dump_memmap(stdout, amap);
+    syslinux_dump_memmap(amap);
 
     dprintf("Initial movelist:\n");
-    syslinux_dump_movelist(stdout, fraglist);
-#endif
+    syslinux_dump_movelist(fraglist);
 
     syslinux_shuffle_boot_rm(fraglist, mmap, 0, &regs);
 
index 6c75105..7a05f3c 100644 (file)
@@ -228,10 +228,8 @@ static void shuffle_dealias(struct syslinux_movelist **fraglist,
     addr_t ps, pe, xs, xe, delta;
     bool advance;
 
-#if DEBUG
     dprintf("Before alias resolution:\n");
-    syslinux_dump_movelist(stdout, *fraglist);
-#endif
+    syslinux_dump_movelist(*fraglist);
 
     *postcopy = NULL;
 
@@ -302,12 +300,10 @@ restart:
        ;
     }
 
-#if DEBUG
     dprintf("After alias resolution:\n");
-    syslinux_dump_movelist(stdout, *fraglist);
+    syslinux_dump_movelist(*fraglist);
     dprintf("Post-shuffle copies:\n");
-    syslinux_dump_movelist(stdout, *postcopy);
-#endif
+    syslinux_dump_movelist(*postcopy);
 }
 
 /*
@@ -435,12 +431,10 @@ nomem:
     /* As long as there are unprocessed fragments in the chain... */
     while ((fp = &frags, f = *fp)) {
 
-#if DEBUG
        dprintf("Current free list:\n");
-       syslinux_dump_memmap(stdout, mmap);
+       syslinux_dump_memmap(mmap);
        dprintf("Current frag list:\n");
-       syslinux_dump_movelist(stdout, frags);
-#endif
+       syslinux_dump_movelist(frags);
 
        /* Scan for fragments which can be discarded without action. */
        if (f->src == f->dst) {
@@ -678,16 +672,16 @@ int main(int argc, char *argv[])
 
     *fep = NULL;
 
-    printf("Input move list:\n");
-    syslinux_dump_movelist(stdout, frags);
-    printf("Input free list:\n");
-    syslinux_dump_memmap(stdout, memmap);
+    dprintf("Input move list:\n");
+    syslinux_dump_movelist(frags);
+    dprintf("Input free list:\n");
+    syslinux_dump_memmap(memmap);
 
     if (syslinux_compute_movelist(&moves, frags, memmap)) {
        printf("Failed to compute a move sequence\n");
        return 1;
     } else {
-       printf("Final move list:\n");
+       dprintf("Final move list:\n");
        syslinux_dump_movelist(stdout, moves);
        return 0;
     }
index 915c7a8..7034c4b 100644 (file)
@@ -82,10 +82,8 @@ int syslinux_add_memmap(struct syslinux_memmap **list,
     struct syslinux_memmap *range;
     enum syslinux_memmap_types oldtype;
 
-#if DEBUG
     dprintf("Input memmap:\n");
-    syslinux_dump_memmap(stdout, *list);
-#endif
+    syslinux_dump_memmap(*list);
 
     /* Remove this to make len == 0 mean all of memory */
     if (len == 0)
@@ -150,10 +148,8 @@ int syslinux_add_memmap(struct syslinux_memmap **list,
        }
     }
 
-#if DEBUG
     dprintf("After adding (%#x,%#x,%d):\n", start, len, type);
-    syslinux_dump_memmap(stdout, *list);
-#endif
+    syslinux_dump_memmap(*list);
 
     return 0;
 }
index 0a71d4c..99add30 100644 (file)
@@ -91,10 +91,9 @@ int init_map(void)
        error("Failed to allocate initial memory map!\n");
        return -1;
     }
-#if DEBUG
+
     dprintf("Initial memory map:\n");
-    syslinux_dump_memmap(stdout, mmap);
-#endif
+    syslinux_dump_memmap(mmap);
 
     return 0;
 }
index 182afa6..0ac4517 100644 (file)
@@ -120,10 +120,8 @@ int boot_elf(void *ptr, size_t len, char **argv)
     if (!mmap || !amap)
        goto bail;
 
-#if DEBUG
     dprintf("Initial memory map:\n");
-    syslinux_dump_memmap(stdout, mmap);
-#endif
+    syslinux_dump_memmap(mmap);
 
     ph = (Elf32_Phdr *) (cptr + eh->e_phoff);
 
@@ -185,10 +183,8 @@ int boot_elf(void *ptr, size_t len, char **argv)
     if (!stack_frame)
        goto bail;
 
-#if DEBUG
     dprintf("Right before syslinux_memmap_largest()...\n");
-    syslinux_dump_memmap(stdout, amap);
-#endif
+    syslinux_dump_memmap(amap);
 
     if (syslinux_memmap_largest(amap, SMT_FREE, &lstart, &llen))
        goto bail;              /* NO free memory?! */
@@ -239,16 +235,14 @@ int boot_elf(void *ptr, size_t len, char **argv)
     regs.eip = eh->e_entry;
     regs.esp = stack_pointer;
 
-#if DEBUG
     dprintf("Final memory map:\n");
-    syslinux_dump_memmap(stdout, mmap);
+    syslinux_dump_memmap(mmap);
 
     dprintf("Final available map:\n");
-    syslinux_dump_memmap(stdout, amap);
+    syslinux_dump_memmap(amap);
 
     dprintf("Movelist:\n");
-    syslinux_dump_movelist(stdout, ml);
-#endif
+    syslinux_dump_movelist(ml);
 
     /* This should not return... */
     fputs("Booting...\n", stdout);
index 3064a94..4c01db0 100644 (file)
@@ -81,10 +81,8 @@ int boot_raw(void *ptr, size_t len, addr_t where, char **argv)
     if (!mmap || !amap)
        goto bail;
 
-#if DEBUG
     dprintf("Initial memory map:\n");
-    syslinux_dump_memmap(stdout, mmap);
-#endif
+    syslinux_dump_memmap(mmap);
 
     dprintf("Segment at 0x%08x len 0x%08x\n", where, len);
 
@@ -119,10 +117,8 @@ int boot_raw(void *ptr, size_t len, addr_t where, char **argv)
     if (!stack_frame)
        goto bail;
 
-#if DEBUG
     dprintf("Right before syslinux_memmap_largest()...\n");
-    syslinux_dump_memmap(stdout, amap);
-#endif
+    syslinux_dump_memmap(amap);
 
     if (syslinux_memmap_largest(amap, SMT_FREE, &lstart, &llen))
        goto bail;              /* NO free memory?! */
@@ -173,16 +169,14 @@ int boot_raw(void *ptr, size_t len, addr_t where, char **argv)
     regs.eip = where;
     regs.esp = stack_pointer;
 
-#if DEBUG
     dprintf("Final memory map:\n");
-    syslinux_dump_memmap(stdout, mmap);
+    syslinux_dump_memmap(mmap);
 
     dprintf("Final available map:\n");
-    syslinux_dump_memmap(stdout, amap);
+    syslinux_dump_memmap(amap);
 
     dprintf("Movelist:\n");
-    syslinux_dump_movelist(stdout, ml);
-#endif
+    syslinux_dump_movelist(ml);
 
     /* This should not return... */
     fputs("Booting...\n", stdout);