Commit e089cffc authored by Jeremy Soller's avatar Jeremy Soller

Add specification to vesad

Fix piping
Fix bug where resources are not closed
Add arpd
Remove question_mark features
parent ea592080
#![feature(alloc)] #![feature(alloc)]
#![feature(asm)] #![feature(asm)]
#![feature(heap_api)] #![feature(heap_api)]
#![feature(question_mark)]
extern crate alloc; extern crate alloc;
extern crate orbclient; extern crate orbclient;
extern crate syscall; extern crate syscall;
use std::{env, thread};
use std::fs::File; use std::fs::File;
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::thread;
use syscall::{physmap, physunmap, Packet, Scheme, MAP_WRITE, MAP_WRITE_COMBINE}; use syscall::{physmap, physunmap, Packet, Scheme, MAP_WRITE, MAP_WRITE_COMBINE};
use mode_info::VBEModeInfo; use mode_info::VBEModeInfo;
...@@ -23,6 +22,18 @@ pub mod scheme; ...@@ -23,6 +22,18 @@ pub mod scheme;
pub mod screen; pub mod screen;
fn main() { fn main() {
let mut spec = Vec::new();
for arg in env::args().skip(1) {
if arg == "T" {
spec.push(false);
} else if arg == "G" {
spec.push(true);
} else {
println!("vesad: unknown screen type: {}", arg);
}
}
let width; let width;
let height; let height;
let physbaseptr; let physbaseptr;
...@@ -46,7 +57,7 @@ fn main() { ...@@ -46,7 +57,7 @@ fn main() {
let onscreen = unsafe { physmap(physbaseptr, size * 4, MAP_WRITE | MAP_WRITE_COMBINE).expect("vesad: failed to map VBE LFB") }; let onscreen = unsafe { physmap(physbaseptr, size * 4, MAP_WRITE | MAP_WRITE_COMBINE).expect("vesad: failed to map VBE LFB") };
unsafe { fast_set64(onscreen as *mut u64, 0, size/2) }; unsafe { fast_set64(onscreen as *mut u64, 0, size/2) };
let scheme = DisplayScheme::new(width, height, onscreen); let scheme = DisplayScheme::new(width, height, onscreen, &spec);
let mut blocked = Vec::new(); let mut blocked = Vec::new();
loop { loop {
......
...@@ -13,20 +13,30 @@ pub struct DisplayScheme { ...@@ -13,20 +13,30 @@ pub struct DisplayScheme {
height: usize, height: usize,
onscreen: usize, onscreen: usize,
active: Cell<usize>, active: Cell<usize>,
next_screen: Cell<usize>,
screens: RefCell<BTreeMap<usize, Box<Screen>>> screens: RefCell<BTreeMap<usize, Box<Screen>>>
} }
impl DisplayScheme { impl DisplayScheme {
pub fn new(width: usize, height: usize, onscreen: usize) -> DisplayScheme { pub fn new(width: usize, height: usize, onscreen: usize, spec: &[bool]) -> DisplayScheme {
let mut screens: BTreeMap<usize, Box<Screen>> = BTreeMap::new(); let mut screens: BTreeMap<usize, Box<Screen>> = BTreeMap::new();
screens.insert(1, Box::new(TextScreen::new(Display::new(width, height, onscreen))));
screens.insert(2, Box::new(GraphicScreen::new(Display::new(width, height, onscreen)))); let mut screen_i = 1;
for &screen_type in spec.iter() {
if screen_type {
screens.insert(screen_i, Box::new(GraphicScreen::new(Display::new(width, height, onscreen))));
} else {
screens.insert(screen_i, Box::new(TextScreen::new(Display::new(width, height, onscreen))));
}
screen_i += 1;
}
DisplayScheme { DisplayScheme {
width: width, width: width,
height: height, height: height,
onscreen: onscreen, onscreen: onscreen,
active: Cell::new(1), active: Cell::new(1),
next_screen: Cell::new(screen_i),
screens: RefCell::new(screens) screens: RefCell::new(screens)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment