Skip to content

Commit bd8ad01

Browse files
authored
Merge pull request #77 from phip1611/mb2-magic-num
add multiboot2 magic number
2 parents 87f8b58 + 6f4b9e9 commit bd8ad01

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/header.rs

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ use core::marker::PhantomData;
22
use core::fmt::{Debug, Formatter};
33
use core::cmp::Ordering;
44

5+
/// Magic number that a multiboot2-compliant boot loader will store in `eax` register
6+
/// right before handoff to the payload (the kernel). This value can be used to check,
7+
/// that the kernel was indeed booted via multiboot2.
8+
///
9+
/// Caution: You might need some assembly code (e.g. GAS or NASM) first, which
10+
/// moves `eax` to another register, like `edi`. Otherwise it probably happens,
11+
/// that the Rust compiler output changes `eax` before you can access it.
12+
pub const MB2_MAGIC: u32 = 0x36d76289;
13+
514
/// Possible Types of a [`Tag`]. The names and values are taken from the example C code
615
/// at the bottom of the Multiboot2 specification.
716
#[repr(u32)]

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub use elf_sections::{
1717
};
1818
pub use framebuffer::{FramebufferColor, FramebufferField, FramebufferTag, FramebufferType};
1919
use header::{Tag, TagIter, TagType};
20+
pub use header::MB2_MAGIC;
2021
pub use memory_map::{
2122
EFIMemoryAreaType, EFIMemoryDesc, EFIMemoryMapTag, MemoryArea, MemoryAreaIter, MemoryAreaType,
2223
MemoryMapTag,

0 commit comments

Comments
 (0)