From 2a4c87c6b1df2746c347efc5b6b711a74d82df7d Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Wed, 7 Aug 2024 02:10:10 +0000 Subject: [PATCH] call it modinfo, not metadata --- src/abi.rs | 2 +- src/boot.rs | 10 +++++----- src/main.rs | 24 ++++++++++++------------ src/object.rs | 6 +++--- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 6ad6f5c..35cb6f0 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -253,7 +253,7 @@ pub enum ModuleInfoType { EFIMemoryMap = 0x9004, #[cfg(target_arch = "x86_64")] - /// EFI framebuffer metadata (MODINFOMD_EFI_FB) + /// EFI framebuffer modinfo (MODINFOMD_EFI_FB) EFIFrameBuffer = 0x9005, } diff --git a/src/boot.rs b/src/boot.rs index d8d7a93..978d0be 100644 --- a/src/boot.rs +++ b/src/boot.rs @@ -142,8 +142,8 @@ trampoline_size: free_ptr as usize ); - // Serialize some final metadata. Calls exit boot services. - add_efi_metadata(system_table, staging); + // Serialize some final modinfo. Calls exit boot services. + add_efi_modinfo(system_table, staging); let trampoline_func: TrampolineFunction = core::mem::transmute(misc_buf.trampoline.as_ptr()); @@ -157,8 +157,8 @@ trampoline_size: } } - unsafe fn add_efi_metadata(boot_system_table: SystemTable, mut staging: &mut [u8]) { - staging = add_efi_framebuffer_metadata(boot_system_table.boot_services(), staging); + unsafe fn add_efi_modinfo(boot_system_table: SystemTable, mut staging: &mut [u8]) { + staging = add_efi_framebuffer_modinfo(boot_system_table.boot_services(), staging); let (runtime_system_table, memory_map) = boot_system_table.exit_boot_services(MemoryType::LOADER_DATA); @@ -175,7 +175,7 @@ trampoline_size: let _staging = firmware_handle_item.serialize_unaligned(staging); } - fn add_efi_framebuffer_metadata<'a>( + fn add_efi_framebuffer_modinfo<'a>( boot_services: &BootServices, staging: &'a mut [u8], ) -> &'a mut [u8] { diff --git a/src/main.rs b/src/main.rs index 0a5e4bb..cb6b5b1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,7 +46,7 @@ fn main(image_handle: Handle, mut system_table: SystemTable) -> Status { info!("Read kernel"); let kernel = Kernel::from_elf_bytes(&kernel_data); - let mut kernel_metadata = kernel.metadata(); + let mut kernel_modinfo = kernel.modinfo(); let mut environment = Environment(BTreeMap::from([( "kernel".to_string(), @@ -57,21 +57,21 @@ fn main(image_handle: Handle, mut system_table: SystemTable) -> Status { log::debug!("environment: {:?}", environment.0); - // Allocate an extra 1 MiB for items we have to add to metadata, like memory map - let metadata_size: usize = kernel_metadata + // Allocate an extra 1 MiB for items we have to add to modinfo, like memory map + let modinfo_size: usize = kernel_modinfo .iter() - .map(|item| item.alloc_size()) + .map(|item| item.size().next_multiple_of(ModuleInfoItem::alignment())) .sum::() + 1024 * 1024; - let alloc_size = kernel.alloc_size() + environment.alloc_size() + metadata_size; + let alloc_size = kernel.alloc_size() + environment.alloc_size() + modinfo_size; let staging = staging::allocate_code(system_table.boot_services(), alloc_size); let (kernel_base, next) = kernel.serialize_unaligned_base(staging); let (environ_base, next) = environment.serialize_unaligned_base(next); - kernel_metadata.push(abi::ModuleInfoItem { + kernel_modinfo.push(abi::ModuleInfoItem { tag: ModuleInfoType::Environment, value: ModuleInfoValue::Size( (environ_base as usize) @@ -80,25 +80,25 @@ fn main(image_handle: Handle, mut system_table: SystemTable) -> Status { ), }); - kernel_metadata.push(abi::ModuleInfoItem { + kernel_modinfo.push(abi::ModuleInfoItem { tag: ModuleInfoType::Howto, value: ModuleInfoValue::Howto(Howto::VERBOSE | Howto::SERIAL), }); let free_ptr = unsafe { - let base = next.as_ptr().byte_add(metadata_size); + let base = next.as_ptr().byte_add(modinfo_size); let offset = base.align_offset(PAGE_SIZE); base.byte_add(offset) }; - kernel_metadata.push(ModuleInfoItem { + kernel_modinfo.push(ModuleInfoItem { tag: ModuleInfoType::FreeAddress, value: ModuleInfoValue::Pointer(free_ptr), }); - info!("Kernel metadata is {:x?}", kernel_metadata); + info!("Kernel modinfo is {:x?}", kernel_modinfo); - let (modinfo_base, mut next) = kernel_metadata[0].serialize_unaligned_base(next); - for item in kernel_metadata[1..].iter() { + let (modinfo_base, mut next) = kernel_modinfo[0].serialize_unaligned_base(next); + for item in kernel_modinfo[1..].iter() { next = item.serialize_unaligned(next); } diff --git a/src/object.rs b/src/object.rs index 66d7873..7aaaf54 100644 --- a/src/object.rs +++ b/src/object.rs @@ -11,8 +11,8 @@ const NATIVE_ELF_MACHINE: u16 = goblin::elf::header::EM_X86_64; const USIZE_SIZE: usize = core::mem::size_of::(); pub trait Module { - /// Associated metadata for this module, including name and type - fn metadata(&self) -> Vec; + /// Associated modinfo for this module, including name and type + fn modinfo(&self) -> Vec; } pub struct Kernel<'a> { @@ -157,7 +157,7 @@ impl<'a> Serialize for Kernel<'a> { } impl<'a> Module for Kernel<'a> { - fn metadata(&self) -> Vec { + fn modinfo(&self) -> Vec { // FreeBSD would also put constructors here but I haven't managed // to find any kernels or modules with constructors let mut items = alloc::vec![