device.rs0.00%
1
// Copyright 2024 Google LLC2
//3
// Licensed under the Apache License, Version 2.0 (the "License");4
// you may not use this file except in compliance with the License.5
// You may obtain a copy of the License at6
//7
// https://www.apache.org/licenses/LICENSE-2.08
//9
// Unless required by applicable law or agreed to in writing, software10
// distributed under the License is distributed on an "AS IS" BASIS,11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12
// See the License for the specific language governing permissions and13
// limitations under the License.14
15
use alioth_macros::trace_error;16
use snafu::Snafu;17
18
use crate::errors::DebugTrace;19
use crate::mem::emulated::Mmio;20
21
pub mod clock;22
pub mod cmos;23
pub mod console;24
#[cfg(target_arch = "x86_64")]25
#[path = "fw_cfg/fw_cfg.rs"]26
pub mod fw_cfg;27
pub mod fw_dbg;28
pub mod ioapic;29
pub mod net;30
pub mod pl011;31
pub mod pl031;32
pub mod serial;33
34
#[trace_error]35
#[derive(Snafu, DebugTrace)]36
#[snafu(module, visibility(pub(crate)), context(suffix(false)))]37
pub enum Error {38
#[snafu(display("Error from OS"), context(false))]39
System { error: std::io::Error },40
#[snafu(display("Device is not pausable"))]41
NotPausable,42
}43
44
pub type Result<T, E = Error> = std::result::Result<T, E>;45
46
pub trait Pause {47
fn pause(&self) -> Result<()> {48
error::NotPausable.fail()49
}50
fn resume(&self) -> Result<()> {51
error::NotPausable.fail()52
}53
}54
55
pub trait MmioDev: Mmio + Pause {}56