All about programming in GNU/LINUX

Posts tagged “/var/syslog

Linux Device Drivers-1:Introduction to Device Drivers in Linux

The programs written for the LINUX kernel , that is the kernel programs cannot use headers and function from any library .they cannot make use C headers and their library functions.

Then the obvious question would be that which are  the HEADERS and FUNCTIONS does DEVICE DRIVER and KERNEL PROGRAMS in LINUX make use of??

Kernel programs and device drivers make use of headers which they obtain from the kernel source tree

issuing the command would get you into the path where these kernel headers reside

“cd /lib/modules/$(uname -r)/build/include/linux”
The kernel and device driver programs make use of these headers and functions within them .No External Libraries can be linked , not even C library or its headers found in /usr/include can be used to write device drivers or kernel programs.

After kernel programs or device drivers are written they are compiled and linked to the executable version of these files called as Kernel Modules with .ko extension.A Makefile is created for  these files which are to be compiled and linked.The ‘make’ program is made use of to achieve this purpose.

Later these kernel modules are loaded on top of the kernel dynamically using ‘insmod’ command .lsmod command gives you the list of all kernel modules on top of the kernel.Linux kernel is dynamic , addition and removal of kernel modules can done without the need for restarting the system .The running module can be removed by using ‘rmmod’ command.

By default all the kernel messages from printk function goes to /var/log/syslog file.This can viewed by using ‘dmesg’ command.
/proc/devices contain the list of all configured devices