Index: stand/common/bootstrap.h =================================================================== --- stand/common/bootstrap.h +++ stand/common/bootstrap.h @@ -124,6 +124,8 @@ bool cons_update_mode(bool); void autoload_font(bool); +extern int module_verbose; + /* * Plug-and-play enumerator/configurator interface. */ Index: stand/common/console.c =================================================================== --- stand/common/console.c +++ stand/common/console.c @@ -39,6 +39,7 @@ static int cons_find(const char *name); static int cons_check(const char *string); static int cons_change(const char *string); +static int module_verbose_set(struct env_var *ev, int flags, const void *value); static int twiddle_set(struct env_var *ev, int flags, const void *value); /* @@ -55,7 +56,9 @@ TSENTER(); - /* We want a callback to install the new value when this var changes. */ + /* We want a callback to install the new value when these vars change. */ + env_setenv("module_verbose", EV_VOLATILE, "1", module_verbose_set, + env_nounset); env_setenv("twiddle_divisor", EV_VOLATILE, "16", twiddle_set, env_nounset); @@ -318,3 +321,25 @@ return (CMD_OK); } + +#ifndef MODULE_VERBOSE +# define MODULE_VERBOSE 2 +#endif +int module_verbose = MODULE_VERBOSE; + +static int +module_verbose_set(struct env_var *ev, int flags, const void *value) +{ + u_long v; + char *eptr; + + v = strtoul(value, &eptr, 0); + if (*(const char *)value == 0 || *eptr != 0) { + printf("invalid module_verbose '%s'\n", (const char *)value); + return (CMD_ERROR); + } + module_verbose = v; + env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); + + return (CMD_OK); +} Index: stand/common/load_elf.c =================================================================== --- stand/common/load_elf.c +++ stand/common/load_elf.c @@ -463,13 +463,19 @@ else fp->f_type = strdup("elf multiboot kernel"); + if (module_verbose > 0) { #ifdef ELF_VERBOSE - if (ef.kernel) - printf("%s entry at 0x%jx\n", filename, - (uintmax_t)ehdr->e_entry); + if (ef.kernel) + printf("%s entry at 0x%jx\n", filename, + (uintmax_t)ehdr->e_entry); #else - printf("%s ", filename); + printf("%s ", filename); #endif + } + if (module_verbose < 2) { + /* A hack for now; we do not want twiddling */ + twiddle_divisor(UINT_MAX); + } fp->f_size = __elfN(loadimage)(fp, &ef, dest); if (fp->f_size == 0 || fp->f_addr == 0) @@ -581,7 +587,9 @@ } ehdr->e_entry += off; #ifdef ELF_VERBOSE - printf("Converted entry 0x%jx\n", (uintmax_t)ehdr->e_entry); + if (module_verbose > 0) + printf("Converted entry 0x%jx\n", + (uintmax_t)ehdr->e_entry); #endif #elif defined(__arm__) && !defined(EFI) /* @@ -605,8 +613,9 @@ off -= ehdr->e_entry & ~PAGE_MASK; ehdr->e_entry += off; #ifdef ELF_VERBOSE - printf("ehdr->e_entry 0x%jx, va<->pa off %llx\n", - (uintmax_t)ehdr->e_entry, off); + if (module_verbose > 0) + printf("ehdr->e_entry 0x%jx, va<->pa off %llx\n", + (uintmax_t)ehdr->e_entry, off); #endif #else off = 0; /* other archs use direct mapped kernels */ @@ -632,22 +641,24 @@ if (phdr[i].p_type != PT_LOAD) continue; + if (module_verbose > 0) { #ifdef ELF_VERBOSE - printf("Segment: 0x%lx@0x%lx -> 0x%lx-0x%lx", - (long)phdr[i].p_filesz, (long)phdr[i].p_offset, - (long)(phdr[i].p_vaddr + off), - (long)(phdr[i].p_vaddr + off + phdr[i].p_memsz - 1)); + printf("Segment: 0x%lx@0x%lx -> 0x%lx-0x%lx", + (long)phdr[i].p_filesz, (long)phdr[i].p_offset, + (long)(phdr[i].p_vaddr + off), + (long)(phdr[i].p_vaddr + off + phdr[i].p_memsz - 1)); #else - if ((phdr[i].p_flags & PF_W) == 0) { - printf("text=0x%lx ", (long)phdr[i].p_filesz); - } else { - printf("data=0x%lx", (long)phdr[i].p_filesz); - if (phdr[i].p_filesz < phdr[i].p_memsz) - printf("+0x%lx", (long)(phdr[i].p_memsz - - phdr[i].p_filesz)); - printf(" "); - } + if ((phdr[i].p_flags & PF_W) == 0) { + printf("text=0x%lx ", (long)phdr[i].p_filesz); + } else { + printf("data=0x%lx", (long)phdr[i].p_filesz); + if (phdr[i].p_filesz < phdr[i].p_memsz) + printf("+0x%lx", (long)(phdr[i].p_memsz - + phdr[i].p_filesz)); + printf(" "); + } #endif + } fpcopy = 0; if (ef->firstlen > phdr[i].p_offset) { fpcopy = ef->firstlen - phdr[i].p_offset; @@ -666,17 +677,19 @@ } /* clear space from oversized segments; eg: bss */ if (phdr[i].p_filesz < phdr[i].p_memsz) { + if (module_verbose > 0) { #ifdef ELF_VERBOSE - printf(" (bss: 0x%lx-0x%lx)", - (long)(phdr[i].p_vaddr + off + phdr[i].p_filesz), - (long)(phdr[i].p_vaddr + off + phdr[i].p_memsz -1)); + printf(" (bss: 0x%lx-0x%lx)", + (long)(phdr[i].p_vaddr + off + phdr[i].p_filesz), + (long)(phdr[i].p_vaddr + off + phdr[i].p_memsz -1)); #endif - + } kern_bzero(phdr[i].p_vaddr + off + phdr[i].p_filesz, phdr[i].p_memsz - phdr[i].p_filesz); } #ifdef ELF_VERBOSE - printf("\n"); + if (module_verbose > 0) + printf("\n"); #endif if (archsw.arch_loadseg != NULL) @@ -768,7 +781,8 @@ /* Ok, committed to a load. */ #ifndef ELF_VERBOSE - printf("syms=["); + if (module_verbose > 0) + printf("syms=["); #endif ssym = lastaddr; for (i = symtabindex; i >= 0; i = symstrindex) { @@ -792,17 +806,18 @@ archsw.arch_copyin(&size, lastaddr, sizeof(size)); lastaddr += sizeof(size); + if (module_verbose > 0) { #ifdef ELF_VERBOSE - printf("\n%s: 0x%jx@0x%jx -> 0x%jx-0x%jx", secname, - (uintmax_t)shdr[i].sh_size, (uintmax_t)shdr[i].sh_offset, - (uintmax_t)lastaddr, - (uintmax_t)(lastaddr + shdr[i].sh_size)); + printf("\n%s: 0x%jx@0x%jx -> 0x%jx-0x%jx", secname, + (uintmax_t)shdr[i].sh_size, (uintmax_t)shdr[i].sh_offset, + (uintmax_t)lastaddr, + (uintmax_t)(lastaddr + shdr[i].sh_size)); #else - if (i == symstrindex) - printf("+"); - printf("0x%lx+0x%lx", (long)sizeof(size), (long)size); + if (i == symstrindex) + printf("+"); + printf("0x%lx+0x%lx", (long)sizeof(size), (long)size); #endif - + } if (VECTX_LSEEK(VECTX_HANDLE(ef), (off_t)shdr[i].sh_offset, SEEK_SET) == -1) { printf("\nelf" __XSTRING(__ELF_WORD_SIZE) "_loadimage: could not seek for symbols - skipped!"); @@ -830,14 +845,16 @@ } esym = lastaddr; #ifndef ELF_VERBOSE - printf("]"); + if (module_verbose > 0) + printf("]"); #endif file_addmetadata(fp, MODINFOMD_SSYM, sizeof(ssym), &ssym); file_addmetadata(fp, MODINFOMD_ESYM, sizeof(esym), &esym); nosyms: - printf("\n"); + if (module_verbose > 0) + printf("\n"); ret = lastaddr - firstaddr; fp->f_addr = firstaddr; Index: stand/common/load_elf_obj.c =================================================================== --- stand/common/load_elf_obj.c +++ stand/common/load_elf_obj.c @@ -184,7 +184,8 @@ fp->f_name = strdup(filename); fp->f_type = strdup(__elfN(obj_moduletype)); - printf("%s ", filename); + if (module_verbose > 0) + printf("%s ", filename); fp->f_size = __elfN(obj_loadimage)(fp, &ef, dest); if (fp->f_size == 0 || fp->f_addr == 0) @@ -378,10 +379,12 @@ ret = lastaddr - firstaddr; fp->f_addr = firstaddr; - printf("size 0x%lx at 0x%lx", (u_long)ret, (u_long)firstaddr); + if (module_verbose > 0) + printf("size 0x%lx at 0x%lx", (u_long)ret, (u_long)firstaddr); out: - printf("\n"); + if (module_verbose > 0) + printf("\n"); return ret; }