multiboot/lib.rs
1//! Multiboot v1 library
2//!
3//! The main structs to interact with are [`Multiboot`] for the Multiboot information
4//! passed from the bootloader to the kernel at runtime and [`Header`] for the static
5//! information passed from the kernel to the bootloader in the kernel image.
6//!
7//!
8//!
9//! # Additional documentation
10//! * https://www.gnu.org/software/grub/manual/multiboot/multiboot.html
11//! * http://git.savannah.gnu.org/cgit/grub.git/tree/doc/multiboot.texi?h=multiboot
12//!
13//! [`Multiboot`]: information/struct.Multiboot.html
14//! [`Header`]: header/struct.Header.html
15
16#![no_std]
17#![crate_name = "multiboot"]
18#![crate_type = "lib"]
19
20macro_rules! round_up {
21 ($num:expr, $s:expr) => {
22 (($num + $s - 1) / $s) * $s
23 };
24}
25
26macro_rules! flag {
27 ($doc:meta, $fun:ident, $bit:expr) => {
28 #[$doc]
29 pub fn $fun(&self) -> bool {
30 //assert!($bit <= 31);
31 (self.header.flags & (1 << $bit)) > 0
32 }
33
34 paste::paste! {
35 #[$doc]
36 pub fn [< set_ $fun >] (&mut self, flag: bool) {
37 //assert!($bit <= 31);
38 self.header.flags = if flag {
39 self.header.flags | (1 << $bit)
40 } else {
41 self.header.flags & !(1 << $bit)
42 };
43 }
44 }
45 };
46}
47
48pub mod header;
49pub mod information;
50
51#[cfg(doctest)]
52mod test_readme {
53 macro_rules! external_doc_test {
54 ($x:expr) => {
55 #[doc = $x]
56 extern "C" {}
57 };
58 }
59
60 external_doc_test!(include_str!("../README.md"));
61}