1
1
#![ no_std]
2
2
#![ deny( missing_debug_implementations) ]
3
- #![ deny( missing_docs) ]
3
+ // --- BEGIN STYLE CHECKS ---
4
+ // These checks are optional in CI for PRs, as discussed in
5
+ // https://github.com/rust-osdev/multiboot2/pull/92
6
+ #![ deny( clippy:: all) ]
7
+ #![ deny( rustdoc:: all) ]
8
+ // Forcing this would be a little bit ridiculous, because it would require code examples for
9
+ // each getter and each trivial trait implementation (like Debug).
10
+ #![ allow( rustdoc:: missing_doc_code_examples) ]
11
+ // --- END STYLE CHECKS ---
4
12
5
13
//! Library that helps you to parse the multiboot information structure (mbi) from
6
14
//! Multiboot2-compliant bootloaders, like GRUB. It supports all tags from the specification
9
17
//!
10
18
//! The GNU Multiboot(2) specification aims to provide a standardised
11
19
//! method of sharing commonly used information about the host machine at
12
- //! boot time and give the payload, i.e. a kernel, a well defined machien
20
+ //! boot time and give the payload, i.e. a kernel, a well defined machine
13
21
//! state.
14
22
//!
15
23
//! ## Example
16
24
//!
17
- //! ```ignore
18
- //! use multiboot ::load;
25
+ //! ```rust
26
+ //! use multiboot2 ::load;
19
27
//! fn kmain(multiboot_info_ptr: u32) {
20
- //! let boot_info = unsafe { load(ptr as usize).unwrap() };
28
+ //! let boot_info = unsafe { load(multiboot_info_ptr as usize).unwrap() };
21
29
//! println!("{:?}", boot_info);
22
30
//! }
23
31
//! ```
@@ -26,23 +34,21 @@ use core::fmt;
26
34
27
35
pub use boot_loader_name:: BootLoaderNameTag ;
28
36
pub use command_line:: CommandLineTag ;
37
+ pub use efi:: { EFIImageHandle32 , EFIImageHandle64 , EFISdt32 , EFISdt64 } ;
29
38
pub use elf_sections:: {
30
39
ElfSection , ElfSectionFlags , ElfSectionIter , ElfSectionType , ElfSectionsTag ,
31
40
} ;
32
41
pub use framebuffer:: { FramebufferColor , FramebufferField , FramebufferTag , FramebufferType } ;
33
42
pub use header:: TagType ;
34
43
pub use header:: MULTIBOOT2_BOOTLOADER_MAGIC ;
35
44
use header:: { Tag , TagIter } ;
45
+ pub use image_load_addr:: ImageLoadPhysAddr ;
36
46
pub use memory_map:: {
37
47
EFIMemoryAreaType , EFIMemoryDesc , EFIMemoryMapTag , MemoryArea , MemoryAreaIter , MemoryAreaType ,
38
48
MemoryMapTag ,
39
49
} ;
40
50
pub use module:: { ModuleIter , ModuleTag } ;
41
- pub use rsdp:: {
42
- RsdpV1Tag , RsdpV2Tag ,
43
- } ;
44
- pub use image_load_addr:: ImageLoadPhysAddr ;
45
- pub use efi:: { EFIImageHandle32 , EFIImageHandle64 , EFISdt32 , EFISdt64 } ;
51
+ pub use rsdp:: { RsdpV1Tag , RsdpV2Tag } ;
46
52
pub use vbe_info:: {
47
53
VBECapabilities , VBEControlInfo , VBEDirectColorAttributes , VBEField , VBEInfoTag ,
48
54
VBEMemoryModel , VBEModeAttributes , VBEModeInfo , VBEWindowAttributes ,
@@ -53,46 +59,56 @@ extern crate bitflags;
53
59
54
60
mod boot_loader_name;
55
61
mod command_line;
62
+ mod efi;
56
63
mod elf_sections;
57
64
mod framebuffer;
58
65
mod header;
66
+ mod image_load_addr;
59
67
mod memory_map;
60
68
mod module;
61
69
mod rsdp;
62
70
mod vbe_info;
63
- mod efi;
64
- mod image_load_addr;
65
71
66
72
/// Load the multiboot boot information struct from an address.
67
73
///
68
74
/// This is the same as `load_with_offset` but the offset is omitted and set
69
75
/// to zero.
70
76
///
71
- /// Examples
77
+ /// ## Example
72
78
///
73
- /// ```ignore
74
- /// use multiboot ::load;
79
+ /// ```rust
80
+ /// use multiboot2 ::load;
75
81
///
76
82
/// fn kmain(multiboot_info_ptr: u32) {
77
- /// let boot_info = unsafe { load(ptr as usize).unwrap() };
83
+ /// let boot_info = unsafe { load(multiboot_info_ptr as usize).unwrap() };
78
84
/// println!("{:?}", boot_info);
79
85
/// }
80
86
/// ```
87
+ ///
88
+ /// ## Safety
89
+ /// This function might terminate the program, if the address is invalid. This can be the case in
90
+ /// environments with standard environment (segfault) but also in UEFI-applications,
91
+ /// where the referenced memory is not (identity) mapped (UEFI does only identity mapping).
81
92
pub unsafe fn load ( address : usize ) -> Result < BootInformation , MbiLoadError > {
82
93
load_with_offset ( address, 0 )
83
94
}
84
95
85
96
/// Load the multiboot boot information struct from an address at an offset.
86
97
///
87
- /// Examples
98
+ /// ## Example
88
99
///
89
100
/// ```ignore
90
- /// use multiboot ::load_with_offset;
101
+ /// use multiboot2 ::load_with_offset;
91
102
///
92
- /// let ptr = 0xDEADBEEF as *const _ ;
103
+ /// let ptr = 0xDEADBEEF as *const u32 ;
93
104
/// let boot_info = unsafe { load_with_offset(ptr as usize, 0xCAFEBABE).unwrap() };
94
105
/// println!("{:?}", boot_info);
95
106
/// ```
107
+ ///
108
+ /// ## Safety
109
+ /// This function might terminate the program, if the address is invalid. This can be the case in
110
+ /// environments with standard environment (segfault) but also in UEFI-applications,
111
+ /// where the referenced memory is not (identity) mapped (UEFI does only identity mapping).
96
112
pub unsafe fn load_with_offset (
97
113
address : usize ,
98
114
offset : usize ,
0 commit comments