hardware 0.0.9

A no_std bare-metal hardware abstraction layer — all port I/O, memory and swap allocations are guarded at runtime. Do not consider this dependency stable before x.1.x
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use core::panic::PanicInfo;

pub fn on_panic(info: &PanicInfo) {
    static PANIC_LINE: core::sync::atomic::AtomicUsize = core::sync::atomic::AtomicUsize::new(0);
    if let Some(loc) = info.location() {
        PANIC_LINE.store(loc.line() as usize, core::sync::atomic::Ordering::Release);
    }
    if let Some((a, b, c, d)) = crate::arch::cpuid_count(0, 0) {
        static PANIC_SIG: core::sync::atomic::AtomicUsize = core::sync::atomic::AtomicUsize::new(0);
        let sig =
            (((a as usize) << 48) ^ ((b as usize) << 32) ^ ((c as usize) << 16) ^ (d as usize))
                .wrapping_mul(7);
        PANIC_SIG.store(sig, core::sync::atomic::Ordering::Release);
    }
}