help with coding a loadable kernel module

Warner Losh imp at bsdimp.com
Fri Apr 17 14:14:16 UTC 2015


> On Apr 17, 2015, at 8:08 AM, Daniel Braniss <danny at cs.huji.ac.il> wrote:
> 
>> 
>> On Apr 17, 2015, at 4:42 PM, Warner Losh <imp at bsdimp.com> wrote:
>> 
>>> 
>>> On Apr 17, 2015, at 7:26 AM, Daniel Braniss <danny at cs.huji.ac.il> wrote:
>>> 
>>>> 
>>>> On Apr 17, 2015, at 4:13 PM, Ian Lepore <ian at freebsd.org> wrote:
>>>> 
>>>> On Fri, 2015-04-17 at 13:46 +0300, Daniel Braniss wrote:
>>>>>> On Apr 17, 2015, at 12:55 PM, Tom Jones <jones at sdf.org> wrote:
>>>>>> 
>>>>>> On Fri, Apr 17, 2015 at 12:15:33PM +0300, Daniel Braniss wrote:
>>>>>>> 
>>>>>>>> On Apr 17, 2015, at 11:08 AM, Kurt Jaeger <lists at opsec.eu> wrote:
>>>>>>>> 
>>>>>>>> Hi!
>>>>>>>> 
>>>>>>>>> I know I'm embarking on a dangerous trip, but I want to use a Raspberry Pi
>>>>>>>>> and or a BeagleBone to read (and write) RFID cards.
>>>>>>>>> Since a driver is needed to use the spibus, I have 2 options while
>>>>>>>>> developing:
>>>>>>>> [...]
>>>>>>>>> So before I give up on option 2, is there some examples/help?
>>>>>>>> 
>>>>>>>> Are you aware of this book ?
>>>>>>>> 
>>>>>>>> http://www.nostarch.com/bsddrivers.htm <http://www.nostarch.com/bsddrivers.htm>
>>>>>>> 
>>>>>>> no, but before I spend more money (this is getting expensive :-),
>>>>>>> does it explain how to write a loadable module that needs to to talk
>>>>>>> to a spibus?
>>>>>> 
>>>>>> I don't think it does.
>>>>>> 
>>>>>> spibus is very simple, there is one interface call
>>>>>> 
>>>>>> SPIBUS_TRANSFER(device_t, device_t, strcut spi_command);
>>>>>> 
>>>>> 
>>>>> chicken and egg issue :-), what device_t dev should I use?
>>>>> it must point to the spibus …
>>>> 
>>>> Your device will be a child of the spibus, and it is the bus that
>>> 
>>> it’s the ‘child of’ that I have problems. this will be a loadable module, so
>>> it will have to tell the parent that he is no longer an orphan :-)
>> 
>> When you declare the module, one of the parameters are what bus to
>> attach to.
>> 
>> If you are using FDT in your system, then you’ll put your device into the
>> FDT tree below the spibus to create the device_t node in the tree. When
>> your module is loaded, its probe routine will be called, and you can
>> match based on the compatible string given in the FDT.
>> 
> 
> I was afraid of that :-), this FDT stuff is new to me, and so far I was successful
> in adding a gpio/led, but grep has not found any spibus.
> any chance for a small template/example ? rpi or bbb would help!

I’m afraid I don’t have one handy.

Warner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-arm/attachments/20150417/7b3c4f46/attachment.sig>


More information about the freebsd-arm mailing list