ad2d8a71b12a509d7bcfd20ff0ae6f5576011c74
[lunaix-os.git] / lunaix-os / includes / lunaix / device_num.h
1 #ifndef __LUNAIX_DEVICE_NUM_H
2 #define __LUNAIX_DEVICE_NUM_H
3
4 #include <lunaix/types.h>
5
6 /*
7     Device metadata field (device_def::meta)
8
9     31          16 15           0
10     |  interface  |   function  |
11
12     Where the interface identify how the device is connected with the processor
13     Lunaix identify the following values:
14
15         NON: device do not have hardware interfacing
16
17         SOC: device conntected through some System-on-Chip interconnect bus
18             for example, southbridge on x86 platform, AMBA for ARM's series.
19
20         PCI: device connected through the peripheral component interconnect bus
21             (PCI)
22
23         USB: device connected through the universal serial bus (USB)
24
25         SPI: device connected through the serial peripheral interface (SPI)
26
27         I2C: device connected through the IIC protocol
28
29     The function defines the functionality that the device is designated to
30    serve. Lunaix identify the following values:
31
32         PSEDUO: a pseudo device which does not backed by any hardware. (e.g.
33                 /dev/null)
34
35         CHAR: a character device, which support read/write and dealing with
36              characters. Backed hardware might exist.
37
38         SERIAL: a serial interface which talks
39
40         STORAGE: a device that is used for storage of data
41
42         INPUT: a device that accept external input.
43
44         TIME: a device that provides time related services, for example, timing
45              and clocking
46
47         BUSIF: a device that is the interface or HBAs for accessing interconnect
48    bus.
49
50         TTY: a device which can be called as teletypewriter, system can use such
51             device for output into external environment
52 */
53
54 #define DEV_FNGRP(if_, function)                                               \
55     (((if_) & 0xffff) << 16) | ((function) & 0xffff)
56 #define DEV_UNIQUE(devkind, variant)                                           \
57     (((devkind) & 0xffff) << 16) | ((variant) & 0xffff)
58 #define DEV_KIND_FROM(unique) ((unique) >> 16)
59 #define DEV_VAR_FROM(unique) ((unique) & 0xffff)
60
61 #define DEV_IF(fngrp) ((fngrp) >> 16)
62 #define DEV_FN(fngrp) (((fngrp) & 0xffff))
63
64 #define DEVIF_NON 0x0
65 #define DEVIF_SOC 0x1
66 #define DEVIF_PCI 0x2
67 #define DEVIF_USB 0x3
68 #define DEVIF_SPI 0x4
69 #define DEVIF_I2C 0x5
70
71 #define DEVFN_PSEUDO 0x0
72 #define DEVFN_CHAR 0x1
73 #define DEVFN_STORAGE 0x4
74 #define DEVFN_INPUT 0x5
75 #define DEVFN_TIME 0x6
76 #define DEVFN_BUSIF 0x7
77 #define DEVFN_TTY 0x8
78 #define DEVFN_DISP 0x9
79
80 #define DEV_BUILTIN 0
81 #define DEV_BUILTIN_NULL 0
82 #define DEV_BUILTIN_ZERO 1
83
84 #define DEV_VTERM 1
85 #define DEV_RNG 2
86 #define DEV_RTC 3
87 #define DEV_SATA 4
88 #define DEV_NVME 5
89 #define DEV_PCI 6
90 #define DEV_UART16550 7
91
92 #define DEV_TIMER 8
93 #define DEV_TIMER_APIC 0
94 #define DEV_TIMER_HEPT 1
95
96 #define DEV_NULL 9
97 #define DEV_ZERO 10
98 #define DEV_KBD 11
99 #define DEV_VGA 12
100
101 struct devident
102 {
103     u32_t fn_grp;
104     u32_t unique;
105 };
106
107 struct devclass
108 {
109     u32_t fn_grp;
110     u32_t device;
111     u32_t variant;
112     u32_t hash;
113 };
114
115 #endif /* __LUNAIX_DEVICE_NUM_H */