Skip to content

Commit 12f4642

Browse files
committed
multiboot2: Support setting Boot Services not exited tag
1 parent 690c84a commit 12f4642

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

multiboot2/src/builder/information.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Exports item [`Multiboot2InformationBuilder`].
22
use crate::builder::traits::StructAsBytes;
33
use crate::{
4-
BasicMemoryInfoTag, BootInformationInner, BootLoaderNameTag, CommandLineTag, EFIMemoryMapTag,
5-
EFISdt32, EFISdt64, ElfSectionsTag, EndTag, FramebufferTag, MemoryMapTag, ModuleTag, RsdpV1Tag,
6-
RsdpV2Tag, SmbiosTag,
4+
BasicMemoryInfoTag, BootInformationInner, BootLoaderNameTag, CommandLineTag,
5+
EFIBootServicesNotExited, EFIMemoryMapTag, EFISdt32, EFISdt64, ElfSectionsTag, EndTag,
6+
FramebufferTag, MemoryMapTag, ModuleTag, RsdpV1Tag, RsdpV2Tag, SmbiosTag,
77
};
88

99
use alloc::boxed::Box;
@@ -18,6 +18,7 @@ pub struct Multiboot2InformationBuilder {
1818
basic_memory_info_tag: Option<BasicMemoryInfoTag>,
1919
boot_loader_name_tag: Option<Box<BootLoaderNameTag>>,
2020
command_line_tag: Option<Box<CommandLineTag>>,
21+
efi_boot_services_not_exited: Option<EFIBootServicesNotExited>,
2122
efi_memory_map_tag: Option<Box<EFIMemoryMapTag>>,
2223
elf_sections_tag: Option<Box<ElfSectionsTag>>,
2324
framebuffer_tag: Option<Box<FramebufferTag>>,
@@ -38,6 +39,7 @@ impl Multiboot2InformationBuilder {
3839
command_line_tag: None,
3940
efisdt32: None,
4041
efisdt64: None,
42+
efi_boot_services_not_exited: None,
4143
efi_memory_map_tag: None,
4244
elf_sections_tag: None,
4345
framebuffer_tag: None,
@@ -85,6 +87,9 @@ impl Multiboot2InformationBuilder {
8587
if let Some(tag) = &self.efisdt64 {
8688
len += Self::size_or_up_aligned(tag.byte_size())
8789
}
90+
if let Some(tag) = &self.efi_boot_services_not_exited {
91+
len += Self::size_or_up_aligned(tag.byte_size())
92+
}
8893
if let Some(tag) = &self.efi_memory_map_tag {
8994
len += Self::size_or_up_aligned(tag.byte_size())
9095
}
@@ -154,6 +159,9 @@ impl Multiboot2InformationBuilder {
154159
if let Some(tag) = self.efisdt64.as_ref() {
155160
Self::build_add_bytes(&mut data, &tag.struct_as_bytes(), false)
156161
}
162+
if let Some(tag) = self.efi_boot_services_not_exited.as_ref() {
163+
Self::build_add_bytes(&mut data, &tag.struct_as_bytes(), false)
164+
}
157165
if let Some(tag) = self.efi_memory_map_tag.as_ref() {
158166
Self::build_add_bytes(&mut data, &tag.struct_as_bytes(), false)
159167
}
@@ -204,6 +212,10 @@ impl Multiboot2InformationBuilder {
204212
self.efisdt64 = Some(efisdt64);
205213
}
206214

215+
pub fn efi_boot_services_not_exited(&mut self) {
216+
self.efi_boot_services_not_exited = Some(EFIBootServicesNotExited::new());
217+
}
218+
207219
pub fn efi_memory_map_tag(&mut self, efi_memory_map_tag: Box<EFIMemoryMapTag>) {
208220
self.efi_memory_map_tag = Some(efi_memory_map_tag);
209221
}

multiboot2/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ pub use elf_sections::{
5757
pub use framebuffer::{FramebufferColor, FramebufferField, FramebufferTag, FramebufferType};
5858
pub use image_load_addr::ImageLoadPhysAddr;
5959
pub use memory_map::{
60-
BasicMemoryInfoTag, EFIMemoryAreaType, EFIMemoryDesc, EFIMemoryMapTag, MemoryArea,
61-
MemoryAreaIter, MemoryAreaType, MemoryMapTag,
60+
BasicMemoryInfoTag, EFIBootServicesNotExited, EFIMemoryAreaType, EFIMemoryDesc,
61+
EFIMemoryMapTag, MemoryArea, MemoryAreaIter, MemoryAreaType, MemoryMapTag,
6262
};
6363
pub use module::{ModuleIter, ModuleTag};
6464
pub use rsdp::{RsdpV1Tag, RsdpV2Tag};

multiboot2/src/memory_map.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,34 @@ impl Default for EFIMemoryDesc {
449449
#[derive(Debug)]
450450
#[repr(C)]
451451
pub struct EFIBootServicesNotExited {
452-
typ: u32,
452+
typ: TagTypeId,
453453
size: u32,
454454
}
455455

456+
impl EFIBootServicesNotExited {
457+
#[cfg(feature = "builder")]
458+
pub fn new() -> Self {
459+
Self::default()
460+
}
461+
}
462+
463+
#[cfg(feature = "builder")]
464+
impl Default for EFIBootServicesNotExited {
465+
fn default() -> Self {
466+
Self {
467+
typ: TagType::EfiBs.into(),
468+
size: mem::size_of::<Self>().try_into().unwrap(),
469+
}
470+
}
471+
}
472+
473+
#[cfg(feature = "builder")]
474+
impl StructAsBytes for EFIBootServicesNotExited {
475+
fn byte_size(&self) -> usize {
476+
mem::size_of::<Self>()
477+
}
478+
}
479+
456480
/// An iterator over ALL EFI memory areas.
457481
#[derive(Clone, Debug)]
458482
pub struct EFIMemoryAreaIter<'a> {

0 commit comments

Comments
 (0)