1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#![no_std]
use serde::{Deserialize, Serialize};
/// Configures the boot behavior of the bootloader.
#[derive(Serialize, Deserialize)]
#[serde(default)]
#[non_exhaustive]
pub struct BootConfig {
/// Configuration for the frame buffer setup.
pub frame_buffer: FrameBuffer,
/// The minimum log level that is printed to the screen during boot.
///
/// The default is [`LevelFilter::Trace`].
pub log_level: LevelFilter,
/// Whether the bootloader should print log messages to the framebuffer during boot.
///
/// Enabled by default.
pub frame_buffer_logging: bool,
/// Whether the bootloader should print log messages to the serial port during boot.
///
/// Enabled by default.
pub serial_logging: bool,
#[doc(hidden)]
pub _test_sentinel: u64,
}
impl Default for BootConfig {
fn default() -> Self {
Self {
frame_buffer: Default::default(),
log_level: Default::default(),
frame_buffer_logging: true,
serial_logging: true,
_test_sentinel: 0,
}
}
}
/// Configuration for the frame buffer used for graphical output.
#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Eq, Clone, Copy)]
#[non_exhaustive]
pub struct FrameBuffer {
/// Instructs the bootloader to set up a framebuffer format that has at least the given height.
///
/// If this is not possible, the bootloader will fall back to a smaller format.
pub minimum_framebuffer_height: Option<u64>,
/// Instructs the bootloader to set up a framebuffer format that has at least the given width.
///
/// If this is not possible, the bootloader will fall back to a smaller format.
pub minimum_framebuffer_width: Option<u64>,
}
/// An enum representing the available verbosity level filters of the logger.
///
/// Based on
/// <https://github.com/rust-lang/log/blob/dc32ab999f52805d5ce579b526bd9d9684c38d1a/src/lib.rs#L552-565>
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum LevelFilter {
/// A level lower than all log levels.
Off,
/// Corresponds to the `Error` log level.
Error,
/// Corresponds to the `Warn` log level.
Warn,
/// Corresponds to the `Info` log level.
Info,
/// Corresponds to the `Debug` log level.
Debug,
/// Corresponds to the `Trace` log level.
Trace,
}
impl Default for LevelFilter {
fn default() -> Self {
Self::Trace
}
}