Add volatile crate

This commit is contained in:
greg 2019-07-10 02:27:20 -07:00
parent 0e9bff7bff
commit 65c824e104
2 changed files with 6 additions and 3 deletions

View File

@ -12,4 +12,5 @@ panic = "abort"
[dependencies]
bootloader = "0.6.0"
volatile = "0.2.6"

View File

@ -1,3 +1,5 @@
use volatile::Volatile;
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
@ -42,7 +44,7 @@ const BUFFER_HEIGHT: usize = 25;
#[repr(transparent)]
struct Buffer {
chars: [[ScreenChar; BUFFER_WIDTH]; BUFFER_HEIGHT],
chars: [[Volatile<ScreenChar>; BUFFER_WIDTH]; BUFFER_HEIGHT],
}
pub struct Writer {
@ -71,9 +73,9 @@ impl Writer {
let row = BUFFER_HEIGHT - 1;
let col = self.column_position;
let color_code = self.color_code;
self.buffer.chars[row][col] = ScreenChar {
self.buffer.chars[row][col].write(ScreenChar {
ascii_char: byte, color_code,
};
});
self.column_position += 1;
}
}