Page MenuHomeFreeBSD

D34245.diff
No OneTemporary

D34245.diff

diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h
--- a/stand/common/bootstrap.h
+++ b/stand/common/bootstrap.h
@@ -124,6 +124,14 @@
bool cons_update_mode(bool);
void autoload_font(bool);
+extern int module_verbose;
+enum {
+ MODULE_VERBOSE_SILENT, /* say nothing */
+ MODULE_VERBOSE_SIZE, /* print name and size */
+ MODULE_VERBOSE_TWIDDLE, /* show progress */
+ MODULE_VERBOSE_FULL, /* all we have */
+};
+
/*
* Plug-and-play enumerator/configurator interface.
*/
diff --git a/stand/common/console.c b/stand/common/console.c
--- a/stand/common/console.c
+++ b/stand/common/console.c
@@ -41,6 +41,28 @@
static int cons_change(const char *string);
static int twiddle_set(struct env_var *ev, int flags, const void *value);
+#ifndef MODULE_VERBOSE
+# define MODULE_VERBOSE MODULE_VERBOSE_TWIDDLE
+#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 = (int)v;
+ env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
+
+ return (CMD_OK);
+}
+
/*
* Detect possible console(s) to use. If preferred console(s) have been
* specified, mark them as active. Else, mark the first probed console
@@ -52,10 +74,15 @@
int cons;
int active;
char *prefconsole;
+ char module_verbose_buf[8];
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. */
+ snprintf(module_verbose_buf, sizeof(module_verbose_buf), "%d",
+ module_verbose);
+ env_setenv("module_verbose", EV_VOLATILE, module_verbose_buf,
+ module_verbose_set, env_nounset);
env_setenv("twiddle_divisor", EV_VOLATILE, "16", twiddle_set,
env_nounset);
diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c
--- a/stand/common/load_elf.c
+++ b/stand/common/load_elf.c
@@ -463,13 +463,17 @@
else
fp->f_type = strdup("elf multiboot kernel");
-#ifdef ELF_VERBOSE
- if (ef.kernel)
- printf("%s entry at 0x%jx\n", filename,
- (uintmax_t)ehdr->e_entry);
-#else
- printf("%s ", filename);
-#endif
+ if (module_verbose >= MODULE_VERBOSE_FULL) {
+ if (ef.kernel)
+ printf("%s entry at 0x%jx\n", filename,
+ (uintmax_t)ehdr->e_entry);
+ } else if (module_verbose > MODULE_VERBOSE_SILENT)
+ printf("%s ", filename);
+
+ if (module_verbose < MODULE_VERBOSE_TWIDDLE) {
+ /* 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)
@@ -580,9 +584,10 @@
off += 0x01000000;
}
ehdr->e_entry += off;
-#ifdef ELF_VERBOSE
- printf("Converted entry 0x%jx\n", (uintmax_t)ehdr->e_entry);
-#endif
+ if (module_verbose >= MODULE_VERBOSE_FULL)
+ printf("Converted entry 0x%jx\n",
+ (uintmax_t)ehdr->e_entry);
+
#elif defined(__arm__) && !defined(EFI)
/*
* The elf headers in arm kernels specify virtual addresses in
@@ -604,10 +609,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);
-#endif
+ if (module_verbose >= MODULE_VERBOSE_FULL)
+ printf("ehdr->e_entry 0x%jx, va<->pa off %llx\n",
+ (uintmax_t)ehdr->e_entry, off);
#else
off = 0; /* other archs use direct mapped kernels */
#endif
@@ -632,22 +636,22 @@
if (phdr[i].p_type != PT_LOAD)
continue;
-#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));
-#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 (module_verbose >= MODULE_VERBOSE_FULL) {
+ 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 (module_verbose > MODULE_VERBOSE_SILENT) {
+ 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,18 +670,16 @@
}
/* clear space from oversized segments; eg: bss */
if (phdr[i].p_filesz < phdr[i].p_memsz) {
-#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));
-#endif
-
+ if (module_verbose >= MODULE_VERBOSE_FULL) {
+ 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));
+ }
kern_bzero(phdr[i].p_vaddr + off + phdr[i].p_filesz,
phdr[i].p_memsz - phdr[i].p_filesz);
}
-#ifdef ELF_VERBOSE
- printf("\n");
-#endif
+ if (module_verbose >= MODULE_VERBOSE_FULL)
+ printf("\n");
if (archsw.arch_loadseg != NULL)
archsw.arch_loadseg(ehdr, phdr + i, off);
@@ -767,12 +769,10 @@
goto nosyms;
/* Ok, committed to a load. */
-#ifndef ELF_VERBOSE
- printf("syms=[");
-#endif
+ if (module_verbose >= MODULE_VERBOSE_FULL)
+ printf("syms=[");
ssym = lastaddr;
for (i = symtabindex; i >= 0; i = symstrindex) {
-#ifdef ELF_VERBOSE
char *secname;
switch(shdr[i].sh_type) {
@@ -786,23 +786,21 @@
secname = "WHOA!!";
break;
}
-#endif
size = shdr[i].sh_size;
archsw.arch_copyin(&size, lastaddr, sizeof(size));
lastaddr += sizeof(size);
-#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));
-#else
- if (i == symstrindex)
- printf("+");
- printf("0x%lx+0x%lx", (long)sizeof(size), (long)size);
-#endif
-
+ if (module_verbose >= MODULE_VERBOSE_FULL) {
+ 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 (module_verbose > MODULE_VERBOSE_SILENT) {
+ if (i == symstrindex)
+ printf("+");
+ printf("0x%lx+0x%lx", (long)sizeof(size), (long)size);
+ }
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!");
@@ -829,15 +827,15 @@
symstrindex = -1;
}
esym = lastaddr;
-#ifndef ELF_VERBOSE
- printf("]");
-#endif
+ if (module_verbose >= MODULE_VERBOSE_FULL)
+ printf("]");
file_addmetadata(fp, MODINFOMD_SSYM, sizeof(ssym), &ssym);
file_addmetadata(fp, MODINFOMD_ESYM, sizeof(esym), &esym);
nosyms:
- printf("\n");
+ if (module_verbose > MODULE_VERBOSE_SILENT)
+ printf("\n");
ret = lastaddr - firstaddr;
fp->f_addr = firstaddr;
diff --git a/stand/common/load_elf_obj.c b/stand/common/load_elf_obj.c
--- a/stand/common/load_elf_obj.c
+++ b/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 > MODULE_VERBOSE_SILENT)
+ 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 > MODULE_VERBOSE_SILENT)
+ printf("size 0x%lx at 0x%lx", (u_long)ret, (u_long)firstaddr);
out:
- printf("\n");
+ if (module_verbose > MODULE_VERBOSE_SILENT)
+ printf("\n");
return ret;
}

File Metadata

Mime Type
text/plain
Expires
Wed, Feb 5, 8:44 AM (21 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16471057
Default Alt Text
D34245.diff (8 KB)

Event Timeline