d6052cdb0c09160e09e84828d32a342c3fa17113
[lunaix-os.git] / lunaix-os / includes / lunaix / device_num.h
1 #ifndef __LUNAIX_DEVICE_NUM_H
2 #define __LUNAIX_DEVICE_NUM_H
3
4 /*
5     Device metadata field (device_def::meta)
6
7     31          16 15           0
8     |  interface  |   function  |
9
10     Where the interface identify how the device is connected with the processor
11     Lunaix identify the following values:
12
13         NON: device do not have hardware interfacing
14
15         SOC: device conntected through some System-on-Chip interconnect bus
16             for example, southbridge on x86 platform, AMBA for ARM's series.
17
18         PCI: device connected through the peripheral component interconnect bus
19             (PCI)
20
21         USB: device connected through the universal serial bus (USB)
22
23         SPI: device connected through the serial peripheral interface (SPI)
24
25         I2C: device connected through the IIC protocol
26
27     The function defines the functionality that the device is designated to
28    serve. Lunaix identify the following values:
29
30         PSEDUO: a pseudo device which does not backed by any hardware. (e.g.
31                 /dev/null)
32
33         CHAR: a character device, which support read/write and dealing with
34              characters. Backed hardware might exist.
35
36         SERIAL: a serial interface which talks
37
38         STORAGE: a device that is used for storage of data
39
40         INPUT: a device that accept external input.
41
42         TIME: a device that provides time related services, for example, timing
43              and clocking
44
45         BUSIF: a device that is the interface or HBAs for accessing interconnect
46    bus.
47
48         TTY: a device which can be called as teletypewriter, system can use such
49             device for output into external environment
50 */
51
52 #define DEV_META(if_, function) (((if_) & 0xffff) << 16) | ((function) & 0xffff)
53 #define DEV_IF(meta) ((meta) >> 16)
54 #define DEV_FN(meta) (((meta) & 0xffff))
55
56 #define DEVIF_NON 0x0
57 #define DEVIF_SOC 0x1
58 #define DEVIF_PCI 0x2
59 #define DEVIF_USB 0x3
60 #define DEVIF_SPI 0x4
61 #define DEVIF_I2C 0x5
62
63 #define DEVFN_PSEUDO 0x0
64 #define DEVFN_CHAR 0x1
65 #define DEVFN_STORAGE 0x4
66 #define DEVFN_INPUT 0x5
67 #define DEVFN_TIME 0x6
68 #define DEVFN_BUSIF 0x7
69 #define DEVFN_TTY 0x8
70
71 #define DEV_BUILTIN 0x0
72 #define DEV_X86LEGACY 0x1
73 #define DEV_RNG 0x2
74 #define DEV_RTC 0x3
75 #define DEV_SATA 0x4
76 #define DEV_NVME 0x5
77 #define DEV_BUS 0x6
78 #define DEV_SERIAL 0x7
79 #define DEV_TIMER 0x8
80
81 #endif /* __LUNAIX_DEVICE_NUM_H */