Alioth Code Coverage

device.rs0.00%

1// Copyright 2024 Google LLC
2//
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 at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// 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 and
13// limitations under the License.
14
15use alioth_macros::trace_error;
16use snafu::Snafu;
17
18use crate::errors::DebugTrace;
19use crate::mem::emulated::Mmio;
20
21pub mod clock;
22pub mod cmos;
23pub mod console;
24#[cfg(target_arch = "x86_64")]
25#[path = "fw_cfg/fw_cfg.rs"]
26pub mod fw_cfg;
27#[cfg(target_arch = "x86_64")]
28pub mod ioapic;
29pub mod net;
30#[cfg(target_arch = "aarch64")]
31pub mod pl011;
32#[cfg(target_arch = "aarch64")]
33pub mod pl031;
34#[cfg(target_arch = "x86_64")]
35pub mod serial;
36
37#[trace_error]
38#[derive(Snafu, DebugTrace)]
39#[snafu(module, visibility(pub(crate)), context(suffix(false)))]
40pub enum Error {
41 #[snafu(display("Device is not pausable"))]
42 NotPausable,
43}
44
45pub type Result<T, E = Error> = std::result::Result<T, E>;
46
47pub trait Pause {
48 fn pause(&self) -> Result<()> {
49 error::NotPausable.fail()
50 }
51 fn resume(&self) -> Result<()> {
52 error::NotPausable.fail()
53 }
54}
55
56pub trait MmioDev: Mmio + Pause {}
57