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 12:44 PM, Michael <macallan%netbsd.org@localhost> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
>
> On May 21, 2009, at 9:24 AM, 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.
>
> You use CFATTACH_DECL_NEW yet all your device methods use struct device *
> and there's a struct device in your softc. CFATTACH_DECL_NEW is for devices
> that split device and softc and use device_t instead. So, you panic because
> your code assumes that device and softc are the same thing but in reality
> you have only a device_t, try to access the softc fields behind it and
> segfault. To get your softc you need to call device_private() and store it
> in your softc for future reference.
>


Thanks, I was wondering why some devices had CFATTACH_DECL_NEW and
others can softc.  (fyi I was still panicing without the
CFATTACH_DECL_NEW, but I'll give it another try)


Home | Main Index | Thread Index | Old Index