From 65c824e10470457c91a8f16866b529d158912d88 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 10 Jul 2019 02:27:20 -0700 Subject: [PATCH] Add volatile crate --- Cargo.toml | 1 + src/vga_buffer.rs | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aef2c8f..730999c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,5 @@ panic = "abort" [dependencies] bootloader = "0.6.0" +volatile = "0.2.6" diff --git a/src/vga_buffer.rs b/src/vga_buffer.rs index 34227e2..c34f01c 100644 --- a/src/vga_buffer.rs +++ b/src/vga_buffer.rs @@ -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; 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; } }