For your first question, I assume that you want to build your driver statically into the kernel image(not as a module). First, you select a directory in drivers directory where you want to put your driver files. Assume you want to put your files in drivers/char/
. Copy your files into this directory. There will be a Kconfig
file in the drivers/char/
directory, open it and add an entry like this in the before the endmenu
.
config MYDRIVER
bool "This is a driver for something"
default n
help
This is a test driver.
Save the file and open Makefile
in the same directory. Goto end of the file and add the following entry.
obj-$(CONFIG_MYDRIVER) += mydriver.o
That's it you have added the file to the kernel tree. Now, as usual, do make menuconfig
and select MYDRIVER
.
See this Kernel Compilation article for more info.