Successfully reported this slideshow.
Your SlideShare is downloading. ×

Introduction to Linux Kernel Module

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Linux dma engine
Linux dma engine
Loading in …3
×

Check these out next

1 of 11 Ad

More Related Content

Recently uploaded (20)

Advertisement

Introduction to Linux Kernel Module

  1. 1. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Introduction to Linux Kernel Module
  2. 2. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved What to Expect ● What is Linux Driver? ● Linux Driver Ecosystem ● Linux Kernel Source organization ● Linux Kernel Module ● Writing a Linux Driver
  3. 3. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved What is Driver? ● Piece of software which drives, operates, monitors, controls – Another piece of software – The device ● Need for the driver – Abstraction
  4. 4. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Linux Driver Ecosystem
  5. 5. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Linux Source Organization /usr/src/linux/ net drivers block fs mm init arch/<arch> char mtd/ide net pci ... usb serial include asm-<arch> linux kernel ipc lib scripts tools scripts crypto firmware security sound ...
  6. 6. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved ● Hot plug and play driver ● Can be loaded/unloaded dynamically ● Need for LKM – Expedites the development cycle – Provides Modularity ● Standard module path – /lib/modules/<kernel version>/ Linux Kernel Module
  7. 7. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Module related commands ● Located under /sbin & require the root previliges ● lsmod – Listing the module – $ lsmod ● insmod – Loading the module – $ insmod <module file>.ko ● rmmod – Unloading the module – $ rmmod <module name>
  8. 8. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Writing a Linux Driver ● Prerequisites – Kernel’s C ● C without standard user space libs & headers – Kernel Source code ● For headers & libs ● Libraries for commonly used funcations at <kernel_src>/libs ● Kernel programming constructs at <kernel_src>/kernel – Kernel build system for building the driver
  9. 9. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved static int __init driver_init(void) { ... return 0; } module_init(driver_init); Module Initialization
  10. 10. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Module Deinitialization static void __exit driver_exit(void) { ... } module_exit(driver_exit);
  11. 11. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved What all did we learn? ● What is Linux Driver? ● Linux Driver Ecosystem ● Linux Kernel Source organization ● Linux Kernel Module ● Writing a Linux Driver

×