missing_dev_resources/
lib.rs1#![forbid(unsafe_code)]
7
8use mesh::MeshPayload;
9use std::ops::RangeInclusive;
10use vm_resource::ResourceId;
11use vm_resource::kind::ChipsetDeviceHandleKind;
12
13#[derive(MeshPayload, Default)]
15pub struct MissingDevHandle {
16 pub pio: Vec<(String, u16, u16)>,
18 pub mmio: Vec<(String, u64, u64)>,
20}
21
22impl ResourceId<ChipsetDeviceHandleKind> for MissingDevHandle {
23 const ID: &'static str = "missing-dev";
24}
25
26impl MissingDevHandle {
27 pub fn new() -> Self {
29 Self::default()
30 }
31
32 pub fn claim_pio(mut self, region_name: impl Into<String>, range: RangeInclusive<u16>) -> Self {
34 self.pio
35 .push((region_name.into(), *range.start(), *range.end()));
36 self
37 }
38
39 pub fn claim_mmio(
41 mut self,
42 region_name: impl Into<String>,
43 range: RangeInclusive<u64>,
44 ) -> Self {
45 self.mmio
46 .push((region_name.into(), *range.start(), *range.end()));
47 self
48 }
49}