Convert mp() to dprintf()
authorMatt Fleming <matt.fleming@linux.intel.com>
Tue, 8 Mar 2011 13:13:28 +0000 (13:13 +0000)
committerMatt Fleming <matt.fleming@linux.intel.com>
Wed, 9 Mar 2011 14:32:36 +0000 (14:32 +0000)
There's only one function required for printing debugging information
and that is dprintf() - there is no need to invent another. dprintf()
is also superior to mp() because it can be enabled/disabled on a
per-file basis via the DEBUG symbol.

Switch all users of mp() to dprintf() and leave them disabled (don't
define the DEBUG) so we have a less verbose boot by default.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
com32/elflink/ldlinux/cli.c
com32/elflink/ldlinux/readconfig.c
com32/elflink/modules/menumain.c
com32/elflink/modules/test.c
com32/include/sys/module.h
com32/lib/sys/module/elf_module.c
com32/lib/sys/module/exec.c
core/elflink/execute.c
core/elflink/kernel.c
core/mem/init.c

index 551113f..77d32cd 100644 (file)
@@ -13,6 +13,7 @@
 #include <sys/exec.h>
 #include <sys/module.h>
 #include <core-elf.h>
+#include <dprintf.h>
 
 #include "getkey.h"
 #include "menu.h"
@@ -24,7 +25,7 @@ static struct list_head cli_history_head;
 
 void clear_screen(void)
 {
-    //mp("enter");
+    //dprintf("enter");
     fputs("\033e\033%@\033)0\033(B\1#0\033[?25l\033[2J", stdout);
 }
 
@@ -34,7 +35,7 @@ int mygetkey(clock_t timeout)
     clock_t tto, to;
     int key;
 
-    //mp("enter");
+    //dprintf("enter");
     if (!totaltimeout)
        return get_key(stdin, timeout);
 
@@ -52,13 +53,13 @@ int mygetkey(clock_t timeout)
        totaltimeout -= t;
 
        if (key != KEY_NONE) {
-               //mp("get key 0x%x", key);
+               //dprintf("get key 0x%x", key);
            return key;
        }
 
        if (timeout) {
            if (timeout <= t) {
-               //mp("timeout");
+               //dprintf("timeout");
                return KEY_NONE;
                }
 
@@ -375,7 +376,7 @@ void process_command(const char *cmd, bool history)
                list_add(&(comm->list), &cli_history_head);
        }
 
-       //      mp("raw cmd = %s", cmd);
+       //      dprintf("raw cmd = %s", cmd);
        strcpy(temp_cmd, cmd);
        module_name = strtok(cmd, COMMAND_DELIM);
        len_mn = strlen(module_name);
@@ -383,7 +384,7 @@ void process_command(const char *cmd, bool history)
        if (!strcmp(module_name + len_mn - 4, ".c32")) {
                if (module_find(module_name) != NULL) {
                        /* make module re-enterable */
-                 //            mp("Module %s is already running");
+                 //            dprintf("Module %s is already running");
                }
                do {
                        argv[0] = module_name;
index 1fb9156..f365b6f 100644 (file)
@@ -23,6 +23,7 @@
 #include <syslinux/adv.h>
 #include <syslinux/config.h>
 #include <core-elf.h>
+#include <dprintf.h>
 
 #include "menu.h"
 #include "config.h"
@@ -171,7 +172,7 @@ static struct menu *new_menu(struct menu *parent,
     struct menu *m = calloc(1, sizeof(struct menu));
     int i;
        
-       //mp("enter: menu_label = %s", label);
+       //dprintf("enter: menu_label = %s", label);
 
     m->label = label;
     m->title = refstr_get(empty_string);
@@ -260,7 +261,7 @@ static struct menu_entry *new_entry(struct menu *m)
 {
     struct menu_entry *me;
 
-    //mp("enter, call from menu %s", m->label);
+    //dprintf("enter, call from menu %s", m->label);
 
     if (m->nentries >= m->nentries_space) {
        if (!m->nentries_space)
@@ -377,7 +378,7 @@ static void record(struct menu *m, struct labeldata *ld, const char *append)
            else
                rsprintf(&me->cmdline, ".%s %s%s%s%s",
                         kernel_types[ld->type], ld->kernel, s, a, ipoptions);
-               mp("type = %s, cmd = %s", kernel_types[ld->type], me->cmdline);
+               dprintf("type = %s, cmd = %s", kernel_types[ld->type], me->cmdline);
            break;
 
        case MA_GOTO_UNRES:
@@ -931,7 +932,7 @@ do_include:
                refstr_put(append);
                append = a;
            }
-           //mp("we got a append: %s", a);
+           //dprintf("we got a append: %s", a);
        } else if (looking_at(p, "initrd")) {
            const char *a = refstrdup(skipspace(p + 6));
            if (ld.label) {
@@ -961,7 +962,7 @@ do_include:
                refstr_put(ld.kernel);
                ld.kernel = refstrdup(skipspace(ep));
                ld.type = type;
-               //mp("got a kernel: %s, type = %d", ld.kernel, ld.type);
+               //dprintf("got a kernel: %s, type = %d", ld.kernel, ld.type);
            }
        } else if (looking_at(p, "timeout")) {
            m->timeout = (atoi(skipspace(p + 7)) * CLK_TCK + 9) / 10;
@@ -1083,7 +1084,7 @@ static void resolve_gotos(void)
 
 static void dump_menu(struct menu *menu)
 {
-       mp("will dump menu for %s:", menu->label);
+       dprintf("will dump menu for %s:", menu->label);
        printf("entries num: %d\n", menu->nentries);
        printf("defentry: %d, nam = %s\n",
                menu->defentry, menu->menu_entries[menu->defentry]->label);
@@ -1099,7 +1100,7 @@ void parse_configs(char **argv)
     struct menu *m;
     struct menu_entry *me;
     char *cmdline;
-    mp("enter");
+    dprintf("enter");
 
     empty_string = refstrdup("");
 
@@ -1122,7 +1123,7 @@ void parse_configs(char **argv)
        parse_one_config("~");
     } else {
        while ((filename = *argv++)) {
-               mp("Parsing config: %s", filename);
+               dprintf("Parsing config: %s", filename);
            parse_one_config(filename);
        }
     }
@@ -1136,7 +1137,7 @@ void parse_configs(char **argv)
     /* Handle global default */
     //if (has_ui && globaldefault) {
     if (globaldefault) {
-       mp("gloabldefault = %s", globaldefault);
+       dprintf("gloabldefault = %s", globaldefault);
        me = find_label(globaldefault);
        if (me && me->menu != hide_menu) {
            me->menu->defentry = me->entry;
index 265f4c4..4d00dc3 100644 (file)
@@ -31,6 +31,7 @@
 #include <syslinux/adv.h>
 #include <sys/module.h>
 #include <core-elf.h>
+#include <dprintf.h>
 
 #include "menu.h"
 #include "cli.h"
@@ -899,7 +900,7 @@ static const char *run_menu(void)
 
 static void dump_menu(struct menu *menu)
 {
-       mp("will dump menu for %s:", menu->label);
+       dprintf("will dump menu for %s:", menu->label);
        printf("entries num: %d\n", menu->nentries);
        printf("defentry: %d, nam = %s\n",
                menu->defentry, menu->menu_entries[menu->defentry]->label);
@@ -956,7 +957,7 @@ int menu_main(int argc, char *argv[])
        printf("\033[?25h\033[%d;1H\033[0m", END_ROW);
 
        if (cmdline) {
-               mp("cmdline = %s", cmdline);
+               dprintf("cmdline = %s", cmdline);
            execute(cmdline, KT_NONE);
            if (cm->onerror)
                execute(cm->onerror, KT_NONE);
index 82df642..dd9e520 100644 (file)
@@ -46,6 +46,7 @@
 #include <syslinux/loadfile.h>
 #include <syslinux/linux.h>
 #include <sys/module.h>
+#include <dprintf.h>
 
 //const char *progname = "test.c32";
 
@@ -94,11 +95,11 @@ static int test_main(int argc, char *argv[])
 
 
        if (initramfs_load_archive(initramfs, "initrd.gz"))
-               mp("initrd load failure\n");
+               dprintf("initrd load failure\n");
        else
-               mp("initrd load success\n");
+               dprintf("initrd load success\n");
 
-       mp("1111");
+       dprintf("1111");
 
         /* This should not return... */
     syslinux_boot_linux(kernel_data, kernel_len, initramfs, cmdline);
index 0c7c71f..dbeab4a 100644 (file)
@@ -135,7 +135,7 @@ struct elf_module {
 static inline void dump_elf_module(struct elf_module *module)
 {
        /*
-       mp("module name = %s", module->name);
+       dprintf("module name = %s", module->name);
        printf("base_addr = 0x%p, module_size = %d\n", module->base_addr, module->module_size);
        printf("hash tlb = 0x%p, ghash tbl = 0x%p\n", module->hash_table, module->ghash_table);
        printf("str tbl = 0x%p, size = %d\n", module->str_table, module->strtable_size);
index d04230e..4bc5d94 100644 (file)
@@ -10,6 +10,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <elf.h>
+#include <dprintf.h>
 
 #include <linux/list.h>
 #include <sys/module.h>
@@ -480,7 +481,7 @@ int module_load(struct elf_module *module) {
        // Perform the relocations
        resolve_symbols(module);
 
-       //mp("module->symtable_size = %d\n", module->symtable_size);
+       //dprintf("module->symtable_size = %d\n", module->symtable_size);
 
        //print_elf_symbols(module);
 
index 03d11cb..54182cc 100644 (file)
@@ -14,8 +14,9 @@
 #include <setjmp.h>
 #include <setjmp.h>
 #include <alloca.h>
+#include <dprintf.h>
 
-#define DBG_PRINT(fmt, args...)        fprintf(stderr, "[EXEC] " fmt, ##args)
+#define DBG_PRINT(fmt, args...) dprintf("[EXEC] " fmt, ##args)
 
 static struct elf_module    *mod_root = NULL;
 struct elf_module *__syslinux_current = NULL;
@@ -232,13 +233,13 @@ int spawn_load(const char *name,const char **argv)
 
        int type;
 
-       mp("enter: name = %s", name);
+       dprintf("enter: name = %s", name);
 
        if (module == NULL)
                return -1;
 
        if (!strcmp(cur_module->name, module->name)) {
-               mp("We is running this module %s already!", module->name);
+               dprintf("We is running this module %s already!", module->name);
 
                /*
                 * If we're already running the module and it's of
@@ -266,7 +267,7 @@ int spawn_load(const char *name,const char **argv)
        prev_module = cur_module;
        cur_module = module;
 
-       mp("type = %d, prev = %s, cur = %s",
+       dprintf("type = %d, prev = %s, cur = %s",
                type, prev_module->name, cur_module->name);
 
        if(type==LIB_MODULE)
@@ -383,7 +384,7 @@ int module_load_dependencies(const char *name,const char *dep_file)
                        while (line[i] != '\n')
                                aux[j++] = line[i++];
                        aux[j] = '\0';
-                       //mp("found dependency: temp_name = %s, aux = %s, name = %s", temp_name, aux, name);
+                       //dprintf("found dependency: temp_name = %s, aux = %s, name = %s", temp_name, aux, name);
                        break;
                }
        }
@@ -394,7 +395,7 @@ int module_load_dependencies(const char *name,const char *dep_file)
        i = 0;
        while (aux[i]) {
                sscanf(aux + i, "%s", temp_name);
-               //mp("load module: %s", temp_name);
+               //dprintf("load module: %s", temp_name);
                i += strlen(temp_name);
                i++;    /* skip a space */
 
index 6410c7d..79dbc55 100644 (file)
@@ -13,6 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <dprintf.h>
 
 #include <com32.h>
 #include "core-elf.h"
@@ -71,7 +72,7 @@ void execute(const char *cmdline, enum kernel_type type)
 
        strcpy(q, p);
 
-       mp("kernel is %s, args = %s  type = %d \n", kernel, args, type);
+       dprintf("kernel is %s, args = %s  type = %d \n", kernel, args, type);
 
        if (kernel[0] == '.' && type == KT_NONE) {
                /* It might be a type specifier */
index d191e6e..6cb3363 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <console.h>
+#include <dprintf.h>
 #include <syslinux/loadfile.h>
 #include <syslinux/linux.h>
 #include <syslinux/pxe.h>
@@ -25,7 +26,7 @@ int new_linux_kernel(char *okernel, char *ocmdline)
        char cmdline_buf[256], *cmdline;
        int i;
 
-       mp("okernel = %s, ocmdline = %s", okernel, ocmdline);
+       dprintf("okernel = %s, ocmdline = %s", okernel, ocmdline);
 
        cmdline = cmdline_buf;
 
@@ -116,7 +117,7 @@ int new_linux_kernel(char *okernel, char *ocmdline)
                initramfs_load_archive(initramfs, initrd_name);
        }
 
-       //mp("loading initrd done");
+       //dprintf("loading initrd done");
 
        /* This should not return... */
        syslinux_boot_linux(kernel_data, kernel_len, initramfs, cmdline);
index bfc6430..4ee2541 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
+#include <dprintf.h>
 #include "malloc.h"
 
 #include <stdio.h>
@@ -18,7 +19,7 @@ int scan_highmem_area(void *data, addr_t start, addr_t len, bool is_ram)
        struct free_arena_header *fp;
        addr_t end;
 
-       mp("start = %x, len = %x, is_ram = %d", start, len, is_ram);
+       dprintf("start = %x, len = %x, is_ram = %d", start, len, is_ram);
 
        if (start < 0x100000 || start > E820_MEM_MAX
                             || !is_ram)
@@ -36,7 +37,7 @@ int scan_highmem_area(void *data, addr_t start, addr_t len, bool is_ram)
                fp = (struct free_arena_header *)start;
                fp->a.attrs = ARENA_TYPE_USED | (HEAP_MAIN << ARENA_HEAP_POS);
                ARENA_SIZE_SET(fp->a.attrs, len);
-               mp("will inject a block start:0x%x size 0x%x", start, len);
+               dprintf("will inject a block start:0x%x size 0x%x", start, len);
                __inject_free_block(fp);
        }
 
@@ -70,7 +71,7 @@ void mem_init(void)
        int i;
        uint16_t *bios_free_mem = (uint16_t *)0x413;
 
-       //mp("enter");
+       //dprintf("enter");
 
        /* Initialize the head nodes */
        fp = &__core_malloc_head[0];
@@ -81,7 +82,7 @@ void mem_init(void)
        fp++;
        }
        
-       //mp("__lowmem_heap = 0x%p bios_free = 0x%p",
+       //dprintf("__lowmem_heap = 0x%p bios_free = 0x%p",
        //      __lowmem_heap, *bios_free_mem);
        
        /* Initialize the lowmem heap */