Skip to content

Commit ed3bfb7

Browse files
committed
chore(crates): introduce new config crate for sprout configuration
1 parent ccc75a2 commit ed3bfb7

39 files changed

Lines changed: 451 additions & 378 deletions

Cargo.lock

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
members = [
3+
"crates/config",
34
"crates/sprout",
45
]
56
resolver = "3"

crates/config/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "edera-sprout-config"
3+
description = "Sprout Configuration"
4+
license.workspace = true
5+
version.workspace = true
6+
homepage.workspace = true
7+
repository.workspace = true
8+
edition.workspace = true
9+
10+
[dependencies.serde]
11+
workspace = true
12+
features = ["derive"]
13+
14+
[lib]
15+
name = "edera_sprout_config"

crates/config/src/actions.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// Configuration for the chainload action.
4+
pub mod chainload;
5+
6+
/// Configuration for the edera action.
7+
pub mod edera;
8+
9+
/// Configuration for the print action.
10+
pub mod print;
11+
12+
/// Declares an action that sprout can execute.
13+
/// Actions allow configuring sprout's internal runtime mechanisms with values
14+
/// that you can specify via other concepts.
15+
///
16+
/// Actions are the main work that Sprout gets done, like booting Linux.
17+
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
18+
pub struct ActionDeclaration {
19+
/// Chainload to another EFI application.
20+
/// This allows you to load any EFI application, either to boot an operating system
21+
/// or to perform more EFI actions and return to sprout.
22+
#[serde(default)]
23+
pub chainload: Option<chainload::ChainloadConfiguration>,
24+
/// Print a string to the EFI console.
25+
#[serde(default)]
26+
pub print: Option<print::PrintConfiguration>,
27+
/// Boot the Edera hypervisor and the root operating system.
28+
/// This action is an extension on top of the Xen EFI stub that
29+
/// is specific to Edera.
30+
#[serde(default, rename = "edera")]
31+
pub edera: Option<edera::EderaConfiguration>,
32+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// The configuration of the chainload action.
4+
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
5+
pub struct ChainloadConfiguration {
6+
/// The path to the image to chainload.
7+
/// This can be a Linux EFI stub (vmlinuz usually) or a standard EFI executable.
8+
pub path: String,
9+
/// The options to pass to the image.
10+
/// The options are concatenated by a space and then passed to the EFI application.
11+
#[serde(default)]
12+
pub options: Vec<String>,
13+
/// An optional path to a Linux initrd.
14+
/// This uses the [LINUX_EFI_INITRD_MEDIA_GUID] mechanism to load the initrd into the EFI stack.
15+
/// For Linux, you can also use initrd=\path\to\initrd as an option, but this option is
16+
/// generally better and safer as it can support additional load options in the future.
17+
#[serde(default, rename = "linux-initrd")]
18+
pub linux_initrd: Option<String>,
19+
}

crates/config/src/actions/edera.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// The configuration of the edera action which boots the Edera hypervisor.
4+
/// Edera is based on Xen but modified significantly with a Rust stack.
5+
/// Sprout is a component of the Edera stack and provides the boot functionality of Xen.
6+
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
7+
pub struct EderaConfiguration {
8+
/// The path to the Xen hypervisor EFI image.
9+
pub xen: String,
10+
/// The path to the kernel to boot for dom0.
11+
pub kernel: String,
12+
/// The path to the initrd to load for dom0.
13+
#[serde(default)]
14+
pub initrd: Option<String>,
15+
/// The options to pass to the kernel.
16+
#[serde(default, rename = "kernel-options")]
17+
pub kernel_options: Vec<String>,
18+
/// The options to pass to the Xen hypervisor.
19+
#[serde(default, rename = "xen-options")]
20+
pub xen_options: Vec<String>,
21+
}

crates/config/src/actions/print.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// The configuration of the print action.
4+
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
5+
pub struct PrintConfiguration {
6+
/// The text to print to the console.
7+
#[serde(default)]
8+
pub text: String,
9+
}

crates/config/src/drivers.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// Declares a driver configuration.
4+
/// Drivers allow extending the functionality of Sprout.
5+
/// Drivers are loaded at runtime and can provide extra functionality like filesystem support.
6+
/// Drivers are loaded by their name, which is used to reference them in other concepts.
7+
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
8+
pub struct DriverDeclaration {
9+
/// The filesystem path to the driver.
10+
/// This file should be an EFI executable that can be located and executed.
11+
pub path: String,
12+
}

crates/config/src/entries.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use serde::{Deserialize, Serialize};
2+
use std::collections::BTreeMap;
3+
4+
/// Declares a boot entry to display in the boot menu.
5+
///
6+
/// Entries are the user-facing concept of Sprout, making it possible
7+
/// to run a set of actions with a specific context.
8+
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
9+
pub struct EntryDeclaration {
10+
/// The title of the entry which will be display in the boot menu.
11+
/// This is the pre-stamped value.
12+
pub title: String,
13+
/// The actions to run when the entry is selected.
14+
#[serde(default)]
15+
pub actions: Vec<String>,
16+
/// The values to insert into the context when the entry is selected.
17+
#[serde(default)]
18+
pub values: BTreeMap<String, String>,
19+
}

crates/config/src/extractors.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use crate::extractors::filesystem_device_match::FilesystemDeviceMatchExtractor;
2+
use serde::{Deserialize, Serialize};
3+
4+
/// Configuration for the filesystem-device-match extractor.
5+
pub mod filesystem_device_match;
6+
7+
/// Declares an extractor configuration.
8+
/// Extractors allow calculating values at runtime
9+
/// using built-in sprout modules.
10+
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
11+
pub struct ExtractorDeclaration {
12+
/// The filesystem device match extractor.
13+
/// This extractor finds a filesystem using some search criteria and returns
14+
/// the device root path that can concatenated with subpaths to access files
15+
/// on a particular filesystem.
16+
#[serde(default, rename = "filesystem-device-match")]
17+
pub filesystem_device_match: Option<FilesystemDeviceMatchExtractor>,
18+
}

0 commit comments

Comments
 (0)