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(asm)]
#![feature(heap_api)]
#![feature(question_mark)]
extern crate alloc;
extern crate orbclient;
extern crate syscall;
use std::{env, thread};
use std::fs::File;
use std::io::{Read, Write};
use std::thread;
use syscall::{physmap, physunmap, Packet, Scheme, MAP_WRITE, MAP_WRITE_COMBINE};
use mode_info::VBEModeInfo;
......@@ -23,6 +22,18 @@ pub mod scheme;
pub mod screen;
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 height;
let physbaseptr;
......@@ -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") };
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();
loop {
......
......@@ -13,20 +13,30 @@ pub struct DisplayScheme {
height: usize,
onscreen: usize,
active: Cell<usize>,
next_screen: Cell<usize>,
screens: RefCell<BTreeMap<usize, Box<Screen>>>
}
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();
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 {
width: width,
height: height,
onscreen: onscreen,
active: Cell::new(1),
next_screen: Cell::new(screen_i),
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