aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--com32/include/syslinux/movebits.h9
-rw-r--r--com32/lib/syslinux/dump_mmap.c12
-rw-r--r--com32/lib/syslinux/dump_movelist.c9
-rw-r--r--com32/lib/syslinux/load_linux.c12
-rw-r--r--com32/lib/syslinux/movebits.c26
-rw-r--r--com32/lib/syslinux/zonelist.c8
-rw-r--r--com32/mboot/map.c5
-rw-r--r--com32/modules/elf.c16
-rw-r--r--com32/modules/pmload.c16
9 files changed, 48 insertions, 65 deletions
diff --git a/com32/include/syslinux/movebits.h b/com32/include/syslinux/movebits.h
index 54ee7ff9..8bcdf3ed 100644
--- a/com32/include/syslinux/movebits.h
+++ b/com32/include/syslinux/movebits.h
@@ -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 */
diff --git a/com32/lib/syslinux/dump_mmap.c b/com32/lib/syslinux/dump_mmap.c
index 3f1e340b..85638cd9 100644
--- a/com32/lib/syslinux/dump_mmap.c
+++ b/com32/lib/syslinux/dump_mmap.c
@@ -28,20 +28,22 @@
/*
* 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
diff --git a/com32/lib/syslinux/dump_movelist.c b/com32/lib/syslinux/dump_movelist.c
index 282d0068..4042ce96 100644
--- a/com32/lib/syslinux/dump_movelist.c
+++ b/com32/lib/syslinux/dump_movelist.c
@@ -33,14 +33,17 @@
*/
#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
diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c
index 4b60a231..45cd6965 100644
--- a/com32/lib/syslinux/load_linux.c
+++ b/com32/lib/syslinux/load_linux.c
@@ -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);
diff --git a/com32/lib/syslinux/movebits.c b/com32/lib/syslinux/movebits.c
index 6c75105a..7a05f3c1 100644
--- a/com32/lib/syslinux/movebits.c
+++ b/com32/lib/syslinux/movebits.c
@@ -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;
}
diff --git a/com32/lib/syslinux/zonelist.c b/com32/lib/syslinux/zonelist.c
index 915c7a8c..7034c4be 100644
--- a/com32/lib/syslinux/zonelist.c
+++ b/com32/lib/syslinux/zonelist.c
@@ -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;
}
diff --git a/com32/mboot/map.c b/com32/mboot/map.c
index 0a71d4c9..99add306 100644
--- a/com32/mboot/map.c
+++ b/com32/mboot/map.c
@@ -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;
}
diff --git a/com32/modules/elf.c b/com32/modules/elf.c
index 84c80ac2..a946af1f 100644
--- a/com32/modules/elf.c
+++ b/com32/modules/elf.c
@@ -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);
diff --git a/com32/modules/pmload.c b/com32/modules/pmload.c
index 88065fb2..6808d38a 100644
--- a/com32/modules/pmload.c
+++ b/com32/modules/pmload.c
@@ -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);