@@ -77,25 +77,41 @@ use std::{
7777
7878mod fat;
7979mod gpt;
80+ mod mbr;
8081
8182const KERNEL_FILE_NAME : & str = "kernel-x86_64" ;
8283
83- pub fn create_uefi_disk_image (
84- kernel_binary : & Path ,
85- out_fat_path : & Path ,
86- out_gpt_path : & Path ,
87- ) -> anyhow:: Result < ( ) > {
84+ /// Creates a bootable FAT partition at the given path.
85+ pub fn create_boot_partition ( kernel_binary : & Path , out_path : & Path ) -> anyhow:: Result < ( ) > {
8886 let bootloader_path = Path :: new ( env ! ( "UEFI_BOOTLOADER_PATH" ) ) ;
8987
9088 let mut files = BTreeMap :: new ( ) ;
9189 files. insert ( "efi/boot/bootx64.efi" , bootloader_path) ;
9290 files. insert ( KERNEL_FILE_NAME , kernel_binary) ;
9391
94- fat:: create_fat_filesystem ( files, & out_fat_path)
95- . context ( "failed to create UEFI FAT filesystem" ) ?;
96- gpt:: create_gpt_disk ( out_fat_path, out_gpt_path)
92+ fat:: create_fat_filesystem ( files, & out_path) . context ( "failed to create UEFI FAT filesystem" ) ?;
93+
94+ Ok ( ( ) )
95+ }
96+
97+ pub fn create_uefi_disk_image (
98+ boot_partition_path : & Path ,
99+ out_gpt_path : & Path ,
100+ ) -> anyhow:: Result < ( ) > {
101+ gpt:: create_gpt_disk ( boot_partition_path, out_gpt_path)
97102 . context ( "failed to create UEFI GPT disk image" ) ?;
98103
99104 Ok ( ( ) )
100105}
101106
107+ pub fn create_bios_disk_image (
108+ boot_partition_path : & Path ,
109+ out_mbr_path : & Path ,
110+ ) -> anyhow:: Result < ( ) > {
111+ let bootsector_path = Path :: new ( env ! ( "BIOS_BOOT_SECTOR_PATH" ) ) ;
112+
113+ mbr:: create_mbr_disk ( bootsector_path, boot_partition_path, out_mbr_path)
114+ . context ( "failed to create BIOS MBR disk image" ) ?;
115+
116+ Ok ( ( ) )
117+ }
0 commit comments