Commit 2593c252 authored by Jeremy Soller's avatar Jeremy Soller

Add support for BGA mode setting (WIP)

parent fe65978a
[package]
name = "bgad"
version = "0.1.0"
[dependencies]
redox_syscall = "0.1"
use syscall::io::{Io, Pio};
const BGA_INDEX_XRES: u16 = 1;
const BGA_INDEX_YRES: u16 = 2;
const BGA_INDEX_BPP: u16 = 3;
const BGA_INDEX_ENABLE: u16 = 4;
pub struct Bga {
index: Pio<u16>,
data: Pio<u16>,
}
impl Bga {
pub fn new() -> Bga {
Bga {
index: Pio::new(0x1CE),
data: Pio::new(0x1CF),
}
}
fn read(&mut self, index: u16) -> u16 {
self.index.write(index);
self.data.read()
}
fn write(&mut self, index: u16, data: u16) {
self.index.write(index);
self.data.write(data);
}
pub fn width(&mut self) -> u16 {
self.read(BGA_INDEX_XRES)
}
pub fn height(&mut self) -> u16 {
self.read(BGA_INDEX_YRES)
}
#[allow(dead_code)]
pub fn set_size(&mut self, width: u16, height: u16) {
self.write(BGA_INDEX_ENABLE, 0);
self.write(BGA_INDEX_XRES, width);
self.write(BGA_INDEX_YRES, height);
self.write(BGA_INDEX_BPP, 32);
self.write(BGA_INDEX_ENABLE, 0x41);
}
}
#![deny(warnings)]
extern crate syscall;
use std::env;
use syscall::iopl;
use bga::Bga;
mod bga;
fn main() {
let mut args = env::args().skip(1);
......@@ -12,4 +19,12 @@ fn main() {
let bar = usize::from_str_radix(&bar_str, 16).expect("bgad: failed to parse address");
print!("{}", format!(" + BGA {} on: {:X}\n", name, bar));
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
unsafe { iopl(3).unwrap() };
let mut bga = Bga::new();
print!("{}", format!(" - BGA {}x{}", bga.width(), bga.height()));
}
}
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