Skip to main content

device/
kind.rs

1//! Registry of VFS control command kind bytes (`file_system::define_command!`).
2//!
3//! Each device class uses a distinct 1-byte kind identifier encoded into
4//! [`file_system::ControlCommandIdentifier`]. Existing kind bytes are part of
5//! the stable VFS control ABI and must not be changed.
6//!
7//! | Kind byte | Hex    | Device class        | Owning module / crate                    |
8//! |-----------|--------|---------------------|------------------------------------------|
9//! | `b'A'`    | `0x41` | Audio               | `device::audio` / `audio`                |
10//! | `b'B'`    | `0x42` | Block device        | `file_system::block_device`              |
11//! | `b'D'`    | `0x44` | Screen / display    | `device::screen` / `graphics`            |
12//! | `b'E'`    | `0x45` | Executable          | `executable`                             |
13//! | `b'F'`    | `0x46` | Firmware update     | `firmware_update::device`                |
14//! | `b'H'`    | `0x48` | Hash accelerator    | `device::hash`                           |
15//! | `b'N'`    | `0x4E` | Neural network      | `device::neural_network` / `drivers_neural_network` |
16//! | `b'P'`    | `0x50` | System power        | `device::power` / `drivers_peripherals::power` |
17//! | `b'T'`    | `0x54` | Terminal / character| `file_system::character_device`          |
18//! | `b'L'`    | `0x4C` | Bluetooth LE        | `device::bluetooth` / `bluetooth`       |
19//! | `b'a'`    | `0x61` | ADC                 | `device::adc` / `drivers_peripherals::adc`|
20//! | `b'g'`    | `0x67` | GPIO                | `device::gpio` / `drivers_peripherals::gpio` |
21//! | `b'h'`    | `0x68` | Human interface emulation | `device::human_interface` / `drivers_peripherals::human_interface` |
22//! | `b'i'`    | `0x69` | I2C                 | `device::i2c` / `drivers_peripherals::i2c`|
23//! | `b'n'`    | `0x6E` | Network interface   | `network`                                |
24//! | `b'p'`    | `0x70` | PWM                 | `device::pwm` / `drivers_peripherals::pwm`|
25//! | `b'r'`    | `0x72` | Real-time clock     | `device::real_time_clock` / `drivers_peripherals::real_time_clock` |
26//! | `b's'`    | `0x73` | SPI                 | `device::spi` / `drivers_peripherals::spi`|
27//! | `b'u'`    | `0x75` | UART                | `device::uart` / `drivers_peripherals::uart` |
28//! | `b'w'`    | `0x77` | Wi-Fi               | `network`                                |
29
30/// Audio playback and stream control (`b'A'`).
31pub const AUDIO: u8 = b'A';
32
33/// Generic block device geometry queries (`b'B'`).
34///
35/// Defined directly in `file_system::block_device` as a literal to avoid a
36/// dependency cycle (`device` depends on `file_system`).
37pub const BLOCK_DEVICE: u8 = b'B';
38
39/// Screen / display control and screenshot requests (`b'D'`).
40pub const SCREEN: u8 = b'D';
41
42/// Native executable launch entry point query (`b'E'`).
43pub const EXECUTABLE: u8 = b'E';
44
45/// Firmware update transaction control (`b'F'`).
46pub const FIRMWARE_UPDATE: u8 = b'F';
47
48/// Hardware or software cryptographic hash device (`b'H'`).
49pub const HASH: u8 = b'H';
50
51/// Bluetooth Low Energy host.
52pub const BLUETOOTH: u8 = b'L';
53
54/// Neural network inference device (`b'N'`).
55pub const NEURAL_NETWORK: u8 = b'N';
56
57/// System power actions: power off, restart, sleep (`b'P'`).
58pub const POWER: u8 = b'P';
59
60/// Terminal capability query and line discipline attributes on character
61/// devices (`b'T'`).
62///
63/// Defined directly in `file_system::character_device` as a literal to avoid a
64/// dependency cycle (`device` depends on `file_system`).
65pub const TERMINAL: u8 = b'T';
66
67/// Analog-to-digital converter (`b'a'`).
68pub const ADC: u8 = b'a';
69
70/// General-purpose input/output line (`b'g'`).
71pub const GPIO: u8 = b'g';
72
73/// Human interface emulation device, acting as a keyboard, media remote and mouse toward
74/// the connected computer (`b'h'`).
75pub const HUMAN_INTERFACE: u8 = b'h';
76
77/// Inter-Integrated Circuit bus endpoint (`b'i'`).
78pub const I2C: u8 = b'i';
79
80/// Network interface configuration and routing (`b'n'`).
81pub const NETWORK: u8 = b'n';
82
83/// Pulse-width modulation channel (`b'p'`).
84pub const PWM: u8 = b'p';
85
86/// Real-time clock: wall-clock time (UTC) kept across resets and power-off (`b'r'`).
87pub const REAL_TIME_CLOCK: u8 = b'r';
88
89/// Serial Peripheral Interface endpoint (`b's'`).
90pub const SPI: u8 = b's';
91
92/// Universal Asynchronous Receiver-Transmitter endpoint (`b'u'`).
93pub const UART: u8 = b'u';
94
95/// Wi-Fi radio, scan, and client association control (`b'w'`).
96pub const WIFI: u8 = b'w';
97
98/// All registered VFS control command kind bytes.
99pub const ALL: &[u8] = &[
100    AUDIO,
101    BLOCK_DEVICE,
102    SCREEN,
103    EXECUTABLE,
104    FIRMWARE_UPDATE,
105    HASH,
106    BLUETOOTH,
107    NEURAL_NETWORK,
108    POWER,
109    TERMINAL,
110    ADC,
111    GPIO,
112    HUMAN_INTERFACE,
113    I2C,
114    NETWORK,
115    PWM,
116    REAL_TIME_CLOCK,
117    SPI,
118    UART,
119    WIFI,
120];
121
122#[cfg(test)]
123mod tests {
124    use super::*;
125
126    #[test]
127    fn all_registered_kinds_are_distinct() {
128        for (i, &left) in ALL.iter().enumerate() {
129            for &right in &ALL[i + 1..] {
130                assert_ne!(
131                    left, right,
132                    "duplicate control command kind byte: 0x{left:02x} ('{}')",
133                    left as char
134                );
135            }
136        }
137    }
138}