blob: 883dcbae7da244f49884bb5fe7f27132417a9046 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#pragma once
#include "types.h"
/*
* A Weenix "device identifier" is the concatenation of:
* - a "driver number" or "device type" (major number)
* - a "device number" (minor number)
*
* The device identifiers for block devices and character devices are
* independent. That is, you could have both a block device and a char device
* with major 3, minor 5 (for example). They would be distinct.
*
* Weenix's device number allocation/assignment scheme is as follows:
*
* - major 0 (byte or block), minor 0: reserved as an analogue of NULL
* for device id's
*
* - char major 1: Memory devices (mem)
* - minor 0: /dev/null The null device
* - minor 1: /dev/zero The zero device
*
* - char major 2: TTY devices (tty)
* - minor 0: /dev/tty0 First TTY device
* - minor 1: /dev/tty1 Second TTY device
* - and so on...
*
* - block major 1: Disk devices
* - minor 0: first disk device
* - minor 1: second disk device
* - and so on...
*/
#define MINOR_BITS 8
#define MINOR_MASK ((1U << MINOR_BITS) - 1)
#define MAJOR(devid) ((unsigned)((devid) >> MINOR_BITS))
#define MINOR(devid) ((unsigned)((devid)&MINOR_MASK))
#define MKDEVID(major, minor) ((devid_t)(((major) << MINOR_BITS) | (minor)))
/* convenience definition: the NULL device id: */
#define NULL_DEVID (MKDEVID(0, 0))
#define MEM_NULL_DEVID (MKDEVID(1, 0))
#define MEM_ZERO_DEVID (MKDEVID(1, 1))
#define DISK_MAJOR 1
#define MEM_MAJOR 1
#define MEM_NULL_MINOR 0
#define MEM_ZERO_MINOR 1
|