kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

145_baremetal_privileged_aa64.toy (891B)


      1 // aarch64-only: the wait/event and interrupt-mask (DAIF) intrinsics are real
      2 // single instructions but are privileged at EL0 (or stall), so they are
      3 // emitted inside a runtime-false branch — compiled and lowered through CG, but
      4 // never executed by the harness. Gated to aarch64 because wfe/sev and the
      5 // irq_save/irq_restore DAIF pair have no x64/rv64 lowering today.
      6 // @target_arch() is 1 on aarch64; this case only ever compiles for aarch64
      7 // (default host paths), where the guard below is statically false at runtime.
      8 fn __user_main(): i64 {
      9   let arch: i64 = @target_arch();
     10   if arch != 1 {
     11     // Dead at runtime on aarch64, still fully code-generated at -O0.
     12     @wfi();
     13     @wfe();
     14     @sev();
     15     @isb();
     16     @irq_disable();
     17     @irq_enable();
     18     let flags: usize = @irq_save();
     19     @irq_restore(flags);
     20   }
     21   return 42;
     22 }
     23 
     24 fn main(): i32 { return __user_main() as i32; }