Statistics
| Revision:

root / logic / trunk / src / kernel_modules / generic / chardev.h @ 71

History | View | Annotate | Download (1.47 KB)

1
/*
2
* chardev.h − the header file with the ioctl definitions.
3
* The declarations here have to be in a header file, because
4
* they need to be known both to the kernel module
5
* (in chardev.c) and the process calling ioctl (ioctl.c)
6
*/
7
#ifndef CHARDEV_H
8
#define CHARDEV_H
9
#include <linux/ioctl.h>
10
/*
11
* The major device number. We can't rely on dynamic
12
* registration any more, because ioctls need to know
13
* it.
14
*/
15
#define MAJOR_NUM 100
16
/*
17
* Set the message of the device driver
18
*/
19
#define IOCTL_SET_MSG _IOR(MAJOR_NUM, 0, char *)
20
/*
21
* _IOR means that we're creating an ioctl command
22
* number for passing information from a user process
23
* to the kernel module.
24
*
25
* The first arguments, MAJOR_NUM, is the major device
26
* number we're using.
27
*
28
* The second argument is the number of the command
29
* (there could be several with different meanings).
30
*
31
* The third argument is the type we want to get from
32
* the process to the kernel.
33
*/
34
/*
35
* Get the message of the device driver
36
*/
37
#define IOCTL_GET_MSG _IOR(MAJOR_NUM, 1, char *)
38
/*
39
* This IOCTL is used for output, to get the message
40
* of the device driver. However, we still need the
41
* buffer to place the message in to be input,
42
* as it is allocated by the process.
43
*/
44
/*
45
* Get the n'th byte of the message
46
*/
47
#define IOCTL_GET_NTH_BYTE _IOWR(MAJOR_NUM, 2, int)
48
/*
49
* The IOCTL is used for both input and output. It
50
* receives from the user a number, n, and returns
51
* Message[n].
52
*/
53
/*
54
* The name of the device file
55
*/
56
#define DEVICE_FILE_NAME "char_dev"
57
#endif
58