Skip to content

Commit 3020b6a

Browse files
authored
Merge pull request #151 from rust-osdev/dev3
multiboot2: more tag name streamlining
2 parents ade1ddd + 33157e5 commit 3020b6a

File tree

8 files changed

+60
-51
lines changed

8 files changed

+60
-51
lines changed

multiboot2/Changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
- **BREAKING** Renamed `ImageLoadPhysAddr` to `ImageLoadPhysAddrTag`
2323
- **BREAKING** Renamed `EFIImageHandle32` to `EFIImageHandle32Tag`
2424
- **BREAKING** Renamed `EFIImageHandle64` to `EFIImageHandle64Tag`
25+
- **BREAKING** Renamed `EFISdt32` to `EFISdt32Tag`
26+
- **BREAKING** Renamed `EFISdt64` to `EFISdt64Tag`
27+
- **BREAKING** Renamed `EFIBootServicesNotExited` to `EFIBootServicesNotExitedTag`
28+
- added `BootInformation::efi_bs_not_exited_tag`
2529

2630
## 0.15.1 (2023-03-18)
2731
- **BREAKING** `MemoryMapTag::all_memory_areas()` was renamed to `memory_areas`

multiboot2/src/builder/information.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
use crate::builder::traits::StructAsBytes;
33
use crate::{
44
BasicMemoryInfoTag, BootInformationInner, BootLoaderNameTag, CommandLineTag,
5-
EFIBootServicesNotExited, EFIImageHandle32Tag, EFIImageHandle64Tag, EFIMemoryMapTag, EFISdt32,
6-
EFISdt64, ElfSectionsTag, EndTag, FramebufferTag, ImageLoadPhysAddrTag, MemoryMapTag,
7-
ModuleTag, RsdpV1Tag, RsdpV2Tag, SmbiosTag,
5+
EFIBootServicesNotExitedTag, EFIImageHandle32Tag, EFIImageHandle64Tag, EFIMemoryMapTag,
6+
EFISdt32Tag, EFISdt64Tag, ElfSectionsTag, EndTag, FramebufferTag, ImageLoadPhysAddrTag,
7+
MemoryMapTag, ModuleTag, RsdpV1Tag, RsdpV2Tag, SmbiosTag,
88
};
99

1010
use alloc::boxed::Box;
@@ -19,7 +19,7 @@ pub struct InformationBuilder {
1919
basic_memory_info_tag: Option<BasicMemoryInfoTag>,
2020
boot_loader_name_tag: Option<Box<BootLoaderNameTag>>,
2121
command_line_tag: Option<Box<CommandLineTag>>,
22-
efi_boot_services_not_exited: Option<EFIBootServicesNotExited>,
22+
efi_boot_services_not_exited: Option<EFIBootServicesNotExitedTag>,
2323
efi_image_handle32: Option<EFIImageHandle32Tag>,
2424
efi_image_handle64: Option<EFIImageHandle64Tag>,
2525
efi_memory_map_tag: Option<Box<EFIMemoryMapTag>>,
@@ -28,8 +28,8 @@ pub struct InformationBuilder {
2828
image_load_addr: Option<ImageLoadPhysAddrTag>,
2929
memory_map_tag: Option<Box<MemoryMapTag>>,
3030
module_tags: Vec<Box<ModuleTag>>,
31-
efisdt32: Option<EFISdt32>,
32-
efisdt64: Option<EFISdt64>,
31+
efisdt32: Option<EFISdt32Tag>,
32+
efisdt64: Option<EFISdt64Tag>,
3333
rsdp_v1_tag: Option<RsdpV1Tag>,
3434
rsdp_v2_tag: Option<RsdpV2Tag>,
3535
smbios_tags: Vec<Box<SmbiosTag>>,
@@ -229,16 +229,16 @@ impl InformationBuilder {
229229
self.command_line_tag = Some(command_line_tag);
230230
}
231231

232-
pub fn efisdt32(&mut self, efisdt32: EFISdt32) {
232+
pub fn efisdt32(&mut self, efisdt32: EFISdt32Tag) {
233233
self.efisdt32 = Some(efisdt32);
234234
}
235235

236-
pub fn efisdt64(&mut self, efisdt64: EFISdt64) {
236+
pub fn efisdt64(&mut self, efisdt64: EFISdt64Tag) {
237237
self.efisdt64 = Some(efisdt64);
238238
}
239239

240240
pub fn efi_boot_services_not_exited(&mut self) {
241-
self.efi_boot_services_not_exited = Some(EFIBootServicesNotExited::new());
241+
self.efi_boot_services_not_exited = Some(EFIBootServicesNotExitedTag::new());
242242
}
243243

244244
pub fn efi_image_handle32(&mut self, efi_image_handle32: EFIImageHandle32Tag) {

multiboot2/src/efi.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ use core::mem::size_of;
88
#[cfg(feature = "builder")]
99
use crate::builder::traits::StructAsBytes;
1010

11-
/// EFI system table in 32 bit mode
11+
/// EFI system table in 32 bit mode tag.
1212
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1313
#[repr(C)]
14-
pub struct EFISdt32 {
14+
pub struct EFISdt32Tag {
1515
typ: TagTypeId,
1616
size: u32,
1717
pointer: u32,
1818
}
1919

20-
impl EFISdt32 {
20+
impl EFISdt32Tag {
2121
/// Create a new tag to pass the EFI32 System Table pointer.
2222
pub fn new(pointer: u32) -> Self {
2323
Self {
@@ -34,22 +34,22 @@ impl EFISdt32 {
3434
}
3535

3636
#[cfg(feature = "builder")]
37-
impl StructAsBytes for EFISdt32 {
37+
impl StructAsBytes for EFISdt32Tag {
3838
fn byte_size(&self) -> usize {
3939
size_of::<Self>()
4040
}
4141
}
4242

43-
/// EFI system table in 64 bit mode
43+
/// EFI system table in 64 bit mode tag.
4444
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
4545
#[repr(C)]
46-
pub struct EFISdt64 {
46+
pub struct EFISdt64Tag {
4747
typ: TagTypeId,
4848
size: u32,
4949
pointer: u64,
5050
}
5151

52-
impl EFISdt64 {
52+
impl EFISdt64Tag {
5353
/// Create a new tag to pass the EFI64 System Table pointer.
5454
pub fn new(pointer: u64) -> Self {
5555
Self {
@@ -66,7 +66,7 @@ impl EFISdt64 {
6666
}
6767

6868
#[cfg(feature = "builder")]
69-
impl StructAsBytes for EFISdt64 {
69+
impl StructAsBytes for EFISdt64Tag {
7070
fn byte_size(&self) -> usize {
7171
size_of::<Self>()
7272
}
@@ -140,19 +140,19 @@ impl StructAsBytes for EFIImageHandle64Tag {
140140

141141
#[cfg(all(test, feature = "builder"))]
142142
mod tests {
143-
use super::{EFIImageHandle32Tag, EFIImageHandle64Tag, EFISdt32, EFISdt64};
143+
use super::{EFIImageHandle32Tag, EFIImageHandle64Tag, EFISdt32Tag, EFISdt64Tag};
144144

145145
const ADDR: usize = 0xABCDEF;
146146

147147
#[test]
148148
fn test_build_eftsdt32() {
149-
let tag = EFISdt32::new(ADDR.try_into().unwrap());
149+
let tag = EFISdt32Tag::new(ADDR.try_into().unwrap());
150150
assert_eq!(tag.sdt_address(), ADDR);
151151
}
152152

153153
#[test]
154154
fn test_build_eftsdt64() {
155-
let tag = EFISdt64::new(ADDR.try_into().unwrap());
155+
let tag = EFISdt64Tag::new(ADDR.try_into().unwrap());
156156
assert_eq!(tag.sdt_address(), ADDR);
157157
}
158158

multiboot2/src/framebuffer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const METADATA_SIZE: usize = size_of::<TagTypeId>()
5050
+ size_of::<u16>()
5151
+ 2 * size_of::<u8>();
5252

53-
/// The VBE Framebuffer information Tag.
53+
/// The VBE Framebuffer information tag.
5454
#[derive(ptr_meta::Pointee, Eq)]
5555
#[repr(C)]
5656
pub struct FramebufferTag {

multiboot2/src/image_load_addr.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use {
55
core::mem::size_of,
66
};
77

8-
/// If the image has relocatable header tag, this tag contains the image's
9-
/// base physical address.
8+
/// The physical load address tag. Typically, this is only available if the
9+
/// binary was relocated, for example if the relocatable header tag was
10+
/// specified.
1011
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1112
#[repr(C)]
1213
pub struct ImageLoadPhysAddrTag {

multiboot2/src/lib.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ pub use boot_loader_name::BootLoaderNameTag;
5050
#[cfg(feature = "builder")]
5151
use builder::traits::StructAsBytes;
5252
pub use command_line::CommandLineTag;
53-
pub use efi::{EFIImageHandle32Tag, EFIImageHandle64Tag, EFISdt32, EFISdt64};
53+
pub use efi::{EFIImageHandle32Tag, EFIImageHandle64Tag, EFISdt32Tag, EFISdt64Tag};
5454
pub use elf_sections::{
5555
ElfSection, ElfSectionFlags, ElfSectionIter, ElfSectionType, ElfSectionsTag,
5656
};
5757
pub use framebuffer::{FramebufferColor, FramebufferField, FramebufferTag, FramebufferType};
5858
pub use image_load_addr::ImageLoadPhysAddrTag;
5959
pub use memory_map::{
60-
BasicMemoryInfoTag, EFIBootServicesNotExited, EFIMemoryAreaType, EFIMemoryDesc,
60+
BasicMemoryInfoTag, EFIBootServicesNotExitedTag, EFIMemoryAreaType, EFIMemoryDesc,
6161
EFIMemoryMapTag, MemoryArea, MemoryAreaType, MemoryMapTag,
6262
};
6363
pub use module::{ModuleIter, ModuleTag};
@@ -303,13 +303,13 @@ impl BootInformation {
303303
}
304304

305305
/// Search for the EFI 32-bit SDT tag.
306-
pub fn efi_sdt_32_tag(&self) -> Option<&EFISdt32> {
307-
self.get_tag::<EFISdt32, _>(TagType::Efi32)
306+
pub fn efi_sdt_32_tag(&self) -> Option<&EFISdt32Tag> {
307+
self.get_tag::<EFISdt32Tag, _>(TagType::Efi32)
308308
}
309309

310310
/// Search for the EFI 64-bit SDT tag.
311-
pub fn efi_sdt_64_tag(&self) -> Option<&EFISdt64> {
312-
self.get_tag::<EFISdt64, _>(TagType::Efi64)
311+
pub fn efi_sdt_64_tag(&self) -> Option<&EFISdt64Tag> {
312+
self.get_tag::<EFISdt64Tag, _>(TagType::Efi64)
313313
}
314314

315315
/// Search for the (ACPI 1.0) RSDP tag.
@@ -345,6 +345,11 @@ impl BootInformation {
345345
self.get_tag::<EFIImageHandle64Tag, _>(TagType::Efi64Ih)
346346
}
347347

348+
/// Search for the EFI boot services not exited tag.
349+
pub fn efi_bs_not_exited_tag(&self) -> Option<&EFIBootServicesNotExitedTag> {
350+
self.get_tag::<EFIBootServicesNotExitedTag, _>(TagType::EfiBs)
351+
}
352+
348353
/// Search for the Image Load Base Physical Address tag.
349354
pub fn load_base_addr_tag(&self) -> Option<&ImageLoadPhysAddrTag> {
350355
self.get_tag::<ImageLoadPhysAddrTag, _>(TagType::LoadBaseAddr)

multiboot2/src/memory_map.rs

+18-20
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use {crate::builder::boxed_dst_tag, crate::builder::traits::StructAsBytes, alloc
1212

1313
const METADATA_SIZE: usize = mem::size_of::<TagTypeId>() + 3 * mem::size_of::<u32>();
1414

15-
/// This tag provides an initial host memory map.
15+
/// This tag provides an initial host memory map (legacy boot, not UEFI).
1616
///
1717
/// The map provided is guaranteed to list all standard RAM that should be
1818
/// available for normal use. This type however includes the regions occupied
@@ -151,20 +151,18 @@ pub enum MemoryAreaType {
151151
Defective = 5,
152152
}
153153

154-
/// Basic memory info
154+
/// Basic memory info tag.
155+
///
156+
/// This tag includes "basic memory information". This means (legacy) lower and
157+
/// upper memory: In Real Mode (modeled after the 8086), only the first 1MB of
158+
/// memory is accessible. Typically, the region between 640KB and 1MB is not
159+
/// freely usable, because it is used for memory-mapped IO, for instance. The
160+
/// term “lower memory” refers to those first 640KB of memory that are freely
161+
/// usable for an application in Real Mode. “Upper memory” then refers to the
162+
/// next freely usable chunk of memory, starting at 1MB up to about 10MB, in
163+
/// practice. This is the memory an application running on a 286 (which had a
164+
/// 24-bit address bus) could use, historically.
155165
///
156-
/// This tag includes "basic memory information".
157-
/// This means (legacy) lower and upper memory:
158-
/// In Real Mode (modeled after the 8086),
159-
/// only the first 1MB of memory is accessible.
160-
/// Typically, the region between 640KB and 1MB is not freely usable,
161-
/// because it is used for memory-mapped IO, for instance.
162-
/// The term “lower memory” refers to those first 640KB of memory that are
163-
/// freely usable for an application in Real Mode.
164-
/// “Upper memory” then refers to the next freely usable chunk of memory,
165-
/// starting at 1MB up to about 10MB, in practice.
166-
/// This is the memory an application running on a 286
167-
/// (which had a 24-bit address bus) could use, historically.
168166
/// Nowadays, much bigger chunks of continuous memory are available at higher
169167
/// addresses, but the Multiboot standard still references those two terms.
170168
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -204,7 +202,7 @@ impl StructAsBytes for BasicMemoryInfoTag {
204202

205203
const EFI_METADATA_SIZE: usize = mem::size_of::<TagTypeId>() + 3 * mem::size_of::<u32>();
206204

207-
/// EFI memory map as per EFI specification.
205+
/// EFI memory map tag. The [`EFIMemoryDesc`] follows the EFI specification.
208206
#[derive(ptr_meta::Pointee, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
209207
#[repr(C)]
210208
pub struct EFIMemoryMapTag {
@@ -274,23 +272,23 @@ impl StructAsBytes for EFIMemoryDesc {
274272
}
275273
}
276274

277-
/// EFI ExitBootServices was not called
275+
/// EFI ExitBootServices was not called tag.
278276
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
279277
#[repr(C)]
280-
pub struct EFIBootServicesNotExited {
278+
pub struct EFIBootServicesNotExitedTag {
281279
typ: TagTypeId,
282280
size: u32,
283281
}
284282

285-
impl EFIBootServicesNotExited {
283+
impl EFIBootServicesNotExitedTag {
286284
#[cfg(feature = "builder")]
287285
pub fn new() -> Self {
288286
Self::default()
289287
}
290288
}
291289

292290
#[cfg(feature = "builder")]
293-
impl Default for EFIBootServicesNotExited {
291+
impl Default for EFIBootServicesNotExitedTag {
294292
fn default() -> Self {
295293
Self {
296294
typ: TagType::EfiBs.into(),
@@ -300,7 +298,7 @@ impl Default for EFIBootServicesNotExited {
300298
}
301299

302300
#[cfg(feature = "builder")]
303-
impl StructAsBytes for EFIBootServicesNotExited {
301+
impl StructAsBytes for EFIBootServicesNotExitedTag {
304302
fn byte_size(&self) -> usize {
305303
mem::size_of::<Self>()
306304
}

multiboot2/src/module.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ use {
1212

1313
const METADATA_SIZE: usize = size_of::<TagTypeId>() + 3 * size_of::<u32>();
1414

15-
/// This tag indicates to the kernel what boot module was loaded along with
16-
/// the kernel image, and where it can be found.
15+
/// The module tag can occur multiple times and specifies passed boot modules
16+
/// (blobs in memory). The tag itself doesn't include the blog, but references
17+
/// its location.
1718
#[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
1819
#[repr(C)]
1920
pub struct ModuleTag {

0 commit comments

Comments
 (0)