rvm_types/device.rs
1//! Device lease types.
2
3/// Unique identifier for a device lease.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
5#[repr(transparent)]
6pub struct DeviceLeaseId(u64);
7
8impl DeviceLeaseId {
9 /// Create a new device lease identifier.
10 #[must_use]
11 pub const fn new(id: u64) -> Self {
12 Self(id)
13 }
14
15 /// Return the raw identifier value.
16 #[must_use]
17 pub const fn as_u64(self) -> u64 {
18 self.0
19 }
20}
21
22/// Classification of device types.
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
24#[repr(u8)]
25pub enum DeviceClass {
26 /// Network interface controller.
27 Network = 0,
28 /// Block storage device.
29 Storage = 1,
30 /// GPU or display controller.
31 Graphics = 2,
32 /// Serial / UART console.
33 Serial = 3,
34 /// Timer / clock device.
35 Timer = 4,
36 /// Interrupt controller.
37 InterruptController = 5,
38 /// Generic MMIO device.
39 Generic = 255,
40}
41
42/// GPU memory type classification.
43#[derive(Debug, Clone, Copy, PartialEq, Eq)]
44#[repr(u8)]
45pub enum GpuMemoryType {
46 /// Device-local (VRAM), fastest for GPU access.
47 DeviceLocal = 0,
48 /// Host-visible, mappable by CPU.
49 HostVisible = 1,
50 /// Shared/unified memory accessible by both.
51 Unified = 2,
52}
53
54/// GPU command queue priority.
55#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
56#[repr(u8)]
57pub enum GpuQueuePriority {
58 /// Low priority (background compute).
59 Low = 0,
60 /// Normal priority.
61 Normal = 1,
62 /// High priority (real-time rendering/inference).
63 High = 2,
64 /// Realtime priority (coherence engine acceleration).
65 Realtime = 3,
66}
67
68/// A time-bounded, revocable device lease.
69#[derive(Debug, Clone, Copy)]
70pub struct DeviceLease {
71 /// Unique lease identifier.
72 pub id: DeviceLeaseId,
73 /// Device class.
74 pub class: DeviceClass,
75 /// MMIO base address.
76 pub mmio_base: u64,
77 /// MMIO region size in bytes.
78 pub mmio_size: u64,
79 /// Lease expiry timestamp (nanoseconds, 0 = no expiry).
80 pub expiry_ns: u64,
81 /// Epoch when the lease was granted.
82 pub epoch: u32,
83}