use the verbose=2 boot monitor setting to get extensive output for debugging

This commit is contained in:
Erik van der Kouwe 2010-02-13 22:11:16 +00:00
parent df60646f98
commit ff835e0e35
6 changed files with 79 additions and 17 deletions

View file

@ -419,6 +419,11 @@ static void restore_screen(void)
}
}
#define DEBUGBASIC(params) do { \
if (verbose >= VERBOSEBOOT_BASIC) printf params; } while (0)
#define DEBUGMAX(params) do { \
if (verbose >= VERBOSEBOOT_MAX) printf params; } while (0)
void exec_image(char *image)
/* Get a Minix image into core, patch it up and execute. */
{
@ -435,13 +440,13 @@ void exec_image(char *image)
char params[SECTOR_SIZE];
extern char *sbrk(int);
char *verb;
int verbose = 0;
int verbose = VERBOSEBOOT_QUIET;
/* The stack is pretty deep here, so check if heap and stack collide. */
(void) sbrk(0);
if ((verb= b_value("verbose")) != nil && a2l(verb) > 0)
verbose = 1;
if ((verb= b_value(VERBOSEBOOTVARNAME)) != nil)
verbose = a2l(verb);
printf("\nLoading ");
pretty_image(image);
@ -471,6 +476,7 @@ void exec_image(char *image)
procp= &process[i];
/* Read header. */
DEBUGMAX(("Reading header... "));
for (;;) {
if ((buf= get_sector(vsec++)) == nil) return;
@ -484,6 +490,7 @@ void exec_image(char *image)
/* Bad label, skip this process. */
vsec+= proc_size(&hdr);
}
DEBUGMAX(("done\n"));
/* Sanity check: an 8086 can't run a 386 kernel. */
if (hdr.process.a_cpu == A_I80386 && processor < 386) {
@ -502,13 +509,16 @@ void exec_image(char *image)
/* Save a copy of the header for the kernel, with a_syms
* misused as the address where the process is loaded at.
*/
DEBUGMAX(("raw_copy(0x%x, 0x%x, 0x%x)... ",
aout + i * A_MINHDR, mon2abs(&hdr.process), A_MINHDR));
hdr.process.a_syms= addr;
raw_copy(aout + i * A_MINHDR, mon2abs(&hdr.process), A_MINHDR);
DEBUGMAX(("done\n"));
if (!banner && verbose) {
printf(" cs ds text data bss");
if (k_flags & K_CHMEM) printf(" stack");
putch('\n');
if (!banner) {
DEBUGBASIC((" cs ds text data bss"));
if (k_flags & K_CHMEM) DEBUGBASIC((" stack"));
DEBUGBASIC(("\n"));
banner= 1;
}
@ -536,7 +546,11 @@ void exec_image(char *image)
/* Separate I&D: two segments. Common I&D: only one. */
if (hdr.process.a_flags & A_SEP) {
/* Read the text segment. */
DEBUGMAX(("get_segment(0x%x, &a_text, 0x%x, 0x%x)... ",
vsec, addr, limit));
if (!get_segment(&vsec, &a_text, &addr, limit)) return;
DEBUGMAX(("vsec=0x%x a_text=0x%x addr=0x%x\n",
vsec, a_text, addr));
/* The data segment follows. */
procp->ds= addr;
@ -550,19 +564,19 @@ void exec_image(char *image)
}
/* Read the data segment. */
DEBUGMAX(("get_segment(0x%x, &a_data, 0x%x, 0x%x)... ",
vsec, addr, limit));
if (!get_segment(&vsec, &a_data, &addr, limit)) return;
DEBUGMAX(("vsec=0x%x a_data=0x%x addr=0x%x\n",
vsec, a_data, addr));
/* Make space for bss and stack unless... */
if (i != KERNEL_IDX && (k_flags & K_CLAIM)) a_bss= a_stack= 0;
if(verbose) {
printf("%07lx %07lx %8ld %8ld %8ld",
procp->cs, procp->ds,
hdr.process.a_text, hdr.process.a_data,
hdr.process.a_bss
);
}
if ((k_flags & K_CHMEM) && verbose) printf(" %8ld", a_stack);
DEBUGBASIC(("%07lx %07lx %8ld %8ld %8ld",
procp->cs, procp->ds, hdr.process.a_text,
hdr.process.a_data, hdr.process.a_bss));
if (k_flags & K_CHMEM) DEBUGBASIC((" %8ld", a_stack));
/* Note that a_data may be negative now, but we can look at it
* as -a_data bss bytes.
@ -575,7 +589,9 @@ void exec_image(char *image)
/* Zero out bss. */
if (addr + n > limit) { errno= ENOMEM; return; }
DEBUGMAX(("\nraw_clear(0x%x, 0x%x)... ", addr, n));
raw_clear(addr, n);
DEBUGMAX(("done\n"));
addr+= n;
/* And the number of stack clicks. */
@ -589,7 +605,7 @@ void exec_image(char *image)
/* Process endpoint. */
procp->end= addr;
if(verbose)
if (verbose >= VERBOSEBOOT_BASIC)
printf(" %s\n", hdr.name);
else {
u32_t mem;
@ -605,7 +621,7 @@ void exec_image(char *image)
}
}
if(!verbose)
if (verbose < VERBOSEBOOT_BASIC)
printf("(%dk)\n", totalmem/1024);
if ((n_procs= i) == 0) {
@ -622,7 +638,9 @@ void exec_image(char *image)
}
/* Patch sizes, etc. into kernel data. */
DEBUGMAX(("patch_sizes()... "));
patch_sizes();
DEBUGMAX(("done\n"));
#if !DOS
if (!(k_flags & K_MEML)) {
@ -632,22 +650,33 @@ void exec_image(char *image)
#endif
/* Run the trailer function just before starting Minix. */
DEBUGMAX(("run_trailer()... "));
if (!run_trailer()) { errno= 0; return; }
DEBUGMAX(("done\n"));
/* Translate the boot parameters to what Minix likes best. */
DEBUGMAX(("params2params(0x%x, 0x%x)... ", params, sizeof(params)));
if (!params2params(params, sizeof(params))) { errno= 0; return; }
DEBUGMAX(("done\n"));
/* Set the video to the required mode. */
if ((console= b_value("console")) == nil || (mode= a2x(console)) == 0) {
mode= strcmp(b_value("chrome"), "color") == 0 ? COLOR_MODE :
MONO_MODE;
}
DEBUGMAX(("set_mode(%d)... ", mode));
set_mode(mode);
DEBUGMAX(("done\n"));
/* Close the disk. */
DEBUGMAX(("dev_close()... "));
(void) dev_close();
DEBUGMAX(("done\n"));
/* Minix. */
DEBUGMAX(("minix(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x)\n",
process[KERNEL_IDX].entry, process[KERNEL_IDX].cs,
process[KERNEL_IDX].ds, params, sizeof(params), aout));
minix(process[KERNEL_IDX].entry, process[KERNEL_IDX].cs,
process[KERNEL_IDX].ds, params, sizeof(params), aout);

View file

@ -146,3 +146,9 @@
#define CHECK_IO_PORT 0x20 /* check if I/O request is allowed */
#define CHECK_IRQ 0x40 /* check if IRQ can be used */
#define CHECK_MEM 0x80 /* check if (VM) mem map request is allowed */
/* Values for the "verbose" boot monitor variable */
#define VERBOSEBOOT_QUIET 0
#define VERBOSEBOOT_BASIC 1
#define VERBOSEBOOT_MAX 2
#define VERBOSEBOOTVARNAME "verbose"

View file

@ -82,4 +82,11 @@
#define BOOT_VERBOSE(x)
#endif
#ifdef _SYSTEM
#define DEBUG_PRINT(params, level) do { \
if (verboseboot >= (level)) kprintf params; } while (0)
#define DEBUGBASIC(params) DEBUG_PRINT(params, VERBOSEBOOT_BASIC)
#define DEBUGMAX(params) DEBUG_PRINT(params, VERBOSEBOOT_MAX)
#endif
#endif /* DEBUG_H */

View file

@ -47,6 +47,7 @@ EXTERN int minix_panicing;
EXTERN int locklevel;
EXTERN char fpu_presence;
EXTERN char osfxsr_feature; /* FXSAVE/FXRSTOR instructions support (SSEx) */
EXTERN int verboseboot; /* verbose boot, init'ed in cstart */
#define MAGICTEST 0xC0FFEE23
EXTERN u32_t magictest; /* global magic number */

View file

@ -40,6 +40,8 @@ PUBLIC void main()
/* Global value to test segment sanity. */
magictest = MAGICTEST;
DEBUGMAX(("main()\n"));
/* Clear the process table. Anounce each slot as empty and set up mappings
* for proc_addr() and proc_nr() macros. Do the same for the table with
* privilege structures for the system processes.
@ -75,6 +77,7 @@ PUBLIC void main()
int ipc_to_m, kcalls;
ip = &image[i]; /* process' attributes */
DEBUGMAX(("initializing %s... ", ip->proc_name));
rp = proc_addr(ip->proc_nr); /* get process pointer */
ip->endpoint = rp->p_endpoint; /* ipc endpoint */
rp->p_max_priority = ip->priority; /* max scheduling priority */
@ -203,15 +206,22 @@ PUBLIC void main()
if (rp->p_nr < 0) RTS_SET(rp, RTS_PROC_STOP);
RTS_UNSET(rp, RTS_SLOT_FREE); /* remove RTS_SLOT_FREE and schedule */
alloc_segments(rp);
DEBUGMAX(("done\n"));
}
/* Architecture-dependent initialization. */
DEBUGMAX(("arch_init()... "));
arch_init();
DEBUGMAX(("done\n"));
/* System and processes initialization */
DEBUGMAX(("system_init()... "));
system_init();
DEBUGMAX(("done\n"));
/* Initialize timers handling */
DEBUGMAX(("clock_init()... "));
clock_init();
DEBUGMAX(("done\n"));
#if SPROFILE
sprofiling = 0; /* we're not profiling until instructed to */
@ -251,7 +261,9 @@ PUBLIC void main()
FIXME("PROC check enabled");
#endif
DEBUGMAX(("cycles_accounting_init()... "));
cycles_accounting_init();
DEBUGMAX(("done\n"));
restart();
NOT_REACHABLE;

View file

@ -39,6 +39,12 @@ U16_t parmoff, parmsize; /* boot parameters offset and length */
/* Copy the boot parameters to the local buffer. */
arch_get_params(params_buffer, sizeof(params_buffer));
/* determine verbosity */
if ((value = get_value(params_buffer, VERBOSEBOOTVARNAME)))
verboseboot = atoi(value);
DEBUGMAX(("cstart\n"));
/* Record miscellaneous information for user-space servers. */
kinfo.nr_procs = NR_PROCS;
kinfo.nr_tasks = NR_TASKS;
@ -97,6 +103,7 @@ U16_t parmoff, parmsize; /* boot parameters offset and length */
* reload selectors and call main().
*/
DEBUGMAX(("intr_init(%d, 0)\n", INTS_MINIX));
intr_init(INTS_MINIX, 0);
}