SlideShare a Scribd company logo
1 of 52
Download to read offline
Linux Kernel Modules
Let’s solve the puzzle
Dheryta Jaisinghani
Workshop on Computer Systems, Ashoka University
Dec 9, 2018
(Note: Most of the codes in the slides are from references in the end)
Basics of Operating
Systems
From user space to kernel space
Basic Operating System Structure
Hardware
Kernel
User Services
User Applications
& Processes
System Call
Interface
● What is an operating system?
○ An operating system is system software
that manages computer hardware and
software resources and provides
common services for computer
programs. [Wikipedia]
● What is Kernel?
○ Core of the operating system
○ Loads at startup and takes care of
everything else -
resources/memory/scheduling and many
more
○ Types: Monolithic, Microkernel, Modular,
Nano, Exo 3
What is a Kernel Module?
● Piece of code - Runtime Load/Unload
● Examples - Device Drivers - printer
driver, WLAN driver, vbox driver and
many more
● Actual kernel image is small - Modules
make it big
○ Monolithic kernels would have
been huge
User-level
Programs
System Call Interface
Kernel Services
Device Modules and Drivers
Physical Devices
User space
Kernel space
4
Module vs Program
● Program
○ main() - sequentially executes instructions and terminates
● Kernel Modules
○ init_module() or module_init() - Entry function
■ Initial setup to tell kernel about this module
■ Kernel executes it when needed
○ cleanup_module() or module_exit - Exit function
■ Unregister the module
5
Example 1
(user space to kernel
space)
User Space (Library Functions) → Kernel Space (System
Calls)
#include <stdio.h>
int main(void)
{
printf("hello");
return 0;
}
SystemCalls
7
Example 2
My First Kernel
Module
Example 2.1 from Ref [1]
Prepare the system
● Update the system
○ sudo apt-get update
● Search appropriate headers
○ apt-cache search linux-headers-$(uname -r)
● Download and install correct Linux headers
○ sudo apt-get install linux-headers-$(uname -r)
● Check if installed correctly
○ cd /usr/src/linux-headers-$(uname -r)
○ ls - should show the header files
● Follow steps under Prepare the System for Building LKMs, presented here
(http://derekmolloy.ie/writing-a-linux-kernel-module-part-1-introduction/)
9
Hello World Kernel Module
#include <linux/module.h>
#include <linux/kernel.h>
DRIVER_AUTHOR "Dheryta Jaisinghani"
DRIVER_DESC "A Hello World kernel module."
MODULE_LICENSE("GPL");
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
int init_module(void)
{
printk(KERN_INFO "Hello Worldn");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye Worldn");
}
10
Header files to make it a kernel module
and log levels
Module Information
Load the module
0 - Success, Else - Failure
Unload the module
Example 3
Different Log Levels
printk
● Log at kernel
● 8 priority levels (See: include/linux/kern_levels.h)
○ KERN_EMERG 0 system is unusable
○ KERN_ALERT 1 action must be taken immediately
○ KERN_CRIT 2 critical conditions
○ KERN_ERR 3 error conditions
○ KERN_WARNING 4 warning conditions
○ KERN_NOTICE 5 normal but significant condition
○ KERN_INFO 6 informational
○ KERN_DEBUG 7 debug-level messages
12
Module Makefile
obj−m += hello.o
all:
make −C /lib/modules/$(shell uname −r)/build M=$(PWD) modules
clean:
make −C /lib/modules/$(shell uname −r)/build M=$(PWD) clean
13
Multiple modules can be built with single makefile. Refer to
Section 2.2 in The Linux Kernel Module Programming Guide
Example 4
Extracting info about
modules
All about modules
● lsmod - Show all loaded modules
○ lsmod
● insmod - Insert a Module (excludes dependencies)
○ sudo insmod <module_name>
● modprobe - Insert a Module (includes dependencies)
○ sudo modprobe <module_name>
● modinfo - Show information about a module
○ modinfo <module_name.ko>
● depmod - Build module dependency database
○ /lib/modules/$(uname -r)/modules.dep
● rmmod - Remove a module
○ rmmod <module_name.ko>
● Show the log
○ dmesg or cat /var/log/syslog
15
Example 5
Moving away from
default init and exit
Example 2.3 from Ref [1]
Not Using Default init and cleanup
#include <linux/module.h>
#include <linux/kernel.h>
DRIVER_AUTHOR "Dheryta Jaisinghani"
DRIVER_DESC "A Hello World kernel module."
MODULE_LICENSE("GPL");
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
static int __init myInit(void)
{
printk(KERN_INFO "Hello Worldn");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
static void __exit myExit(void)
{
printk(KERN_INFO "Goodbye Worldn");
}
module_init(myInit);
module_exit(myExit);
17
● __init and __exit are Macros
● Kernel can free memory
when initialization or module
unloading is done
Example 6
Variables in Kernel
Modules
Example 2.5 from Ref [1]
Declaring init variables in kernel
modules#include <linux/module.h>
#include <linux/kernel.h>
DRIVER_AUTHOR "Dheryta Jaisinghani"
DRIVER_DESC "A Hello World kernel module."
MODULE_LICENSE("GPL");
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
static int myData __initdata = 3;
static int __init myInit(void)
{
printk(KERN_INFO "Hello World, My Data %dn", myData);
return 0;}
static void __exit myExit(void)
{
printk(KERN_INFO "Goodbye Worldn");
}
module_init(myInit);
module_exit(myExit); 19
● Static init variable
● __initdata is a macro
● Notice the change from standard
c program
Example 7
Arguments in Kernel
Modules
Example 2.7 from Ref [1]
Passing command line arguments
21
Conventional argc and argv[] does not work with kernel modules
● Register Parameters
○ //Name, Type, Permission bits
○ module_param(myDataInt, int, 0000);
○ MODULE_PARM_DESC(myDataInt, "An
Integer");
○ module_param(myDataStr, charp, 0000);
○ MODULE_PARM_DESC(myDataStr, "A String");
○ //Name, Type, Pointer to variable to array length,
Permission bits
○ module_param_array(myDataArr, int,
&myDataArrCount, 0000);
○ MODULE_PARM_DESC(myDataArr, "An Array");
● Declare static variables
○ static int myDataInt = 1;
○ static char *myDataStr = "WoCS";
○ static int myDataArr[4] = {0,0,0,0};
○ static int myDataArrCount = 0;
Passing command line arguments
$ sudo insmod helloworld-command_line_args.ko myDataStr="Dheryta"
myDataArrCount=3 myDataInt=10 myDataArr=1,2,3
[23492.223323] Hello World
******
[23492.223327] myDataInt is an integer: 10
[23492.223329] myDataStr is a string: Dheryta
[23492.223331] myDataArr[0] = 1
[23492.223332] myDataArr[1] = 2
[23492.223334] myDataArr[2] = 3
[23492.223336] got 3 arguments for myDataArrCount.
22
Device Drivers
Device Drivers vs Device Files
● Everything is a file or a directory
● Every device is represented by a file in /dev/
● Device Driver: Kernel Module that controls a device
● Device File:
○ Interface for the Device Driver to read from or
write to a physical device
○ Also known as Device Nodes
○ Created with mknod system call [ex. mknod
<c/b> <major> <minor>]
Device File
(/dev/xxx)
Device Driver
Physical Device
User space
Kernel space
24
Example 8
Device Files
Types of Device Files
● Character Files
○ Stream of data one character at a time
○ No restriction on number of bytes
● Block Files
○ Random access to block of data
○ Can buffer and schedule the requests
$ ls -a /dev/
$crw-rw---- 1 root dialout 4, 64 Nov 30 09:51 ttyS0
$brw-rw---- 1 root dialout 4, 64 Nov 30 09:52 sdd
26
Major and Minor Device Number
root@iiitd-HP-Compaq-8200-Elite-MT-PC:/home/iiitd# ls -l /dev/sda*
brw-rw---- 1 root disk 8, 0 Dec 3 11:48 /dev/sda
brw-rw---- 1 root disk 8, 1 Dec 3 11:48 /dev/sda1
brw-rw---- 1 root disk 8, 2 Dec 3 11:48 /dev/sda2
brw-rw---- 1 root disk 8, 3 Dec 3 11:48 /dev/sda3
● Major Number
○ The driver for the hardware
○ Unique for each driver
● Minor Number
○ The number of unique hardware a driver manages
27
Example 9
Some Fun with Device
Files
Writing to/Read from device file
$cat /usr/share/sounds/ubuntu/notifications/Amsterdam.ogg > /dev/audio
$cat /dev/urandom | padsp tee /dev/audio > /dev/null
$echo “Hello World” > /dev/tty1
$cat /dev/psaux
29
Example 10
System Runtime
Information
Getting Runtime Information of System
● proc file system
○ Reports runtime information about various resources
○ Memory usage/hardware/modules loaded and many more
● Try
○ ls /proc/ (Numbered directories correspond to processes!)
○ cat /proc/devices
○ cat /proc/modules
○ cat /proc/cpuinfo
○ cat /proc/meminfo
● More Details: http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html
31
Example 11
My First Character
Device Driver
Example 4.1 from Ref [1]
Developing a Character Device Driver
Device Driver → Kernel Module Device File → /dev/<filename>
Register the device -
● register_chrdev
● mknod
● struct file_operations
Do the operations -
read/write/open/close
Unregister the device -
● unregister_chrdev
Try Example - chardev.c
33
● Try_module_get
● module_put
Example 12
Dancing Lights with
Keyboard
Example 10.2 from Ref [1]
Interacting with External Devices
● printk does not always help
● Device specific commands should be known
● Interfacing with Keyboard
○ Periodic Lighting Keyboard - Example 10.2 from Ref[1]
○ Dancing Lights Keyboard - Modify Example 10.2 (see help on next slide)
35
Dancing Lights with Keyboard
● Define 3 Macros
○ #define ONE_LEDS_ON 0x04
○ #define TWO_LEDS_ON 0x06
○ #define THREE_LEDS_ON 0x07
36
● Modify my_timer_func
static void my_timer_func(unsigned long ptr)
{
int *pstatus = (int *)ptr;
if (*pstatus == RESTORE_LEDS)
*pstatus = ONE_LEDS_ON;
else if (*pstatus == ONE_LEDS_ON)
*pstatus = TWO_LEDS_ON;
else if (*pstatus == TWO_LEDS_ON)
*pstatus = THREE_LEDS_ON;
else
*pstatus = RESTORE_LEDS;
(my_driver->ops->ioctl) (vc_cons[fg_console].d->port.tty, KDSETLED,
*pstatus);
(my_driver->ops->ioctl) (vc_cons[fg_console].d->port.tty, KIOCSOUND,
CLOCK_TICK_RATE/DEFAULT_FREQ);
my_timer.expires = jiffies + BLINK_DELAY;
add_timer(&my_timer);
}
Interrupt Handlers
37
Processor Hardware
Instructions
How? → Interrupts
Received an interrupt
Pause current work.
Save the state (How?)
Address the interrupt
with Interrupt Handler
Resume the work
request_irq() → Create entry in /proc/interrupts
request_irq() → Create entry in /proc/interrupts
Example 13
Interrupt Handling
Refer Example 7.1 for chardev.c and Ref [8] for interrupts
Raise and Capture Interrupt on a
Character Device
● chardev.c
● Raise the interrupt whenever file is read [asm instruction]
● Capture the interrupt
● Tell user that the interrupt is captured
39
Example 14
Practice with IOCTL
(Do it on your own)
Ref [7]
Interacting with Physical Devices
Kernel Modules
41
/proc/ file system
/dev/ file system
Device read/write
IOCTLs
System Calls
Interrupt Handlers
Use Existing or Write Your Own Custom Calls
Shell Scripts
What and Why of Shell Scripts
● Shell is an interface to allow the use of operating system services
● All commands are executed in a shell through a terminal
● Bash shell is the most common shell
● Shell scripts allow to
○ Automate the execution of repetitive shell commands
○ Routine procedures such as backups
○ System monitoring
43
Shell Script Structure
● Every shell script starts with a shell name like → # !/bin/bash
● As per convention, a shell script file extension is .sh
● A shell script should be made executable with chmod command
● A shell script can have constructs such as for, while, if-elseif-else, switch
● A shell script can read/write from files
● A shell script can call another program may it be a python or C or any other
● In summary - shell scripts are very powerful
44
Few Interesting
Examples
Control CD Drive
#!/bin/bash
while :
do
eject
eject -t
done
Ref:https://www.quora.com/What-is-the-most-interesting-shell-script-you-have-ever-written
46
GRE Prep
1. sudo apt-get install cowsay
2. Prepare a dictionary
a. Apple == red fruit
b. LadyFinger == green vegetable
c. Clock == A device to show time
d. English == It is a language
3. In .bashrc → shuf -n 1 MyDictionary.txt | cowsay
Ref:https://www.quora.com/What-is-the-most-interesting-shell-script-you-have-ever-
written 47
System Health
● Use standard commands to summarize all vitals
48
Ref: https://www.tecmint.com/linux-server-health-monitoring-script/
Conclusion
● Kernel Modules: An introduction
● Hello world modules: Creating, Compiling, Inserting, Initialization and Passing
variables
● Proc, Device file system
● Device drivers, files
● Interaction with devices
● Interrupt handling
● Shell Scripts
49
Linux WiFi Subsytem
● Tutorial: Opening Nuts and Bolts of Linux WiFi Subsytem
● Slides:
https://www.slideshare.net/DherytaJaisinghani/tutorial-wifi-driver-code-opening
-nuts-and-bolts-of-linux-wifi-subsystem
● Video: https://www.youtube.com/watch?v=pa1oEyc7Dm0
50
Contact
● Web: www.dheryta.co.in
● Email: dherytaj@iiitd.ac.in
51
References
1. https://www.tldp.org/LDP/lkmpg/2.6/lkmpg.pdf
2. http://derekmolloy.ie/writing-a-linux-kernel-module-part-1-introduction/
3. http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
4. https://elinux.org/Debugging_by_printing
5. ftp://ftp.lpp.polytechnique.fr/jeandet/keep/sync/LINUX/interrupt/t3.pdf
6. http://lwn.net/Kernel/LDD3/
7. https://embetronicx.com/tutorials/linux/device-drivers/ioctl-tutorial-in-linux/
8. https://embetronicx.com/tutorials/linux/device-drivers/linux-device-driver-tutori
al-part-13-interrupt-example-program-in-linux-kernel/
9. http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html
10. https://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/dev.html
11. https://01.org/linuxgraphics/gfx-docs/drm/driver-api/index.html
52

More Related Content

What's hot

Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequenceHoucheng Lin
 
Launch the First Process in Linux System
Launch the First Process in Linux SystemLaunch the First Process in Linux System
Launch the First Process in Linux SystemJian-Hong Pan
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot) Omkar Rane
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal BootloaderSatpal Parmar
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013Wave Digitech
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device driversHoucheng Lin
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecturehugo lu
 
linux device driver
linux device driverlinux device driver
linux device driverRahul Batra
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_BootingRashila Rr
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driverVandana Salve
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoCMacpaul Lin
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New HardwareRuggedBoardGroup
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)shimosawa
 
A Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry PiA Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry PiJian-Hong Pan
 
Kernel module programming
Kernel module programmingKernel module programming
Kernel module programmingVandana Salve
 

What's hot (20)

Embedded linux network device driver development
Embedded linux network device driver developmentEmbedded linux network device driver development
Embedded linux network device driver development
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
 
Launch the First Process in Linux System
Launch the First Process in Linux SystemLaunch the First Process in Linux System
Launch the First Process in Linux System
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot)
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
 
Network Drivers
Network DriversNetwork Drivers
Network Drivers
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
 
Kernel module in linux os.
Kernel module in linux os.Kernel module in linux os.
Kernel module in linux os.
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driver
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
A Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry PiA Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry Pi
 
Kernel module programming
Kernel module programmingKernel module programming
Kernel module programming
 
Linux Device Driver’s
Linux Device Driver’sLinux Device Driver’s
Linux Device Driver’s
 
Linux-Internals-and-Networking
Linux-Internals-and-NetworkingLinux-Internals-and-Networking
Linux-Internals-and-Networking
 

Similar to Linux kernel modules

Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxRajKumar Rampelli
 
Introduction to containers
Introduction to containersIntroduction to containers
Introduction to containersNitish Jadia
 
Basis Linux (aan de hand van LPIC-1)
Basis Linux (aan de hand van LPIC-1)Basis Linux (aan de hand van LPIC-1)
Basis Linux (aan de hand van LPIC-1)Peter Martin
 
Docker 原理與實作
Docker 原理與實作Docker 原理與實作
Docker 原理與實作kao kuo-tung
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel DevelopmentPriyank Kapadia
 
Zephyr RTOS in One Hour | HARDWARIO @ IoT North UK
Zephyr RTOS in One Hour | HARDWARIO @ IoT North UKZephyr RTOS in One Hour | HARDWARIO @ IoT North UK
Zephyr RTOS in One Hour | HARDWARIO @ IoT North UKHARDWARIO
 
Linux device driver
Linux device driverLinux device driver
Linux device driverchatsiri
 
Lec 10-linux-review
Lec 10-linux-reviewLec 10-linux-review
Lec 10-linux-reviewabinaya m
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device driversAlexandre Moreno
 
How Secure Is Your Container? ContainerCon Berlin 2016
How Secure Is Your Container? ContainerCon Berlin 2016How Secure Is Your Container? ContainerCon Berlin 2016
How Secure Is Your Container? ContainerCon Berlin 2016Phil Estes
 
Evolution of Linux Containerization
Evolution of Linux Containerization Evolution of Linux Containerization
Evolution of Linux Containerization WSO2
 
Evoluation of Linux Container Virtualization
Evoluation of Linux Container VirtualizationEvoluation of Linux Container Virtualization
Evoluation of Linux Container VirtualizationImesh Gunaratne
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux DevelopersOpersys inc.
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embeddedAlison Chaiken
 
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011camp_drupal_ua
 
Automotive Grade Linux and systemd
Automotive Grade Linux and systemdAutomotive Grade Linux and systemd
Automotive Grade Linux and systemdAlison Chaiken
 

Similar to Linux kernel modules (20)

Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linux
 
An Introduction To Linux
An Introduction To LinuxAn Introduction To Linux
An Introduction To Linux
 
Introduction to containers
Introduction to containersIntroduction to containers
Introduction to containers
 
Basis Linux (aan de hand van LPIC-1)
Basis Linux (aan de hand van LPIC-1)Basis Linux (aan de hand van LPIC-1)
Basis Linux (aan de hand van LPIC-1)
 
Docker 原理與實作
Docker 原理與實作Docker 原理與實作
Docker 原理與實作
 
Linux Kernel Debugging
Linux Kernel DebuggingLinux Kernel Debugging
Linux Kernel Debugging
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
 
Zephyr RTOS in One Hour | HARDWARIO @ IoT North UK
Zephyr RTOS in One Hour | HARDWARIO @ IoT North UKZephyr RTOS in One Hour | HARDWARIO @ IoT North UK
Zephyr RTOS in One Hour | HARDWARIO @ IoT North UK
 
Linux device driver
Linux device driverLinux device driver
Linux device driver
 
Lec 10-linux-review
Lec 10-linux-reviewLec 10-linux-review
Lec 10-linux-review
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
 
How Secure Is Your Container? ContainerCon Berlin 2016
How Secure Is Your Container? ContainerCon Berlin 2016How Secure Is Your Container? ContainerCon Berlin 2016
How Secure Is Your Container? ContainerCon Berlin 2016
 
Evolution of Linux Containerization
Evolution of Linux Containerization Evolution of Linux Containerization
Evolution of Linux Containerization
 
Evoluation of Linux Container Virtualization
Evoluation of Linux Container VirtualizationEvoluation of Linux Container Virtualization
Evoluation of Linux Container Virtualization
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embedded
 
Device drivers tsp
Device drivers tspDevice drivers tsp
Device drivers tsp
 
Driver_linux
Driver_linuxDriver_linux
Driver_linux
 
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
 
Automotive Grade Linux and systemd
Automotive Grade Linux and systemdAutomotive Grade Linux and systemd
Automotive Grade Linux and systemd
 

Recently uploaded

ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 

Recently uploaded (20)

ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 

Linux kernel modules

  • 1. Linux Kernel Modules Let’s solve the puzzle Dheryta Jaisinghani Workshop on Computer Systems, Ashoka University Dec 9, 2018 (Note: Most of the codes in the slides are from references in the end)
  • 2. Basics of Operating Systems From user space to kernel space
  • 3. Basic Operating System Structure Hardware Kernel User Services User Applications & Processes System Call Interface ● What is an operating system? ○ An operating system is system software that manages computer hardware and software resources and provides common services for computer programs. [Wikipedia] ● What is Kernel? ○ Core of the operating system ○ Loads at startup and takes care of everything else - resources/memory/scheduling and many more ○ Types: Monolithic, Microkernel, Modular, Nano, Exo 3
  • 4. What is a Kernel Module? ● Piece of code - Runtime Load/Unload ● Examples - Device Drivers - printer driver, WLAN driver, vbox driver and many more ● Actual kernel image is small - Modules make it big ○ Monolithic kernels would have been huge User-level Programs System Call Interface Kernel Services Device Modules and Drivers Physical Devices User space Kernel space 4
  • 5. Module vs Program ● Program ○ main() - sequentially executes instructions and terminates ● Kernel Modules ○ init_module() or module_init() - Entry function ■ Initial setup to tell kernel about this module ■ Kernel executes it when needed ○ cleanup_module() or module_exit - Exit function ■ Unregister the module 5
  • 6. Example 1 (user space to kernel space)
  • 7. User Space (Library Functions) → Kernel Space (System Calls) #include <stdio.h> int main(void) { printf("hello"); return 0; } SystemCalls 7
  • 8. Example 2 My First Kernel Module Example 2.1 from Ref [1]
  • 9. Prepare the system ● Update the system ○ sudo apt-get update ● Search appropriate headers ○ apt-cache search linux-headers-$(uname -r) ● Download and install correct Linux headers ○ sudo apt-get install linux-headers-$(uname -r) ● Check if installed correctly ○ cd /usr/src/linux-headers-$(uname -r) ○ ls - should show the header files ● Follow steps under Prepare the System for Building LKMs, presented here (http://derekmolloy.ie/writing-a-linux-kernel-module-part-1-introduction/) 9
  • 10. Hello World Kernel Module #include <linux/module.h> #include <linux/kernel.h> DRIVER_AUTHOR "Dheryta Jaisinghani" DRIVER_DESC "A Hello World kernel module." MODULE_LICENSE("GPL"); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); int init_module(void) { printk(KERN_INFO "Hello Worldn"); return 0; } void cleanup_module(void) { printk(KERN_INFO "Goodbye Worldn"); } 10 Header files to make it a kernel module and log levels Module Information Load the module 0 - Success, Else - Failure Unload the module
  • 12. printk ● Log at kernel ● 8 priority levels (See: include/linux/kern_levels.h) ○ KERN_EMERG 0 system is unusable ○ KERN_ALERT 1 action must be taken immediately ○ KERN_CRIT 2 critical conditions ○ KERN_ERR 3 error conditions ○ KERN_WARNING 4 warning conditions ○ KERN_NOTICE 5 normal but significant condition ○ KERN_INFO 6 informational ○ KERN_DEBUG 7 debug-level messages 12
  • 13. Module Makefile obj−m += hello.o all: make −C /lib/modules/$(shell uname −r)/build M=$(PWD) modules clean: make −C /lib/modules/$(shell uname −r)/build M=$(PWD) clean 13 Multiple modules can be built with single makefile. Refer to Section 2.2 in The Linux Kernel Module Programming Guide
  • 14. Example 4 Extracting info about modules
  • 15. All about modules ● lsmod - Show all loaded modules ○ lsmod ● insmod - Insert a Module (excludes dependencies) ○ sudo insmod <module_name> ● modprobe - Insert a Module (includes dependencies) ○ sudo modprobe <module_name> ● modinfo - Show information about a module ○ modinfo <module_name.ko> ● depmod - Build module dependency database ○ /lib/modules/$(uname -r)/modules.dep ● rmmod - Remove a module ○ rmmod <module_name.ko> ● Show the log ○ dmesg or cat /var/log/syslog 15
  • 16. Example 5 Moving away from default init and exit Example 2.3 from Ref [1]
  • 17. Not Using Default init and cleanup #include <linux/module.h> #include <linux/kernel.h> DRIVER_AUTHOR "Dheryta Jaisinghani" DRIVER_DESC "A Hello World kernel module." MODULE_LICENSE("GPL"); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); static int __init myInit(void) { printk(KERN_INFO "Hello Worldn"); /* * A non 0 return means init_module failed; module can't be loaded. */ return 0; } static void __exit myExit(void) { printk(KERN_INFO "Goodbye Worldn"); } module_init(myInit); module_exit(myExit); 17 ● __init and __exit are Macros ● Kernel can free memory when initialization or module unloading is done
  • 18. Example 6 Variables in Kernel Modules Example 2.5 from Ref [1]
  • 19. Declaring init variables in kernel modules#include <linux/module.h> #include <linux/kernel.h> DRIVER_AUTHOR "Dheryta Jaisinghani" DRIVER_DESC "A Hello World kernel module." MODULE_LICENSE("GPL"); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); static int myData __initdata = 3; static int __init myInit(void) { printk(KERN_INFO "Hello World, My Data %dn", myData); return 0;} static void __exit myExit(void) { printk(KERN_INFO "Goodbye Worldn"); } module_init(myInit); module_exit(myExit); 19 ● Static init variable ● __initdata is a macro ● Notice the change from standard c program
  • 20. Example 7 Arguments in Kernel Modules Example 2.7 from Ref [1]
  • 21. Passing command line arguments 21 Conventional argc and argv[] does not work with kernel modules ● Register Parameters ○ //Name, Type, Permission bits ○ module_param(myDataInt, int, 0000); ○ MODULE_PARM_DESC(myDataInt, "An Integer"); ○ module_param(myDataStr, charp, 0000); ○ MODULE_PARM_DESC(myDataStr, "A String"); ○ //Name, Type, Pointer to variable to array length, Permission bits ○ module_param_array(myDataArr, int, &myDataArrCount, 0000); ○ MODULE_PARM_DESC(myDataArr, "An Array"); ● Declare static variables ○ static int myDataInt = 1; ○ static char *myDataStr = "WoCS"; ○ static int myDataArr[4] = {0,0,0,0}; ○ static int myDataArrCount = 0;
  • 22. Passing command line arguments $ sudo insmod helloworld-command_line_args.ko myDataStr="Dheryta" myDataArrCount=3 myDataInt=10 myDataArr=1,2,3 [23492.223323] Hello World ****** [23492.223327] myDataInt is an integer: 10 [23492.223329] myDataStr is a string: Dheryta [23492.223331] myDataArr[0] = 1 [23492.223332] myDataArr[1] = 2 [23492.223334] myDataArr[2] = 3 [23492.223336] got 3 arguments for myDataArrCount. 22
  • 24. Device Drivers vs Device Files ● Everything is a file or a directory ● Every device is represented by a file in /dev/ ● Device Driver: Kernel Module that controls a device ● Device File: ○ Interface for the Device Driver to read from or write to a physical device ○ Also known as Device Nodes ○ Created with mknod system call [ex. mknod <c/b> <major> <minor>] Device File (/dev/xxx) Device Driver Physical Device User space Kernel space 24
  • 26. Types of Device Files ● Character Files ○ Stream of data one character at a time ○ No restriction on number of bytes ● Block Files ○ Random access to block of data ○ Can buffer and schedule the requests $ ls -a /dev/ $crw-rw---- 1 root dialout 4, 64 Nov 30 09:51 ttyS0 $brw-rw---- 1 root dialout 4, 64 Nov 30 09:52 sdd 26
  • 27. Major and Minor Device Number root@iiitd-HP-Compaq-8200-Elite-MT-PC:/home/iiitd# ls -l /dev/sda* brw-rw---- 1 root disk 8, 0 Dec 3 11:48 /dev/sda brw-rw---- 1 root disk 8, 1 Dec 3 11:48 /dev/sda1 brw-rw---- 1 root disk 8, 2 Dec 3 11:48 /dev/sda2 brw-rw---- 1 root disk 8, 3 Dec 3 11:48 /dev/sda3 ● Major Number ○ The driver for the hardware ○ Unique for each driver ● Minor Number ○ The number of unique hardware a driver manages 27
  • 28. Example 9 Some Fun with Device Files
  • 29. Writing to/Read from device file $cat /usr/share/sounds/ubuntu/notifications/Amsterdam.ogg > /dev/audio $cat /dev/urandom | padsp tee /dev/audio > /dev/null $echo “Hello World” > /dev/tty1 $cat /dev/psaux 29
  • 31. Getting Runtime Information of System ● proc file system ○ Reports runtime information about various resources ○ Memory usage/hardware/modules loaded and many more ● Try ○ ls /proc/ (Numbered directories correspond to processes!) ○ cat /proc/devices ○ cat /proc/modules ○ cat /proc/cpuinfo ○ cat /proc/meminfo ● More Details: http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html 31
  • 32. Example 11 My First Character Device Driver Example 4.1 from Ref [1]
  • 33. Developing a Character Device Driver Device Driver → Kernel Module Device File → /dev/<filename> Register the device - ● register_chrdev ● mknod ● struct file_operations Do the operations - read/write/open/close Unregister the device - ● unregister_chrdev Try Example - chardev.c 33 ● Try_module_get ● module_put
  • 34. Example 12 Dancing Lights with Keyboard Example 10.2 from Ref [1]
  • 35. Interacting with External Devices ● printk does not always help ● Device specific commands should be known ● Interfacing with Keyboard ○ Periodic Lighting Keyboard - Example 10.2 from Ref[1] ○ Dancing Lights Keyboard - Modify Example 10.2 (see help on next slide) 35
  • 36. Dancing Lights with Keyboard ● Define 3 Macros ○ #define ONE_LEDS_ON 0x04 ○ #define TWO_LEDS_ON 0x06 ○ #define THREE_LEDS_ON 0x07 36 ● Modify my_timer_func static void my_timer_func(unsigned long ptr) { int *pstatus = (int *)ptr; if (*pstatus == RESTORE_LEDS) *pstatus = ONE_LEDS_ON; else if (*pstatus == ONE_LEDS_ON) *pstatus = TWO_LEDS_ON; else if (*pstatus == TWO_LEDS_ON) *pstatus = THREE_LEDS_ON; else *pstatus = RESTORE_LEDS; (my_driver->ops->ioctl) (vc_cons[fg_console].d->port.tty, KDSETLED, *pstatus); (my_driver->ops->ioctl) (vc_cons[fg_console].d->port.tty, KIOCSOUND, CLOCK_TICK_RATE/DEFAULT_FREQ); my_timer.expires = jiffies + BLINK_DELAY; add_timer(&my_timer); }
  • 37. Interrupt Handlers 37 Processor Hardware Instructions How? → Interrupts Received an interrupt Pause current work. Save the state (How?) Address the interrupt with Interrupt Handler Resume the work request_irq() → Create entry in /proc/interrupts request_irq() → Create entry in /proc/interrupts
  • 38. Example 13 Interrupt Handling Refer Example 7.1 for chardev.c and Ref [8] for interrupts
  • 39. Raise and Capture Interrupt on a Character Device ● chardev.c ● Raise the interrupt whenever file is read [asm instruction] ● Capture the interrupt ● Tell user that the interrupt is captured 39
  • 40. Example 14 Practice with IOCTL (Do it on your own) Ref [7]
  • 41. Interacting with Physical Devices Kernel Modules 41 /proc/ file system /dev/ file system Device read/write IOCTLs System Calls Interrupt Handlers Use Existing or Write Your Own Custom Calls
  • 43. What and Why of Shell Scripts ● Shell is an interface to allow the use of operating system services ● All commands are executed in a shell through a terminal ● Bash shell is the most common shell ● Shell scripts allow to ○ Automate the execution of repetitive shell commands ○ Routine procedures such as backups ○ System monitoring 43
  • 44. Shell Script Structure ● Every shell script starts with a shell name like → # !/bin/bash ● As per convention, a shell script file extension is .sh ● A shell script should be made executable with chmod command ● A shell script can have constructs such as for, while, if-elseif-else, switch ● A shell script can read/write from files ● A shell script can call another program may it be a python or C or any other ● In summary - shell scripts are very powerful 44
  • 46. Control CD Drive #!/bin/bash while : do eject eject -t done Ref:https://www.quora.com/What-is-the-most-interesting-shell-script-you-have-ever-written 46
  • 47. GRE Prep 1. sudo apt-get install cowsay 2. Prepare a dictionary a. Apple == red fruit b. LadyFinger == green vegetable c. Clock == A device to show time d. English == It is a language 3. In .bashrc → shuf -n 1 MyDictionary.txt | cowsay Ref:https://www.quora.com/What-is-the-most-interesting-shell-script-you-have-ever- written 47
  • 48. System Health ● Use standard commands to summarize all vitals 48 Ref: https://www.tecmint.com/linux-server-health-monitoring-script/
  • 49. Conclusion ● Kernel Modules: An introduction ● Hello world modules: Creating, Compiling, Inserting, Initialization and Passing variables ● Proc, Device file system ● Device drivers, files ● Interaction with devices ● Interrupt handling ● Shell Scripts 49
  • 50. Linux WiFi Subsytem ● Tutorial: Opening Nuts and Bolts of Linux WiFi Subsytem ● Slides: https://www.slideshare.net/DherytaJaisinghani/tutorial-wifi-driver-code-opening -nuts-and-bolts-of-linux-wifi-subsystem ● Video: https://www.youtube.com/watch?v=pa1oEyc7Dm0 50
  • 51. Contact ● Web: www.dheryta.co.in ● Email: dherytaj@iiitd.ac.in 51
  • 52. References 1. https://www.tldp.org/LDP/lkmpg/2.6/lkmpg.pdf 2. http://derekmolloy.ie/writing-a-linux-kernel-module-part-1-introduction/ 3. http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/ 4. https://elinux.org/Debugging_by_printing 5. ftp://ftp.lpp.polytechnique.fr/jeandet/keep/sync/LINUX/interrupt/t3.pdf 6. http://lwn.net/Kernel/LDD3/ 7. https://embetronicx.com/tutorials/linux/device-drivers/ioctl-tutorial-in-linux/ 8. https://embetronicx.com/tutorials/linux/device-drivers/linux-device-driver-tutori al-part-13-interrupt-example-program-in-linux-kernel/ 9. http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html 10. https://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/dev.html 11. https://01.org/linuxgraphics/gfx-docs/drm/driver-api/index.html 52