#mode #real #load #kernel #x86-64 #tiny #boot

realjump

Tiny crate that loads and boots Real Mode code from an x86-64 kernel

2 unstable releases

0.2.0 Mar 28, 2022
0.1.0 Sep 14, 2021

#831 in Unix APIs

MIT license

10KB
198 lines

realjump

Build

realjump is a tiny #![no_std] crate that loads and boots Real Mode code (MBR, GRUB2, etc.) from your x86-64 kernel. It puts the system from Long Mode back to Real Mode and jumps to the code.

But why?

It's mostly useful for quickly getting back to Linux from your OS because the boot process can be very slow on server hardware, and you are too lazy to implement some kexec-like functionality in your kernel.

Usage

  1. Disable interrupts.
  2. Identity map the first 1MiB of memory as executable.
  3. Halt all other processors.
  4. Call realjump::boot(your_mbr_slice, 0x7c00).unwrap().
  5. realjump will take care of the rest. It will load its own GDT and take the system all the way back to Real Mode.

INT 13h

Certain BIOS services, like INT 13h, may no longer function when you return to Real Mode. For GRUB2, you can work around this by loading the core.img directly with realjump::boot_grub2.

No runtime deps