Skip to content

Commit c044e26

Browse files
committed
dedicated module file for EFI-related MBI tags
1 parent e05d805 commit c044e26

File tree

3 files changed

+59
-51
lines changed

3 files changed

+59
-51
lines changed

src/efi.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//! All MBI tags related to (U)EFI.
2+
3+
use crate::TagType;
4+
5+
/// EFI system table in 32 bit mode
6+
#[derive(Clone, Copy, Debug)]
7+
#[repr(C, packed)] // only repr(C) would add unwanted padding before first_section
8+
pub struct EFISdt32 {
9+
typ: TagType,
10+
size: u32,
11+
pointer: u32,
12+
}
13+
14+
impl EFISdt32 {
15+
/// The Physical address of a i386 EFI system table.
16+
pub fn sdt_address(&self) -> usize {
17+
self.pointer as usize
18+
}
19+
}
20+
21+
/// EFI system table in 64 bit mode
22+
#[derive(Clone, Copy, Debug)]
23+
#[repr(C)]
24+
pub struct EFISdt64 {
25+
typ: TagType,
26+
size: u32,
27+
pointer: u64,
28+
}
29+
30+
impl EFISdt64 {
31+
/// The Physical address of a x86_64 EFI system table.
32+
pub fn sdt_address(&self) -> usize {
33+
self.pointer as usize
34+
}
35+
}
36+
37+
/// Contains pointer to boot loader image handle.
38+
#[derive(Debug)]
39+
#[repr(C)]
40+
pub struct EFIImageHandle32 {
41+
typ: TagType,
42+
size: u32,
43+
pointer: u32,
44+
}
45+
46+
/// Contains pointer to boot loader image handle.
47+
#[derive(Debug)]
48+
#[repr(C)]
49+
pub struct EFIImageHandle64 {
50+
typ: TagType,
51+
size: u32,
52+
pointer: u64,
53+
}

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ pub use memory_map::{
3939
};
4040
pub use module::{ModuleIter, ModuleTag};
4141
pub use rsdp::{
42-
EFIImageHandle32, EFIImageHandle64, EFISdt32, EFISdt64, ImageLoadPhysAddr, RsdpV1Tag, RsdpV2Tag,
42+
ImageLoadPhysAddr, RsdpV1Tag, RsdpV2Tag,
4343
};
44+
pub use efi::{EFIImageHandle32, EFIImageHandle64, EFISdt32, EFISdt64};
4445
pub use vbe_info::{
4546
VBECapabilities, VBEControlInfo, VBEDirectColorAttributes, VBEField, VBEInfoTag,
4647
VBEMemoryModel, VBEModeAttributes, VBEModeInfo, VBEWindowAttributes,
@@ -58,6 +59,7 @@ mod memory_map;
5859
mod module;
5960
mod rsdp;
6061
mod vbe_info;
62+
mod efi;
6163

6264
/// Load the multiboot boot information struct from an address.
6365
///

src/rsdp.rs

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Module for RSDP/ACPI. RSDP (Root System Description Pointer) is a data structure used in the
2+
//! ACPI programming interface.
3+
//!
14
//! The tag that the bootloader passes will depend on the ACPI version the hardware supports.
25
//! For ACPI Version 1.0, a `RsdpV1Tag` will be provided, which can be accessed from
36
//! `BootInformation` using the `rsdp_v1_tag` function. For subsequent versions of ACPI, a
@@ -11,56 +14,6 @@ use crate::TagType;
1114

1215
const RSDPV1_LENGTH: usize = 20;
1316

14-
/// EFI system table in 32 bit mode
15-
#[derive(Clone, Copy, Debug)]
16-
#[repr(C, packed)] // only repr(C) would add unwanted padding before first_section
17-
pub struct EFISdt32 {
18-
typ: TagType,
19-
size: u32,
20-
pointer: u32,
21-
}
22-
23-
impl EFISdt32 {
24-
/// The Physical address of a i386 EFI system table.
25-
pub fn sdt_address(&self) -> usize {
26-
self.pointer as usize
27-
}
28-
}
29-
30-
/// EFI system table in 64 bit mode
31-
#[derive(Clone, Copy, Debug)]
32-
#[repr(C)]
33-
pub struct EFISdt64 {
34-
typ: TagType,
35-
size: u32,
36-
pointer: u64,
37-
}
38-
39-
impl EFISdt64 {
40-
/// The Physical address of a x86_64 EFI system table.
41-
pub fn sdt_address(&self) -> usize {
42-
self.pointer as usize
43-
}
44-
}
45-
46-
/// Contains pointer to boot loader image handle.
47-
#[derive(Debug)]
48-
#[repr(C)]
49-
pub struct EFIImageHandle32 {
50-
typ: TagType,
51-
size: u32,
52-
pointer: u32,
53-
}
54-
55-
/// Contains pointer to boot loader image handle.
56-
#[derive(Debug)]
57-
#[repr(C)]
58-
pub struct EFIImageHandle64 {
59-
typ: TagType,
60-
size: u32,
61-
pointer: u64,
62-
}
63-
6417
/// If the image has relocatable header tag, this tag contains the image's
6518
/// base physical address.
6619
#[derive(Debug)]

0 commit comments

Comments
 (0)