tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kernel panic with new pseudo device



On Thu, May 21, 2009 at 09:24:31AM -0400, matthew sporleder wrote:
> Hi, I'm trying to write a pseudo device with an envsys component.  I
> mostly followed http://www.netbsd.org/docs/kernel/pseudo/ and got a
> working device, but now I get a panic when I attempt to do:
> sc->sc_sme = sysmon_envsys_create();
> 
> My best guess is that I didn't get any memory allocated for my _softc
> structure, but I'm not really sure how to validate that.
> 
> A rough cut of my code is here:
> http://mspo.com/code/screenblankenv.c.txt
> 
> Can anyone offer some hints?  I'm a little stuck.

autoconf(9) can be confusing at times.  And the fact that the example
code is wrong doesn't help.

If you read http://www.netbsd.org/docs/kernel/pseudo/#functions, you'll
notice that the <pseudo>attach function only takes one argument, which
is an int (the number given in the config file, which defaults to 1).

There is no softc involved for pseudo-devices (although if you use
defpseudodev to declare it, you get the possibility to make that happen,
but even then there is more work to do;  it doesn't seem to me this is
what you want though).

So because <pseudo>attach is called with no device context, you have to
do all memory allocations by yourself.  I'll fix the example.

-- 
Quentin Garnier - cube%cubidou.net@localhost - cube%NetBSD.org@localhost
"See the look on my face from staying too long in one place
[...] every time the morning breaks I know I'm closer to falling"
KT Tunstall, Saving My Face, Drastic Fantastic, 2007.

Attachment: pgpzW77RQVpnK.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index