summaryrefslogtreecommitdiff
path: root/tools/rust/src/lib.rs
blob: a578b91ac065f4606470822399b5aee2b12e0e2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: MIT
#![no_std]
#![deny(unsafe_op_in_unsafe_fn)]
#![feature(alloc_error_handler)]
#![feature(mixed_integer_ops)]
#![feature(new_uninit)]

#[macro_use]
extern crate alloc;

pub mod chainload;
pub mod dlmalloc;
pub mod gpt;
pub mod nvme;
pub mod print;

use crate::dlmalloc::DLMalloc;

#[global_allocator]
static GLOBAL: DLMalloc = dlmalloc::DLMalloc;

extern "C" {
    fn flush_and_reboot();
}

#[panic_handler]
fn panic(info: &::core::panic::PanicInfo) -> ! {
    println!("{}", info);
    unsafe { flush_and_reboot() };
    loop {}
}

#[alloc_error_handler]
fn alloc_error(layout: core::alloc::Layout) -> ! {
    panic!("memory allocation of {} bytes failed", layout.size())
}