Skip to content

Commit 6b3589d

Browse files
committed
multiboot2: Support setting Boot Services not exited tag
1 parent 0b9edbd commit 6b3589d

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

multiboot2/src/builder/information.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
use crate::builder::traits::StructAsBytes;
33
use crate::{
44
BasicMemoryInfoTag, BootInformationInner, BootLoaderNameTag, CommandLineTag,
5-
EFISdt32, EFISdt64, EFIMemoryMapTag, ElfSectionsTag, EndTag, FramebufferTag,
6-
MemoryMapTag, ModuleTag, RsdpV1Tag, RsdpV2Tag, SmbiosTag,
5+
EFISdt32, EFISdt64, EFIBootServicesNotExited, EFIMemoryMapTag,
6+
ElfSectionsTag, EndTag, FramebufferTag, MemoryMapTag, ModuleTag, RsdpV1Tag,
7+
RsdpV2Tag, SmbiosTag,
78
};
89

910
use alloc::boxed::Box;
@@ -18,6 +19,7 @@ pub struct Multiboot2InformationBuilder {
1819
basic_memory_info_tag: Option<BasicMemoryInfoTag>,
1920
boot_loader_name_tag: Option<Box<BootLoaderNameTag>>,
2021
command_line_tag: Option<Box<CommandLineTag>>,
22+
efi_boot_services_not_exited: Option<EFIBootServicesNotExited>,
2123
efi_memory_map_tag: Option<Box<EFIMemoryMapTag>>,
2224
elf_sections_tag: Option<Box<ElfSectionsTag>>,
2325
framebuffer_tag: Option<Box<FramebufferTag>>,
@@ -38,6 +40,7 @@ impl Multiboot2InformationBuilder {
3840
command_line_tag: None,
3941
efisdt32: None,
4042
efisdt64: None,
43+
efi_boot_services_not_exited: None,
4144
efi_memory_map_tag: None,
4245
elf_sections_tag: None,
4346
framebuffer_tag: None,
@@ -85,6 +88,9 @@ impl Multiboot2InformationBuilder {
8588
if let Some(tag) = &self.efisdt64 {
8689
len += Self::size_or_up_aligned(tag.byte_size())
8790
}
91+
if let Some(tag) = &self.efi_boot_services_not_exited {
92+
len += Self::size_or_up_aligned(tag.byte_size())
93+
}
8894
if let Some(tag) = &self.efi_memory_map_tag {
8995
len += Self::size_or_up_aligned(tag.byte_size())
9096
}
@@ -156,6 +162,9 @@ impl Multiboot2InformationBuilder {
156162
if let Some(tag) = self.efisdt64.as_ref() {
157163
Self::build_add_bytes(&mut data, &tag.struct_as_bytes(), false)
158164
}
165+
if let Some(tag) = self.efi_boot_services_not_exited.as_ref() {
166+
Self::build_add_bytes(&mut data, &tag.struct_as_bytes(), false)
167+
}
159168
if let Some(tag) = self.efi_memory_map_tag.as_ref() {
160169
Self::build_add_bytes(&mut data, &tag.struct_as_bytes(), false)
161170
}
@@ -206,6 +215,10 @@ impl Multiboot2InformationBuilder {
206215
self.efisdt64 = Some(efisdt64);
207216
}
208217

218+
pub fn efi_boot_services_not_exited(&mut self) {
219+
self.efi_boot_services_not_exited = Some(EFIBootServicesNotExited::new());
220+
}
221+
209222
pub fn efi_memory_map_tag(&mut self, efi_memory_map_tag: Box<EFIMemoryMapTag>) {
210223
self.efi_memory_map_tag = Some(efi_memory_map_tag);
211224
}

multiboot2/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ pub use elf_sections::{
5555
pub use framebuffer::{FramebufferColor, FramebufferField, FramebufferTag, FramebufferType};
5656
pub use image_load_addr::ImageLoadPhysAddr;
5757
pub use memory_map::{
58-
BasicMemoryInfoTag, EFIMemoryAreaType, EFIMemoryDesc, EFIMemoryMapTag,
59-
MemoryArea, MemoryAreaIter, MemoryAreaType, MemoryMapTag,
58+
BasicMemoryInfoTag, EFIBootServicesNotExited, EFIMemoryAreaType,
59+
EFIMemoryDesc, EFIMemoryMapTag, MemoryArea, MemoryAreaIter, MemoryAreaType,
60+
MemoryMapTag,
6061
};
6162
pub use module::{ModuleIter, ModuleTag};
6263
pub use rsdp::{RsdpV1Tag, RsdpV2Tag};

multiboot2/src/memory_map.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,27 @@ impl Default for EFIMemoryDesc {
480480
#[derive(Debug)]
481481
#[repr(C)]
482482
pub struct EFIBootServicesNotExited {
483-
typ: u32,
483+
typ: TagType,
484484
size: u32,
485485
}
486486

487+
impl EFIBootServicesNotExited {
488+
#[cfg(feature = "builder")]
489+
pub fn new() -> Self {
490+
Self {
491+
typ: TagType::EfiBs,
492+
size: mem::size_of::<Self>().try_into().unwrap(),
493+
}
494+
}
495+
}
496+
497+
#[cfg(feature = "builder")]
498+
impl StructAsBytes for EFIBootServicesNotExited {
499+
fn byte_size(&self) -> usize {
500+
mem::size_of::<Self>()
501+
}
502+
}
503+
487504
/// An iterator over ALL EFI memory areas.
488505
#[derive(Clone, Debug)]
489506
pub struct EFIMemoryAreaIter<'a> {

0 commit comments

Comments
 (0)