Skip to content

Commit 90a7ac7

Browse files
committed
multiboot2: streamlined tag getters
1 parent 4e40c9b commit 90a7ac7

File tree

2 files changed

+46
-42
lines changed

2 files changed

+46
-42
lines changed

multiboot2/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- dependency updates
66
- **Breaking:** MSRV is now 1.75
7-
- Added missing tags:
7+
- Added missing tags along with getters for on `BootInformation`:
88
- `ApmTag`
99
- `BootdevTag`
1010
- `NetworkTag`

multiboot2/src/boot_information.rs

+45-41
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
use crate::framebuffer::UnknownFramebufferType;
44
use crate::tag::TagHeader;
55
use crate::{
6-
module, BasicMemoryInfoTag, BootLoaderNameTag, CommandLineTag, EFIBootServicesNotExitedTag,
7-
EFIImageHandle32Tag, EFIImageHandle64Tag, EFIMemoryMapTag, EFISdt32Tag, EFISdt64Tag,
8-
ElfSectionIter, ElfSectionsTag, EndTag, FramebufferTag, ImageLoadPhysAddrTag, MemoryMapTag,
9-
ModuleIter, RsdpV1Tag, RsdpV2Tag, SmbiosTag, TagIter, TagType, VBEInfoTag,
6+
module, ApmTag, BasicMemoryInfoTag, BootLoaderNameTag, BootdevTag, CommandLineTag,
7+
EFIBootServicesNotExitedTag, EFIImageHandle32Tag, EFIImageHandle64Tag, EFIMemoryMapTag,
8+
EFISdt32Tag, EFISdt64Tag, ElfSectionIter, ElfSectionsTag, EndTag, FramebufferTag,
9+
ImageLoadPhysAddrTag, MemoryMapTag, ModuleIter, NetworkTag, RsdpV1Tag, RsdpV2Tag, SmbiosTag,
10+
TagIter, TagType, VBEInfoTag,
1011
};
1112
#[cfg(feature = "unstable")]
1213
use core::error::Error;
@@ -165,44 +166,46 @@ impl<'a> BootInformation<'a> {
165166
// ######################################################
166167
// ### BEGIN OF TAG GETTERS (in alphabetical order)
167168

168-
/*fn apm(&self) {
169-
// also add to debug output
170-
todo!()
171-
}*/
169+
/// Search for the [`ApmTag`].
170+
#[must_use]
171+
pub fn apm_tag(&self) -> Option<&ApmTag> {
172+
self.get_tag::<ApmTag>()
173+
}
172174

173-
/// Search for the basic memory info tag.
175+
/// Search for the [`BasicMemoryInfoTag`].
174176
#[must_use]
175177
pub fn basic_memory_info_tag(&self) -> Option<&BasicMemoryInfoTag> {
176178
self.get_tag::<BasicMemoryInfoTag>()
177179
}
178180

179-
/// Search for the BootLoader name tag.
181+
/// Search for the [`BootLoaderNameTag`].
180182
#[must_use]
181183
pub fn boot_loader_name_tag(&self) -> Option<&BootLoaderNameTag> {
182184
self.get_tag::<BootLoaderNameTag>()
183185
}
184186

185-
/*fn bootdev(&self) {
186-
// also add to debug output
187-
todo!()
188-
}*/
187+
/// Search for the [`BootdevTag`].
188+
#[must_use]
189+
pub fn bootdev_tag(&self) -> Option<&BootdevTag> {
190+
self.get_tag::<BootdevTag>()
191+
}
189192

190-
/// Search for the Command line tag.
193+
/// Search for the [`CommandLineTag`].
191194
#[must_use]
192195
pub fn command_line_tag(&self) -> Option<&CommandLineTag> {
193196
self.get_tag::<CommandLineTag>()
194197
}
195198

196-
/// Search for the EFI boot services not exited tag.
199+
/// Search for the [`EFIBootServicesNotExitedTag`].
197200
#[must_use]
198201
pub fn efi_bs_not_exited_tag(&self) -> Option<&EFIBootServicesNotExitedTag> {
199202
self.get_tag::<EFIBootServicesNotExitedTag>()
200203
}
201204

202-
/// Search for the EFI Memory map tag, if the boot services were exited.
205+
/// Search for the [`EFIMemoryMapTag`], if the boot services were exited.
203206
/// Otherwise, if the [`TagType::EfiBs`] tag is present, this returns `None`
204-
/// as it is strictly recommended to get the memory map from the `uefi`
205-
/// services.
207+
/// as it is strictly recommended to get the memory map from `uefi`
208+
/// instead.
206209
///
207210
/// [`TagType::EfiBs`]: crate::TagType::EfiBs
208211
#[must_use]
@@ -216,25 +219,25 @@ impl<'a> BootInformation<'a> {
216219
})
217220
}
218221

219-
/// Search for the EFI 32-bit SDT tag.
222+
/// Search for the [`EFISdt32Tag`].
220223
#[must_use]
221224
pub fn efi_sdt32_tag(&self) -> Option<&EFISdt32Tag> {
222225
self.get_tag::<EFISdt32Tag>()
223226
}
224227

225-
/// Search for the EFI 64-bit SDT tag.
228+
/// Search for the [`EFISdt64Tag`].
226229
#[must_use]
227230
pub fn efi_sdt64_tag(&self) -> Option<&EFISdt64Tag> {
228231
self.get_tag::<EFISdt64Tag>()
229232
}
230233

231-
/// Search for the EFI 32-bit image handle pointer tag.
234+
/// Search for the [`EFIImageHandle32Tag`].
232235
#[must_use]
233236
pub fn efi_ih32_tag(&self) -> Option<&EFIImageHandle32Tag> {
234237
self.get_tag::<EFIImageHandle32Tag>()
235238
}
236239

237-
/// Search for the EFI 64-bit image handle pointer tag.
240+
/// Search for the [`EFIImageHandle64Tag`].
238241
#[must_use]
239242
pub fn efi_ih64_tag(&self) -> Option<&EFIImageHandle64Tag> {
240243
self.get_tag::<EFIImageHandle64Tag>()
@@ -266,61 +269,62 @@ impl<'a> BootInformation<'a> {
266269
})
267270
}
268271

269-
/// Search for the VBE framebuffer tag. The result is `Some(Err(e))`, if the
272+
/// Search for the [`FramebufferTag`]. The result is `Some(Err(e))`, if the
270273
/// framebuffer type is unknown, while the framebuffer tag is present.
271274
#[must_use]
272275
pub fn framebuffer_tag(&self) -> Option<Result<&FramebufferTag, UnknownFramebufferType>> {
273276
self.get_tag::<FramebufferTag>()
274-
// TODO temporarily. Someone needs to fix the framebuffer thingy.
275-
.map(Ok)
276-
/*.map(|tag| match tag.buffer_type() {
277-
Ok(_) => Ok(tag),
278-
Err(e) => Err(e),
279-
})*/
277+
.map(|tag| match tag.buffer_type() {
278+
Ok(_) => Ok(tag),
279+
Err(e) => Err(e),
280+
})
280281
}
281282

282-
/// Search for the Image Load Base Physical Address tag.
283+
/// Search for the [`ImageLoadPhysAddrTag`].
283284
#[must_use]
284285
pub fn load_base_addr_tag(&self) -> Option<&ImageLoadPhysAddrTag> {
285286
self.get_tag::<ImageLoadPhysAddrTag>()
286287
}
287288

288-
/// Search for the Memory map tag.
289+
/// Search for the [`MemoryMapTag`].
289290
#[must_use]
290291
pub fn memory_map_tag(&self) -> Option<&MemoryMapTag> {
291292
self.get_tag::<MemoryMapTag>()
292293
}
293294

294-
/// Get an iterator of all module tags.
295+
/// Get an iterator of all [`ModuleTag`]s.
296+
///
297+
/// [`ModuleTag`]: crate::ModuleTag
295298
#[must_use]
296299
pub fn module_tags(&self) -> ModuleIter {
297300
module::module_iter(self.tags())
298301
}
299302

300-
/*fn network_tag(&self) {
301-
// also add to debug output
302-
todo!()
303-
}*/
303+
/// Search for the [`NetworkTag`].
304+
#[must_use]
305+
pub fn network_tag(&self) -> Option<&NetworkTag> {
306+
self.get_tag::<NetworkTag>()
307+
}
304308

305-
/// Search for the (ACPI 1.0) RSDP tag.
309+
/// Search for the [`RsdpV1Tag`].
306310
#[must_use]
307311
pub fn rsdp_v1_tag(&self) -> Option<&RsdpV1Tag> {
308312
self.get_tag::<RsdpV1Tag>()
309313
}
310314

311-
/// Search for the (ACPI 2.0 or later) RSDP tag.
315+
/// Search for the [`RsdpV2Tag`].
312316
#[must_use]
313317
pub fn rsdp_v2_tag(&self) -> Option<&RsdpV2Tag> {
314318
self.get_tag::<RsdpV2Tag>()
315319
}
316320

317-
/// Search for the SMBIOS tag.
321+
/// Search for the [`SmbiosTag`].
318322
#[must_use]
319323
pub fn smbios_tag(&self) -> Option<&SmbiosTag> {
320324
self.get_tag::<SmbiosTag>()
321325
}
322326

323-
/// Search for the VBE information tag.
327+
/// Search for the [`VBEInfoTag`].
324328
#[must_use]
325329
pub fn vbe_info_tag(&self) -> Option<&VBEInfoTag> {
326330
self.get_tag::<VBEInfoTag>()

0 commit comments

Comments
 (0)