Coder Social home page Coder Social logo

lkm-sandbox's Introduction

lkm-sandbox

Loadable kernel modules sandbox used to learn about LKMs.

Prerequisities

Install kernel headers for your kernel version if they are missing in /usr/src/

sudo apt-get install linux-headers-$(uname -r)

If gcc is not installed

sudo apt install gcc

If make is not installed

sudo apt install make

Usage

cd to each module directory and run make

To clean output files use make clean

To load module into the kernel use sudo make load

To unload module from the kernel use sudo make unload

Good method to observe kernel log in real time is following:

dmesg -wH

List of modules

  • 00_basic_module
    • initialization of basic module
    • usage of printk function
  • 01_basic_tasklet
  • 02_basic_sleep
    • usage of workqueue
    • schedulink works and delayed works
    • one callback for both types of work
    • msleep used for delay in callback
    • developed way to distinguish which type of work started callback
    • added counting semaphore to clean module when no callbacks are active
  • 03_basic_timers
    • improved kernel timer api [8]
    • regular and high resolution timer configuration with callbacks
  • 04_basic_char
  • 05_char_ioctl
  • 06_char_sysfs
  • 07_timers_conf
    • improved kernel timer api [8]

Sources

[1] Linux Device Drivers, Third Edition, O’Reilly

[2] Linux Device Drivers Development, John Madieu

[3] Writing a Linux Kernel Module by Derek Molloy: Part 1 and Part 2

[4] Linux Driver Tutorial: How to Write a Simple Linux Device Driver

[5] The Linux Kernel Module Programming Guide by Peter Jay Salzman and Ori Pomeranz

[6] Device Drivers, Part 4: Linux Character Drivers, Open Source For You

[7] LINUX KERNEL DEVELOPMENT – CREATING A PROC FILE AND INTERFACING WITH USER SPACE

[8] Improving the kernel timers API

Tips

  • Add linux kernel include folders to Visual Studio Code. Paste following into c_cpp_properties.json file in section includePath. Adjust your kernel version.
"${workspaceFolder}/**",
"/usr/src/linux-headers-5.0.0-29-generic/*",
"/usr/src/linux-headers-5.0.0-29-generic/include/*",
"/usr/src/linux-headers-5.0.0-29-generic/include/linux/*",
"/usr/src/linux-headers-5.0.0-29-generic/include/asm-generic/*"

lkm-sandbox's People

Contributors

ozetroc avatar

Stargazers

0x777 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.