rust-kernel
Rustbelt: a hobby x86_64 kernel written in Rust
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | //! The entry point. QEMU loads our ELF file (see link.ld) and starts CPU 0
//! at `_start`, with the MMU off, at EL1 (or EL2 with `-M virt,virtualization=on`,
//! the way real boards and firmware usually hand over).
//!
//! What `_start` does, in assembly because there's no stack yet:
//!
//! 1. Any CPU but CPU 0 parks (QEMU's virt keeps the others off anyway;
//! the Pi 3's firmware spins them, so this matters there).
//! 2. At EL2: make EL1 a 64-bit level (`HCR_EL2.RW`), let it use the
//! timer (`CNTHCTL_EL2`), give it a safe `SCTLR_EL1`, then `eret` down
//! to EL1 with interrupts masked.
//! 3. Set the stack pointer (`__stack_top` from link.ld), clear `.bss`
//! (Rust expects zero-initialised statics), allow FP/SIMD
//! (`CPACR_EL1.FPEN`; our code doesn't use it, but compiler_builtins
//! could), and call `kmain(dtb, boot_el)`.
global_asm!;
|