summaryrefslogtreecommitdiffstats
path: root/bins/boom/src/main.rs
blob: 0c3201b8d6eedbb5408dc15f02daac0e2db3c54b (plain) (blame)
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
//! boom — crash-containment probe (ADR 0006 Phase 2 gate).
//!
//! Deliberately faults on an unmapped address.  The kernel must kill only
//! this task; the shell survives and `jobs` shows the corpse.

#![no_std]
#![no_main]

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
    loop {
        core::hint::spin_loop();
    }
}

/// The image entry point — the loader jumps here with the ABI arguments.
#[unsafe(no_mangle)]
pub extern "C" fn efi_main(
    _exports: &'static rsapi::Exports,
    _argc: usize,
    _argv: *const rsapi::Arg,
) -> i32 {
    // Canonical-but-unmapped address (below 2^47, above any RAM/MMIO):
    // the page walk terminates at a not-present entry → #PF with
    // CR2 = address.  Same trick as the built-in `fault` command.
    unsafe {
        let p = 0x4000_0000_0000usize as *mut u64;
        p.write_volatile(0xDEAD_BEEF);
    }
    0
}