Alioth Code Coverage

firmware.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
15#[path = "acpi/acpi.rs"]
16#[cfg(target_arch = "x86_64")]
17pub mod acpi;
18#[path = "dt/dt.rs"]
19pub mod dt;
20#[path = "ovmf/ovmf.rs"]
21pub mod ovmf;
22#[path = "uefi/uefi.rs"]
23pub mod uefi;
24
25use snafu::Snafu;
26
27use crate::errors::{DebugTrace, trace_error};
28
29use self::ovmf::x86_64::sev::SEV_SIGNATURE;
30use self::ovmf::x86_64::tdx::{TDVF_SIGNATURE, TDVF_VERSION};
31
32#[trace_error]
33#[derive(Snafu, DebugTrace)]
34#[snafu(module, context(suffix(false)))]
35pub enum Error {
36 #[snafu(display("Firmware missing {name}"))]
37 MissingMetadata { name: &'static str },
38 #[snafu(display("Firmware missing TDVF signature {TDVF_SIGNATURE:08x}, got {got:08x}"))]
39 MissingTdvfSignature { got: u32 },
40 #[snafu(display("Firmware missing AMD-SEV signature {SEV_SIGNATURE:08x}, got {got:08x}"))]
41 MissingAmdSevSignature { got: u32 },
42 #[snafu(display("Firmware missing TDVF version {TDVF_VERSION}, got {got}"))]
43 MissingTdvfVersion { got: u32 },
44 #[snafu(display("Invalid firmware data layout"))]
45 InvalidLayout,
46 #[snafu(display("Uncovered TDVF section"))]
47 UncoveredTdvfSection,
48 #[snafu(display("Failed to write HOB"))]
49 WriteHob { error: std::io::Error },
50}
51
52type Result<T, E = Error> = std::result::Result<T, E>;
53