Skip to content

Commit 4bf969f

Browse files
committed
multiboot2: Add BasicMemoryInfoTag
1 parent 2d0add1 commit 4bf969f

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

multiboot2/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ pub use elf_sections::{
5252
pub use framebuffer::{FramebufferColor, FramebufferField, FramebufferTag, FramebufferType};
5353
pub use image_load_addr::ImageLoadPhysAddr;
5454
pub use memory_map::{
55-
EFIMemoryAreaType, EFIMemoryDesc, EFIMemoryMapTag, MemoryArea, MemoryAreaIter, MemoryAreaType,
56-
MemoryMapTag,
55+
BasicMemoryInfoTag, EFIMemoryAreaType, EFIMemoryDesc, EFIMemoryMapTag, MemoryArea,
56+
MemoryAreaIter, MemoryAreaType, MemoryMapTag,
5757
};
5858
pub use module::{ModuleIter, ModuleTag};
5959
pub use rsdp::{RsdpV1Tag, RsdpV2Tag};
@@ -218,6 +218,11 @@ impl BootInformation {
218218
self.get().total_size as usize
219219
}
220220

221+
/// Search for the basic memory info tag.
222+
pub fn basic_memory_info_tag(&self) -> Option<&BasicMemoryInfoTag> {
223+
self.get_tag::<BasicMemoryInfoTag, _>(TagType::BasicMeminfo)
224+
}
225+
221226
/// Search for the ELF Sections tag.
222227
pub fn elf_sections_tag(&self) -> Option<ElfSectionsTag> {
223228
self.get_tag::<Tag, _>(TagType::ElfSections)

multiboot2/src/memory_map.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,41 @@ impl<'a> Iterator for MemoryAreaIter<'a> {
123123
}
124124
}
125125

126+
/// Basic memory info
127+
///
128+
/// This tag includes "basic memory information".
129+
/// This means (legacy) lower and upper memory:
130+
/// In Real Mode (modeled after the 8086),
131+
/// only the first 1MB of memory is accessible.
132+
/// Typically, the region between 640KB and 1MB is not freely usable,
133+
/// because it is used for memory-mapped IO, for instance.
134+
/// The term “lower memory” refers to those first 640KB of memory that are
135+
/// freely usable for an application in Real Mode.
136+
/// “Upper memory” then refers to the next freely usable chunk of memory,
137+
/// starting at 1MB up to about 10MB, in practice.
138+
/// This is the memory an application running on a 286
139+
/// (which had a 24-bit address bus) could use, historically.
140+
/// Nowadays, much bigger chunks of continuous memory are available at higher
141+
/// addresses, but the Multiboot standard still references those two terms.
142+
#[derive(Debug)]
143+
#[repr(C, packed)]
144+
pub struct BasicMemoryInfoTag {
145+
typ: TagTypeId,
146+
size: u32,
147+
memory_lower: u32,
148+
memory_upper: u32,
149+
}
150+
151+
impl BasicMemoryInfoTag {
152+
pub fn memory_lower(&self) -> u32 {
153+
self.memory_lower
154+
}
155+
156+
pub fn memory_upper(&self) -> u32 {
157+
self.memory_upper
158+
}
159+
}
160+
126161
/// EFI memory map as per EFI specification.
127162
#[derive(Debug)]
128163
#[repr(C)]

0 commit comments

Comments
 (0)