summaryrefslogtreecommitdiffstats
path: root/sys/kern/init_main.c
diff options
context:
space:
mode:
authorbenno <benno@FreeBSD.org>2006-05-12 02:01:38 +0000
committerbenno <benno@FreeBSD.org>2006-05-12 02:01:38 +0000
commited056cb6c7f4ae79404c66f2dd822e4687301e86 (patch)
tree6de1b7e8074fa81d29bd7f57261d9e2dedf3cb88 /sys/kern/init_main.c
parent7c592195ba609d3a95049d69931a8c5f5ac601ba (diff)
downloadFreeBSD-src-ed056cb6c7f4ae79404c66f2dd822e4687301e86.zip
FreeBSD-src-ed056cb6c7f4ae79404c66f2dd822e4687301e86.tar.gz
Add a new kernel config option, VERBOSE_SYSINIT.
When porting FreeBSD to a new platform, one of the more useful things to do is get mi_startup() to let you know which SYSINIT it's up to. Most people tend to whack a printf in the SYSINIT loop to print the address of the function it's about to call. Going one better, jhb made a version that uses DDB to look up the name of the function and print that instead. This version is essentially his with the addition of some ifdeffery to make it optional and to allow it to work (although using only the function address, not the symbol) if you forgot to enable DDB. All the cool bits by: jhb Approved by: scottl, rink, cognet, imp
Diffstat (limited to 'sys/kern/init_main.c')
-rw-r--r--sys/kern/init_main.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index e2ec53f..32f421b 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -84,6 +84,9 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_map.h>
#include <sys/copyright.h>
+#include <ddb/ddb.h>
+#include <ddb/db_sym.h>
+
void mi_startup(void); /* Should be elsewhere */
/* Components of the first process -- never freed. */
@@ -169,6 +172,11 @@ mi_startup(void)
register struct sysinit **xipp; /* interior loop of sort*/
register struct sysinit *save; /* bubble*/
+#if defined(VERBOSE_SYSINIT)
+ int last;
+ int verbose;
+#endif
+
if (sysinit == NULL) {
sysinit = SET_BEGIN(sysinit_set);
sysinit_end = SET_LIMIT(sysinit_set);
@@ -191,6 +199,14 @@ restart:
}
}
+#if defined(VERBOSE_SYSINIT)
+ last = SI_SUB_COPYRIGHT;
+ verbose = 0;
+#if !defined(DDB)
+ printf("VERBOSE_SYSINIT: DDB not enabled, symbol lookups disabled.\n");
+#endif
+#endif
+
/*
* Traverse the (now) ordered list of system initialization tasks.
* Perform each task, and continue on to the next task.
@@ -206,9 +222,38 @@ restart:
if ((*sipp)->subsystem == SI_SUB_DONE)
continue;
+#if defined(VERBOSE_SYSINIT)
+ if ((*sipp)->subsystem > last) {
+ verbose = 1;
+ last = (*sipp)->subsystem;
+ printf("subsystem %x\n", last);
+ }
+ if (verbose) {
+#if defined(DDB)
+ const char *name;
+ c_db_sym_t sym;
+ db_expr_t offset;
+
+ sym = db_search_symbol((vm_offset_t)(*sipp)->func,
+ DB_STGY_PROC, &offset);
+ db_symbol_values(sym, &name, NULL);
+ if (name != NULL)
+ printf(" %s(%p)... ", name, (*sipp)->udata);
+ else
+#endif
+ printf(" %p(%p)... ", (*sipp)->func,
+ (*sipp)->udata);
+ }
+#endif
+
/* Call function */
(*((*sipp)->func))((*sipp)->udata);
+#if defined(VERBOSE_SYSINIT)
+ if (verbose)
+ printf("done.\n");
+#endif
+
/* Check off the one we're just done */
(*sipp)->subsystem = SI_SUB_DONE;
OpenPOWER on IntegriCloud