Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 May 2002 16:25:07 -0400
From:      Jake Burkholder <jake@locore.ca>
To:        Terry Lambert <tlambert2@mindspring.com>
Cc:        Dmitry Mottl <dima@sinp.msu.ru>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: question: hacking init_main.c
Message-ID:  <20020512162506.I2566@locore.ca>
In-Reply-To: <3CDEB3C5.7D08D187@mindspring.com>; from tlambert2@mindspring.com on Sun, May 12, 2002 at 11:26:13AM -0700
References:  <Pine.BSF.4.43.0205121758360.38560-100000@BigKing.sinp.msu.ru> <3CDEB3C5.7D08D187@mindspring.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Apparently, On Sun, May 12, 2002 at 11:26:13AM -0700,
	Terry Lambert said words to the effect of;

> Dmitry Mottl wrote:
> > 
> > I got a page fault (page not present, supervisor read) when I try to
> > modify /sys/kern/init_main.c
> > 
> > I want kernel print each subsytem name when it called from mi_startup.
> > So I define char *sysinit_desct[] array and populate it with
> > description strings.
> > 
> > After I boot kernel I saw expected '*** mi_startup ***' (see patch)
> > and pagefault after that.
> > 
> > Where is my fault?
> 
> [ ... ]
> > +        printf("*** mi_startup ***\n");
> *** BOGUS
> 
> [ ... ]
> > +               printf("SYSINIT: %s\n", sysinit_descr[(*sipp)->subsystem]);
> *** BOGUS
> 
> Your console must be initialized before you can call printf.
> 
> Try this *one line* instead:
> 
> 201a202,204
> > if ((*sipp)->subsystem > SI_SUB_CONSOLE)
> >       printf("SYSINIT: %s\n", sysinit_descr[(*sipp)->subsystem]);
> > 
> 
> Notice that with this patch, it only does printf's after console
> initialization has taken place (unlike your patch).

Wrong, no cookie.  kernel printf uses the low level console which is
initialized by cninit, which is called from init386 (etc), before
mi_startup.

My best guess at what's happening is that the subsystem numbers are
"sparse", and have high numerical values, so you can't really index
an array with them.  ie you're trying to print sysinit_descr[0x1000000]
etc.  The best way I've found to do what you want is to use
linker_ddb_search_symbol and linker_ddb_symbol_values on the sysinit
function pointer to find its name, and to print the numerical value
of the order/subsystem.

T TERRY PLZ TO BE RESEARCHING NEXT TIME LUV JAKE

Jake

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020512162506.I2566>