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 68 69 70 71 | //! A minimal freestanding x86_64 kernel.
//!
//! Boot flow: BIOS -> `bootloader` crate (switches to 64-bit long mode, sets up
//! paging) -> `_start` below. There is no OS underneath us, so no `std`, no
//! `main`, and no heap. Everything we print goes straight to hardware.
// don't link the Rust standard library (it needs an OS)
// no normal `main`: the bootloader jumps to `_start`
// COM1 serial port -> shows up in your terminal via `-serial stdio`
// 80x25 VGA text mode screen at physical address 0xb8000
// The bootloader is linked in by `cargo bootimage`, not called from our code;
// this line just tells Rust/cargo the dependency is intentional.
extern crate bootloader;
use PanicInfo;
/// Kernel entry point. The bootloader calls this after setting up the CPU.
/// `no_mangle` keeps the symbol name `_start` so the linker can find it.
pub extern "C" !
/// Called on `panic!`. Print the message to both outputs, then stop.
!
/// Sleep the CPU until the next interrupt, forever (cheaper than `loop {}`).
!
/// Exit codes for QEMU's `isa-debug-exit` device. QEMU exits with
/// status `(value << 1) | 1`, so Success = 0x10 -> shell exit code 33.
/// Write to I/O port 0xf4 (where we put `isa-debug-exit`) to quit QEMU.
|