#save-file #crash #log #reboot #computer #disk #happened

no-std boot2dump

A library to save a crash log happened in your homebrew OS

1 unstable release

0.0.1 Dec 19, 2021

#11 in #reboot

MIT/Apache

11KB

A library for OS developers to save a kernel crash log happened in your own kernel into a file on disk reboot the computer.

Prerequisites

You kernel needs to satisfy the following prerequisites to use this crate:

  • The CPU is x86_64 and is in the 64-bit mode.
  • The file system is ext4 and its on a virtio-blk device.
  • A sufficiently large file for the crash log (e.g. in the following example, kerla.dump) already exists in the root directory.
  • Virtual addresses starting 0xffff_8000_0000_0000 are straight mapped into from the physical addresses 0 (i.e. 0xffff_8000_0001_0000 points to 0x1_0000). It should cover the memory pages where boot2dump image exist.

How to Use

The usage is pretty simple: at the end of your panic handler, call save_to_file_and_reboot. It will save the given buffer into a file and then reboot the computer.

Example

use boot2dump::save_to_file_and_reboot;

#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
    // Save the panic message into a file. Let's hope `format!` won't panic...
    let message = format!("{}", info).as_bytes();
    save_to_file_and_reboot("kerla.dump",  message.as_bytes());
}

No runtime deps