Skip to content

Commit 0320148

Browse files
committed
multiboot2: Implement setting the BasicMemoryInfoTag
1 parent bb21998 commit 0320148

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

multiboot2/src/builder/information.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//! Exports item [`Multiboot2InformationBuilder`].
22
use crate::builder::traits::StructAsBytes;
3-
use crate::{BootLoaderNameTag, CommandLineTag, ElfSectionsTag, FramebufferTag, ModuleTag};
3+
use crate::{
4+
BasicMemoryInfoTag, BootLoaderNameTag, CommandLineTag, ElfSectionsTag, FramebufferTag,
5+
ModuleTag,
6+
};
47

58
use alloc::boxed::Box;
69
use alloc::vec::Vec;
@@ -10,6 +13,7 @@ use alloc::vec::Vec;
1013
/// except for the END tag.
1114
#[derive(Debug)]
1215
pub struct Multiboot2InformationBuilder {
16+
basic_memory_info_tag: Option<BasicMemoryInfoTag>,
1317
boot_loader_name_tag: Option<Box<BootLoaderNameTag>>,
1418
command_line_tag: Option<Box<CommandLineTag>>,
1519
elf_sections_tag: Option<Box<ElfSectionsTag>>,
@@ -20,6 +24,7 @@ pub struct Multiboot2InformationBuilder {
2024
impl Multiboot2InformationBuilder {
2125
pub const fn new() -> Self {
2226
Self {
27+
basic_memory_info_tag: None,
2328
boot_loader_name_tag: None,
2429
command_line_tag: None,
2530
elf_sections_tag: None,
@@ -28,6 +33,10 @@ impl Multiboot2InformationBuilder {
2833
}
2934
}
3035

36+
pub fn basic_memory_info_tag(&mut self, basic_memory_info_tag: BasicMemoryInfoTag) {
37+
self.basic_memory_info_tag = Some(basic_memory_info_tag)
38+
}
39+
3140
pub fn bootloader_name_tag(&mut self, boot_loader_name_tag: Box<BootLoaderNameTag>) {
3241
self.boot_loader_name_tag = Some(boot_loader_name_tag);
3342
}

multiboot2/src/memory_map.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
use crate::TagTypeId;
1+
use crate::tag_type::{TagType, TagTypeId};
2+
use core::convert::TryInto;
23
use core::marker::PhantomData;
4+
use core::mem;
35

46
/// This tag provides an initial host memory map.
57
///
@@ -149,6 +151,15 @@ pub struct BasicMemoryInfoTag {
149151
}
150152

151153
impl BasicMemoryInfoTag {
154+
pub fn new(memory_lower: u32, memory_upper: u32) -> Self {
155+
Self {
156+
typ: TagType::BasicMeminfo.into(),
157+
size: mem::size_of::<BasicMemoryInfoTag>().try_into().unwrap(),
158+
memory_lower,
159+
memory_upper,
160+
}
161+
}
162+
152163
pub fn memory_lower(&self) -> u32 {
153164
self.memory_lower
154165
}

0 commit comments

Comments
 (0)