1 use system_error::SystemError; 2 3 use super::multiboot2::early_multiboot2_init; 4 5 const BOOT_ENTRY_TYPE_MULTIBOOT: u64 = 1; 6 const BOOT_ENTRY_TYPE_MULTIBOOT2: u64 = 2; 7 const BOOT_ENTRY_TYPE_LINUX_32: u64 = 3; 8 const BOOT_ENTRY_TYPE_LINUX_64: u64 = 4; 9 10 #[derive(Debug)] 11 #[repr(u64)] 12 enum BootProtocol { 13 Multiboot = 1, 14 Multiboot2, 15 Linux32, 16 Linux64, 17 } 18 19 impl TryFrom<u64> for BootProtocol { 20 type Error = SystemError; 21 22 fn try_from(value: u64) -> Result<Self, Self::Error> { 23 match value { 24 BOOT_ENTRY_TYPE_MULTIBOOT => Ok(BootProtocol::Multiboot), 25 BOOT_ENTRY_TYPE_MULTIBOOT2 => Ok(BootProtocol::Multiboot2), 26 BOOT_ENTRY_TYPE_LINUX_32 => Ok(BootProtocol::Linux32), 27 BOOT_ENTRY_TYPE_LINUX_64 => Ok(BootProtocol::Linux64), 28 _ => Err(SystemError::EINVAL), 29 } 30 } 31 } 32 33 #[inline(never)] 34 pub(super) fn early_boot_init( 35 boot_entry_type: u64, 36 arg1: u64, 37 arg2: u64, 38 ) -> Result<(), SystemError> { 39 let boot_protocol = BootProtocol::try_from(boot_entry_type)?; 40 match boot_protocol { 41 BootProtocol::Multiboot => { 42 // early_multiboot_init(arg1, arg2); 43 unimplemented!(); 44 } 45 BootProtocol::Multiboot2 => early_multiboot2_init(arg1 as u32, arg2), 46 BootProtocol::Linux32 => { 47 // linux32_init(arg1, arg2); 48 unimplemented!(); 49 } 50 BootProtocol::Linux64 => { 51 // linux64_init(arg1, arg2); 52 unimplemented!(); 53 } 54 } 55 } 56