Kernel development, Writing kernel modules, What is a kernel module – Digi 9P 9360/9750 User Manual

Page 39: Writing your own kernel modules, Add your source files, Chapter 6 kernel development

Advertising
background image

3 9

K e r n e l D e v e l o p m e n t

Kernel Development

C

H

A

P

T

E

R

6

Writing kernel modules

What is a kernel module?

Modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They are useful
because they extend the functionality of the kernel without the need to reboot the system.

A typical kernel module is the device driver, which allows the kernel to access hardware connected to the
system. Without modules, you would have to build substantial kernels and add new functionality directly
into the kernel image. Besides having extensive kernels, you would be required to rebuild and reboot the
kernel for every new functionality.

Writing your own kernel modules

Some kernel modules are included as examples. They can be found in the modules/ subdirectory of the
project folder. Each kernel module must be stored in a different folder.

The easiest way to create your own kernel module is to clone one of the existing modules:

Add your source files

Add the sources for your kernel module directly to the new folder you’ve just created, and remove the
original source files of the folder that you cloned.

~/LxNETES3.2$ cd modules

~/LxNETES3.2/modules$ cp -r minimal my_kmodule

~/LxNETES3.2/modules$ cd my_kmodule

Advertising