Add a public static writer

Since `unsafe const` aren't allowed yet, we temorary add a custom version of Unique to make `Unique::new` const (instead of unsafe).
This commit is contained in:
Philipp Oppermann
2015-09-24 15:52:33 +02:00
parent ab464b107d
commit 4668acb09e
3 changed files with 9 additions and 0 deletions

View File

@@ -8,3 +8,4 @@ crate-type = ["staticlib"]
[dependencies] [dependencies]
rlibc = "*" rlibc = "*"
spin = "*"

View File

@@ -17,6 +17,7 @@
#![no_std] #![no_std]
extern crate rlibc; extern crate rlibc;
extern crate spin;
mod vga_buffer; mod vga_buffer;

View File

@@ -1,8 +1,15 @@
use core::ptr::Unique; use core::ptr::Unique;
use spin::Mutex;
const BUFFER_HEIGHT: usize = 25; const BUFFER_HEIGHT: usize = 25;
const BUFFER_WIDTH: usize = 80; const BUFFER_WIDTH: usize = 80;
pub static WRITER: Mutex<Writer> = Mutex::new(Writer {
column_position: 0,
color_code: ColorCode::new(Color::LightGreen, Color::Black),
buffer: unsafe{Unique::new(0xb8000 as *mut _)},
});
#[repr(u8)] #[repr(u8)]
pub enum Color { pub enum Color {
Black = 0, Black = 0,