Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Outline
Concept
Kernel Module
Char Device Driver
Interrupt Handling
I/O Management
Allocating Memory
Block Device Driver
Network Device Driver
Concept
The role of device driver
C programming
Microprocessor programming
Important concepts
Concept (Cont.)
Execution paths: From user to kernel
Concept (Cont.)
Classes of devices
Characters devices
Block devices
Network interfaces
Concept (Cont.)
A device driver is a kernel
module.
A kernel module is a device
driver? Not necessarily so.
Example: ext3 file system module
Outline
Concept
Kernel Module
Character Device Driver
Interrupt Handling
I/O Management
Allocating Memory
Block Device Driver
Network Device Driver
Kernel Module
The first kernel module Hello, world
#include <linux/init.h>
#include <linux/module.h>
static int hello_init(void)
{
printk(KERN_ALERT Hello, world\n);
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT Goodbye, cruel world\n);
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE(GPL);
Kernel Module
Priority
Low
Outline
Concept
Kernel Module
Char Device Driver
Interrupt Handling
I/O Management
Allocating Memory
Block Device Driver
Network Device Driver
Device type
-l
root
root
root
root
root
root
root
root
root
root
disk
disk
disk
14, 12 12
10, 175 12
14,
4 12
60 12
5,
1 12
120 12
14,
3 12
13, 64 12
1,
7 12
0 12
3,
0 12
3,
1 12
3,
2 12
Major
number
Minor
number
5
5
5
5
5
5
5
5
5
5
5
5
5
20:59
20:59
20:59
20:59
13:00
20:59
20:59
20:59
20:59
13:00
20:59
12:59
12:59
adsp
agpgart
audio
bus
console
disk
dsp
event0
full
gpmctl
hda
hda1
hda2
For example:
# mknod /dev/hello c 254 0
register_chrdev is defined in
<linux/fs.h>.
Where,
Note that,
#include <linux/config.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include "NET-Start.h"
#define MAJOR_NUM 120
sniped
module_init(_7seg_init);
module_exit(_7seg_cleanup);
Release method