11#![ no_std]
22#![ 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 ---
412
513//! Library that helps you to parse the multiboot information structure (mbi) from
614//! Multiboot2-compliant bootloaders, like GRUB. It supports all tags from the specification
917//!
1018//! The GNU Multiboot(2) specification aims to provide a standardised
1119//! 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
1321//! state.
1422//!
1523//! ## Example
1624//!
17- //! ```ignore
18- //! use multiboot ::load;
25+ //! ```rust
26+ //! use multiboot2 ::load;
1927//! 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() };
2129//! println!("{:?}", boot_info);
2230//! }
2331//! ```
@@ -26,23 +34,21 @@ use core::fmt;
2634
2735pub use boot_loader_name:: BootLoaderNameTag ;
2836pub use command_line:: CommandLineTag ;
37+ pub use efi:: { EFIImageHandle32 , EFIImageHandle64 , EFISdt32 , EFISdt64 } ;
2938pub use elf_sections:: {
3039 ElfSection , ElfSectionFlags , ElfSectionIter , ElfSectionType , ElfSectionsTag ,
3140} ;
3241pub use framebuffer:: { FramebufferColor , FramebufferField , FramebufferTag , FramebufferType } ;
3342pub use header:: TagType ;
3443pub use header:: MULTIBOOT2_BOOTLOADER_MAGIC ;
3544use header:: { Tag , TagIter } ;
45+ pub use image_load_addr:: ImageLoadPhysAddr ;
3646pub use memory_map:: {
3747 EFIMemoryAreaType , EFIMemoryDesc , EFIMemoryMapTag , MemoryArea , MemoryAreaIter , MemoryAreaType ,
3848 MemoryMapTag ,
3949} ;
4050pub 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 } ;
4652pub use vbe_info:: {
4753 VBECapabilities , VBEControlInfo , VBEDirectColorAttributes , VBEField , VBEInfoTag ,
4854 VBEMemoryModel , VBEModeAttributes , VBEModeInfo , VBEWindowAttributes ,
@@ -53,46 +59,56 @@ extern crate bitflags;
5359
5460mod boot_loader_name;
5561mod command_line;
62+ mod efi;
5663mod elf_sections;
5764mod framebuffer;
5865mod header;
66+ mod image_load_addr;
5967mod memory_map;
6068mod module;
6169mod rsdp;
6270mod vbe_info;
63- mod efi;
64- mod image_load_addr;
6571
6672/// Load the multiboot boot information struct from an address.
6773///
6874/// This is the same as `load_with_offset` but the offset is omitted and set
6975/// to zero.
7076///
71- /// Examples
77+ /// ## Example
7278///
73- /// ```ignore
74- /// use multiboot ::load;
79+ /// ```rust
80+ /// use multiboot2 ::load;
7581///
7682/// 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() };
7884/// println!("{:?}", boot_info);
7985/// }
8086/// ```
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).
8192pub unsafe fn load ( address : usize ) -> Result < BootInformation , MbiLoadError > {
8293 load_with_offset ( address, 0 )
8394}
8495
8596/// Load the multiboot boot information struct from an address at an offset.
8697///
87- /// Examples
98+ /// ## Example
8899///
89100/// ```ignore
90- /// use multiboot ::load_with_offset;
101+ /// use multiboot2 ::load_with_offset;
91102///
92- /// let ptr = 0xDEADBEEF as *const _ ;
103+ /// let ptr = 0xDEADBEEF as *const u32 ;
93104/// let boot_info = unsafe { load_with_offset(ptr as usize, 0xCAFEBABE).unwrap() };
94105/// println!("{:?}", boot_info);
95106/// ```
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).
96112pub unsafe fn load_with_offset (
97113 address : usize ,
98114 offset : usize ,
0 commit comments