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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | //! VGA text mode driver.
//!
//! In text mode the screen is a 25x80 grid of 2-byte cells memory-mapped at
//! physical address 0xb8000: byte 0 = ASCII char, byte 1 = colour attribute
//! (low nibble foreground, high nibble background).
//! The bootloader identity-maps that address, so we can write to it directly.
use fmt;
use lazy_static;
use Mutex;
use Volatile;
/// Foreground + background packed into one attribute byte.
;
/// One on-screen cell. `repr(C)` guarantees the char-then-colour layout.
const BUFFER_HEIGHT: usize = 25;
const BUFFER_WIDTH: usize = 80;
/// The whole screen. `Volatile` tells the compiler these writes have side
/// effects (they change what's on the monitor) so it must not drop them.
/// Always writes on the bottom row and scrolls everything up on newline.
/// Lets us use Rust's formatting machinery (`write!`, `{}`) with the Writer.
lazy_static!
/// Draw " uptime: N s " right-aligned on the top row (row 0), in a different
/// colour. The normal Writer only writes the bottom row and scrolls up, so if
/// text scrolls over this, the next update simply redraws it. Called from the
/// timer interrupt handler (interrupts already off), so taking the lock is safe.
/// `print!` for the VGA screen.
/// `println!` for the VGA screen.
|