call it modinfo, not metadata
This commit is contained in:
parent
bb00fbba80
commit
2a4c87c6b1
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
10
src/boot.rs
10
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<Boot>, mut staging: &mut [u8]) {
|
||||
staging = add_efi_framebuffer_metadata(boot_system_table.boot_services(), staging);
|
||||
unsafe fn add_efi_modinfo(boot_system_table: SystemTable<Boot>, 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] {
|
||||
|
|
24
src/main.rs
24
src/main.rs
|
@ -46,7 +46,7 @@ fn main(image_handle: Handle, mut system_table: SystemTable<Boot>) -> 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<Boot>) -> 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::<usize>()
|
||||
+ 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<Boot>) -> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ const NATIVE_ELF_MACHINE: u16 = goblin::elf::header::EM_X86_64;
|
|||
const USIZE_SIZE: usize = core::mem::size_of::<usize>();
|
||||
|
||||
pub trait Module {
|
||||
/// Associated metadata for this module, including name and type
|
||||
fn metadata(&self) -> Vec<ModuleInfoItem>;
|
||||
/// Associated modinfo for this module, including name and type
|
||||
fn modinfo(&self) -> Vec<ModuleInfoItem>;
|
||||
}
|
||||
|
||||
pub struct Kernel<'a> {
|
||||
|
@ -157,7 +157,7 @@ impl<'a> Serialize for Kernel<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Module for Kernel<'a> {
|
||||
fn metadata(&self) -> Vec<ModuleInfoItem> {
|
||||
fn modinfo(&self) -> Vec<ModuleInfoItem> {
|
||||
// FreeBSD would also put constructors here but I haven't managed
|
||||
// to find any kernels or modules with constructors
|
||||
let mut items = alloc::vec![
|
||||
|
|
Loading…
Reference in a new issue