simple ioctl for fb is reachable

master
PanQL 6 years ago
parent 7cf8b5d52f
commit 3b6d94efae

10
kernel/Cargo.lock generated

@ -88,7 +88,7 @@ source = "git+https://github.com/myrrlyn/bitvec.git#8ab20a3e33fe068fc3a4a05eda12
[[package]] [[package]]
name = "bootloader" name = "bootloader"
version = "0.4.0" version = "0.4.0"
source = "git+https://github.com/rcore-os/bootloader?branch=linear#cc33d7d2d2d33f5adcbd0f596964ba99127b51af" source = "git+https://github.com/rcore-os/bootloader?branch=vga#472731f974eb9cddbee030d5bda11fd1ee6959db"
dependencies = [ dependencies = [
"apic 0.1.0 (git+https://github.com/rcore-os/apic-rs)", "apic 0.1.0 (git+https://github.com/rcore-os/apic-rs)",
"fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -378,7 +378,7 @@ dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)", "bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)",
"bitvec 0.11.0 (git+https://github.com/myrrlyn/bitvec.git)", "bitvec 0.11.0 (git+https://github.com/myrrlyn/bitvec.git)",
"bootloader 0.4.0 (git+https://github.com/rcore-os/bootloader?branch=linear)", "bootloader 0.4.0 (git+https://github.com/rcore-os/bootloader?branch=vga)",
"buddy_system_allocator 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "buddy_system_allocator 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)",
"console-traits 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "console-traits 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -693,11 +693,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)" = "<none>" "checksum bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)" = "<none>"
"checksum bitvec 0.11.0 (git+https://github.com/myrrlyn/bitvec.git)" = "<none>" "checksum bitvec 0.11.0 (git+https://github.com/myrrlyn/bitvec.git)" = "<none>"
"checksum bitvec 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cfadef5c4e2c2e64067b9ecc061179f12ac7ec65ba613b1f60f3972bbada1f5b" "checksum bitvec 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cfadef5c4e2c2e64067b9ecc061179f12ac7ec65ba613b1f60f3972bbada1f5b"
"checksum bootloader 0.4.0 (git+https://github.com/rcore-os/bootloader?branch=linear)" = "<none>" "checksum bootloader 0.4.0 (git+https://github.com/rcore-os/bootloader?branch=vga)" = "<none>"
"checksum buddy_system_allocator 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "59da15ef556589ee78370281d75b67f2d69ed26465ec0e0f3961e2021502426f" "checksum buddy_system_allocator 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "59da15ef556589ee78370281d75b67f2d69ed26465ec0e0f3961e2021502426f"
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
"checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427"
"checksum cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ce8bb087aacff865633f0bd5aeaed910fe2fe55b55f4739527f2e023a2e53d" "checksum cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a0c56216487bb80eec9c4516337b2588a4f2a2290d72a1416d930e4dcdb0c90d"
"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4"
"checksum console-traits 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f711b3d1d5c3f7ae7d6428901c0f3e5d5f5c800fcfac86bf0252e96373a2cec6" "checksum console-traits 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f711b3d1d5c3f7ae7d6428901c0f3e5d5f5c800fcfac86bf0252e96373a2cec6"
"checksum deque 0.3.2 (git+https://github.com/rcore-os/deque.git?branch=no_std)" = "<none>" "checksum deque 0.3.2 (git+https://github.com/rcore-os/deque.git?branch=no_std)" = "<none>"
@ -762,7 +762,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
"checksum x86 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "841e1ca5a87068718a2a26f2473c6f93cf3b8119f9778fa0ae4b39b664d9e66a" "checksum x86 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "841e1ca5a87068718a2a26f2473c6f93cf3b8119f9778fa0ae4b39b664d9e66a"
"checksum x86_64 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f9258d7e2dd25008d69e8c9e9ee37865887a5e1e3d06a62f1cb3f6c209e6f177" "checksum x86_64 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f9258d7e2dd25008d69e8c9e9ee37865887a5e1e3d06a62f1cb3f6c209e6f177"
"checksum x86_64 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0a8201f52d2c7b373c7243dcdfb27c0dd5012f221ef6a126f507ee82005204" "checksum x86_64 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bb8f09c32a991cc758ebcb9b7984f530095d32578a4e7b85db6ee1f0bbe4c9c6"
"checksum x86_64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d69bf2d256c74df90fcc68aaf99862dd205310609e9d56247a5c82ead2f28a93" "checksum x86_64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d69bf2d256c74df90fcc68aaf99862dd205310609e9d56247a5c82ead2f28a93"
"checksum xmas-elf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "22678df5df766e8d1e5d609da69f0c3132d794edf6ab5e75e7abcd2270d4cf58" "checksum xmas-elf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "22678df5df766e8d1e5d609da69f0c3132d794edf6ab5e75e7abcd2270d4cf58"
"checksum zero 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f1bc8a6b2005884962297587045002d8cfb8dcec9db332f4ca216ddc5de82c5" "checksum zero 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f1bc8a6b2005884962297587045002d8cfb8dcec9db332f4ca216ddc5de82c5"

@ -68,7 +68,7 @@ rcore-fs = { git = "https://github.com/rcore-os/rcore-fs" }
rcore-fs-sfs = { git = "https://github.com/rcore-os/rcore-fs" } rcore-fs-sfs = { git = "https://github.com/rcore-os/rcore-fs" }
[target.'cfg(target_arch = "x86_64")'.dependencies] [target.'cfg(target_arch = "x86_64")'.dependencies]
bootloader = { git = "https://github.com/rcore-os/bootloader", branch = "linear" } bootloader = { git = "https://github.com/rcore-os/bootloader", branch = "vga" }
apic = { git = "https://github.com/rcore-os/apic-rs" } apic = { git = "https://github.com/rcore-os/apic-rs" }
x86_64 = "0.6" x86_64 = "0.6"
raw-cpuid = "6.0" raw-cpuid = "6.0"

@ -37,7 +37,7 @@ pub fn init() {
*/ */
board::init_driver(); board::init_driver();
console::init(); console::init();
if let Some(con) = console::CONSOLE.lock().as_mut() { //if let Some(con) = console::CONSOLE.lock().as_mut() {
con.clear(); //con.clear();
} //}
} }

@ -15,7 +15,6 @@ pub mod paging;
pub mod rand; pub mod rand;
pub mod syscall; pub mod syscall;
pub mod timer; pub mod timer;
pub mod ipi;
pub mod board; pub mod board;
static AP_CAN_INIT: AtomicBool = AtomicBool::new(false); static AP_CAN_INIT: AtomicBool = AtomicBool::new(false);

@ -5,6 +5,7 @@ use core::fmt;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use log::*; use log::*;
use spin::Mutex; use spin::Mutex;
use crate::fs::vga::{fb_var_screeninfo, fb_bitfield};
/// Framebuffer information /// Framebuffer information
#[repr(C)] #[repr(C)]
@ -237,6 +238,16 @@ impl Framebuffer {
pub fn clear(&mut self) { pub fn clear(&mut self) {
self.fill(0, self.fb_info.screen_size as usize, 0); self.fill(0, self.fb_info.screen_size as usize, 0);
} }
pub fn fill_var_screeninfo(&self, var_info : &mut fb_var_screeninfo) {
var_info.xres = self.fb_info.xres;
var_info.yres = self.fb_info.yres;
var_info.xres_virtual = self.fb_info.xres_virtual;
var_info.yres_virtual = self.fb_info.yres_virtual;
var_info.xoffset = self.fb_info.xoffset;
var_info.yoffset = self.fb_info.yoffset;
var_info.bits_per_pixel = self.fb_info.depth;
}
} }
lazy_static! { lazy_static! {

@ -20,7 +20,7 @@ mod ioctl;
mod pipe; mod pipe;
mod pseudo; mod pseudo;
mod stdio; mod stdio;
mod vga; pub mod vga;
// Hard link user programs // Hard link user programs
#[cfg(feature = "link_user")] #[cfg(feature = "link_user")]

@ -19,7 +19,6 @@ macro_rules! impl_inode {
fn move_(&self, _old_name: &str, _target: &Arc<INode>, _new_name: &str) -> Result<()> { Err(FsError::NotDir) } fn move_(&self, _old_name: &str, _target: &Arc<INode>, _new_name: &str) -> Result<()> { Err(FsError::NotDir) }
fn find(&self, _name: &str) -> Result<Arc<INode>> { Err(FsError::NotDir) } fn find(&self, _name: &str) -> Result<Arc<INode>> { Err(FsError::NotDir) }
fn get_entry(&self, _id: usize) -> Result<String> { Err(FsError::NotDir) } fn get_entry(&self, _id: usize) -> Result<String> { Err(FsError::NotDir) }
fn io_control(&self, cmd: u32, data: usize) -> Result<()> { Err(FsError::NotSupported) }
fn fs(&self) -> Arc<FileSystem> { unimplemented!() } fn fs(&self) -> Arc<FileSystem> { unimplemented!() }
fn as_any_ref(&self) -> &Any { self } fn as_any_ref(&self) -> &Any { self }
}; };
@ -62,5 +61,102 @@ impl INode for Vga {
gid: 0, gid: 0,
}) })
} }
fn io_control(&self, cmd: u32, data: usize) -> Result<()> {
info!("cmd {:#x} , data {:#x} vga not support ioctl !", cmd, data);
match cmd {
FBIOGET_FSCREENINFO => {
let fb_fix_info = unsafe{ &mut *(data as *mut fb_fix_screeninfo) };
fb_fix_info.line_length = 100;
Ok(())
},
FBIOGET_VSCREENINFO => {
let fb_var_info = unsafe{ &mut *(data as *mut fb_var_screeninfo) };
if let Some(fb) = FRAME_BUFFER.lock().as_ref() {
fb.fill_var_screeninfo(fb_var_info);
}
Ok(())
},
_ => {
warn!("use never support ioctl !");
Err(FsError::NotSupported)
}
}
//let fb_fix_info = unsafe{ &mut *(data as *mut fb_fix_screeninfo) };
//Ok(())
}
impl_inode!(); impl_inode!();
} }
const FBIOGET_FSCREENINFO : u32 = 0x4602;
const FBIOGET_VSCREENINFO : u32 = 0x4600;
#[repr(C)]
struct fb_fix_screeninfo {
pub id : [u8;16], /* identification string eg "TT Builtin" */
pub smem_start : u64, /* Start of frame buffer mem */
/* (physical address) */
pub smem_len : u32, /* Length of frame buffer mem */
pub _type : u32, /* see FB_TYPE_* */
pub type_aux : u32, /* Interleave for interleaved Planes */
pub visual : u32, /* see FB_VISUAL_* */
pub xpanstep : u16, /* zero if no hardware panning */
pub ypanstep : u16, /* zero if no hardware panning */
pub ywrapstep : u16, /* zero if no hardware ywrap */
pub line_length : u32, /* length of a line in bytes */
pub mmio_start : u64, /* Start of Memory Mapped I/O */
/* (physical address) */
pub mmio_len : u32, /* Length of Memory Mapped I/O */
pub accel : u32, /* Indicate to driver which */
/* specific chip/card we have */
pub capabilities : u16, /* see FB_CAP_* */
pub reserved : [u16;2], /* Reserved for future compatibility */
}
#[repr(C)]
pub struct fb_var_screeninfo {
pub xres : u32, /* visible resolution */
pub yres : u32,
pub xres_virtual : u32, /* virtual resolution */
pub yres_virtual : u32,
pub xoffset : u32, /* offset from virtual to visible */
pub yoffset : u32, /* resolution */
pub bits_per_pixel : u32, /* guess what */
pub grayscale : u32, /* 0 = color, 1 = grayscale, */
/* >1 = FOURCC */
pub red : fb_bitfield , /* bitfield in fb mem if true color, */
pub green : fb_bitfield , /* else only length is significant */
pub blue : fb_bitfield ,
pub transp : fb_bitfield , /* transparency */
pub nonstd : u32, /* != 0 Non standard pixel format */
pub activate : u32, /* see FB_ACTIVATE_* */
pub height : u32, /* height of picture in mm */
pub width : u32, /* width of picture in mm */
pub accel_flags : u32, /* (OBSOLETE) see fb_info.flags */
/* Timing: All values in pixclocks, except pixclock (of course) */
pub pixclock : u32, /* pixel clock in ps (pico seconds) */
pub left_margin : u32, /* time from sync to picture */
pub right_margin : u32, /* time from picture to sync */
pub upper_margin : u32, /* time from sync to picture */
pub lower_margin : u32,
pub hsync_len : u32, /* length of horizontal sync */
pub vsync_len : u32, /* length of vertical sync */
pub sync : u32, /* see FB_SYNC_* */
pub vmode : u32, /* see FB_VMODE_* */
pub rotate : u32, /* angle we rotate counter clockwise */
pub colorspace : u32, /* colorspace for FOURCC-based modes */
pub reserved : [u32;4], /* Reserved for future compatibility */
}
#[repr(C)]
pub struct fb_bitfield {
pub offset : u32, /* beginning of bitfield */
pub length : u32, /* length of bitfield */
pub msb_right : u32, /* != 0 : Most significant bit is */
/* right */
}

Loading…
Cancel
Save