Posts

Showing posts from December, 2015

Basic Steps to registering character device driver

Basic Steps to registering character device driver 1) Create the object of structure named as dev_t which contains two things as major number and minor number. 2) Call function alloc_chardev_region() which is use to create device file by allocating major number and minor number implicitely. 3) If we call this function then there is no need to create device file explicitely. 4) At the time of removing device driver we have to call unregister_chardev_region() function. 5) Compile that driver and insert into kernel using insmod command. 6) We can check the list of devices which are loaded currently by the kernel by opening the file /proc/devices. 7) Major number and minor number gets display in our log file as /var/log/syslog. ------------------------------------------------------------------------- ///////////////////////////////////////////////////////////////// Device Driver Program: ///////////////////////////////////////////////////////////////// Program Name...

KERNEL MODULE PROGRAMS

KERNEL MODULE PROGRAMS ///////////////////////////////////////////////////////////////// Program No. : 1 ----------------------------------------------------------------------- // hello-1.c ----------------------------------------------------------------------- // This header file is require for all kernel module. #include<linux/module.h> // This header file is require for KERN_INFO macro. #include<linux/kernel.h> // This function gets called automatically when module gets loaded by insmod command // This function returns 0 if it successfully executed otherwise it returns non zero value int init_module(void) { printk(KERN_INFO "Jay ShreeKrishna: module inserted 1\n"); return 0; } // This function gets called automatically when module gets removed from memory by rmmod. void cleanup_module(void) { printk(KERN_INFO "Hare Ram: module removed 1\n"); } ----------------------------------------------------------------------- // ...

Library Development in Linux

1) Library is a set of functions which are used by another executable files. 2) Library are consider as dependable executable, which is not directly run because we have to need some executable files for linking purpose. 3) According to the linking there are two types of library:-    i)  Static link library.    ii) Dynamic link library.   -------------------------------------------------------------------------------------------------------------------------- 1) Static Link Library in Linux:-     i) This type of library gets link to executable at compile time.       ii) Contents of this library are attach with the executable file permanently due to which a size of              executable file get increase permanently.       iii) In case of static library same library can be loaded multiple times in memory due to which           ...