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
use std::path::Path;
use bootloader_boot_config::BootConfig;
use crate::DiskImageBuilder;
/// Create disk images for booting on legacy BIOS systems.
pub struct UefiBoot {
image_builder: DiskImageBuilder,
}
impl UefiBoot {
/// Start creating a disk image for the given bootloader ELF executable.
pub fn new(kernel_path: &Path) -> Self {
Self {
image_builder: DiskImageBuilder::new(kernel_path.to_owned()),
}
}
/// Add a ramdisk file to the image
pub fn set_ramdisk(&mut self, ramdisk_path: &Path) -> &mut Self {
self.image_builder.set_ramdisk(ramdisk_path.to_owned());
self
}
/// Creates a configuration file (boot.json) that configures the runtime behavior of the bootloader.
pub fn set_boot_config(&mut self, config: &BootConfig) -> &mut Self {
self.image_builder.set_boot_config(config);
self
}
/// Create a bootable UEFI disk image at the given path.
pub fn create_disk_image(&self, out_path: &Path) -> anyhow::Result<()> {
self.image_builder.create_uefi_image(out_path)
}
/// Prepare a folder for use with booting over UEFI_PXE.
///
/// This places the bootloader executable under the path "bootloader". The
/// DHCP server should set the filename option to that path, otherwise the
/// bootloader won't be found.
pub fn create_pxe_tftp_folder(&self, out_path: &Path) -> anyhow::Result<()> {
self.image_builder.create_uefi_tftp_folder(out_path)
}
}