mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
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:
@@ -8,3 +8,4 @@ crate-type = ["staticlib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rlibc = "*"
|
rlibc = "*"
|
||||||
|
spin = "*"
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
extern crate rlibc;
|
extern crate rlibc;
|
||||||
|
extern crate spin;
|
||||||
|
|
||||||
mod vga_buffer;
|
mod vga_buffer;
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user