Source tree driver question

I am having a hard time figuring out where in the source tree the driver source would belong.

My device is a driver for external GPIO pins to be named sch311x_gpio for a SMSC SCH3114.

I see the following relevant spots:

/usr/src/sys/dev/sms (exists with an LAN driver >my device manufacturer SMSC=SMS)

/usr/src/sys/i386/i386/ (Gonzo's diff patch uses this directory)

/usr/src/sys/dev/gpio(seems to be spot for gpio_if.m, gpiobus.c and system gpio stuff)

Where would the makefile go?

This book seems good for my file creation but I lack knowledge of correct locations.
https://www.freebsd.org/doc/en/books/arch-handbook/pci.html

Next hurdle after that is where to have it included in my kernel? If used dynamically do I have to recompile kernel or just 'make' my driver and
kldload sch311x_gpio?
Thanks in Advance
 
I suppose I could 'make' my module anywhere that can find the #include files and copy the sch311x_gpio.ko to the boot/modules folder by hand and load.

I am wondering about the proper way.

I note the book above uses kldload -v ./skeleton.ko, So does that mean module in root dir? I dunno what ./ does here?
 
Because of the way the system make(1) is configured you can build the sources in any directory you want including /root or a subdirectory of it. The magic incantation is the .include <bsd.kmod.mk> which includes a whole bunch of rules that do the correct invocations for the build tools.
 
Made my first module (outside of usbdevs/u3g.c PID fixup) with minimal effort. Time to test it out.
Thanks for everyones help.
 
I note the book above uses kldload -v ./skeleton.ko, So does that mean module in root dir? I dunno what ./ does here?

./ is the directory you currently are (in your shell). It's just a safeguard in case several files with the same name are in your path. You may use the pwd(1) command any time to find out where you are.

PS: Had it been April 1st, I would have laughed so hard at you.

Dominique.
 
Back
Top